hacks/cloud-init.sh

50 lines
1.1 KiB
Bash
Raw Normal View History

2018-03-06 21:04:21 +00:00
#!/bin/sh
2018-03-06 21:27:31 +00:00
# fetch and run this in cloud-init, viz:
2018-03-06 21:04:21 +00:00
2018-03-06 21:27:31 +00:00
##cloud-config
#runcmd:
2018-03-06 22:07:09 +00:00
# - curl -fsSL https://raw.githubusercontent.com/sneak/hacks/master/cloud-init.sh | bash
2018-03-06 21:27:31 +00:00
#exec 1 2>&1 | tee -a ${LOG_FILE}
export DEBIAN_FRONTEND=noninteractive
2018-03-06 21:04:21 +00:00
apt-get update
apt-get -y upgrade
2018-03-06 21:44:43 +00:00
apt-get -y install vim byobu screen build-essential git mosh bash-completion
2018-03-06 21:04:21 +00:00
if [[ ! -d /home/sneak ]]; then
2018-03-06 21:56:19 +00:00
useradd -m -s /bin/bash sneak
2018-03-06 21:16:02 +00:00
usermod -a -G sudo sneak
2018-03-06 22:10:39 +00:00
echo "sneak ALL=NOPASSWD:ALL" > /etc/sudoers.d/sneak
2018-03-06 21:04:21 +00:00
fi
2018-03-06 21:12:04 +00:00
# run the rest as sneak:
sudo -H -u sneak bash <<EOF
2018-03-06 22:07:09 +00:00
export HOME=/home/sneak
if [[ ! -d ~/.ssh ]]; then
mkdir -p ~/.ssh
2018-03-06 21:04:21 +00:00
fi
2018-03-06 22:07:09 +00:00
if [[ ! -e ~/.ssh/sneak.keys ]]; then
cd ~/.ssh && \
2018-03-06 21:04:21 +00:00
wget https://github.com/sneak.keys && \
cat *.keys > authorized_keys
fi
2018-03-06 21:12:04 +00:00
2018-03-06 22:07:09 +00:00
if [[ ! -d ~/hacks ]]; then
cd ~
2018-03-06 21:12:04 +00:00
git clone https://github.com/sneak/hacks.git
fi
2018-03-06 22:07:09 +00:00
mkdir -p ~/.local/bashrc.d
mkdir -p ~/.local/profile.d
2018-03-06 21:12:04 +00:00
2018-03-06 22:07:09 +00:00
mv ~/.profile ~/.local/profile.d/999.distro.profile.sh
mv ~/.bashrc ~/.local/bashrc.d/999.distro.bashrc.sh
rsync -avP /home/sneak/hacks/homedir.skel/ /home/sneak/
2018-03-06 21:12:04 +00:00
EOF