hacks/cloud-init.sh

64 lines
1.5 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 22:20:50 +00:00
apt-get -y install vim byobu screen build-essential git mosh bash-completion golang-go python-pip python3-pip
2018-03-06 21:04:21 +00:00
2018-03-06 22:20:50 +00:00
pip3 install --upgrade pip
pip3 install awscli pipenv aws-shell
curl -L https://github.com/docker/machine/releases/download/v0.14.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine
chmod +x /usr/local/bin/docker-machine
# create user if doesn't exist
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:20:50 +00:00
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
2018-03-06 22:21:39 +00:00
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
nvm install node
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