Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Provision script to setup Ubuntu18.04 on VirtualBox VM
#!/bin/bash
set -xuo pipefail
# GIST: https://gist.github.com/djravine/19f4d820bce3d716108b3f77d7132275
# USAGE: ssh -t -p 2222 adan@localhost 'curl -sL https://gist.github.com/djravine/19f4d820bce3d716108b3f77d7132275/raw | sudo bash -s -- adan'
# CHECK USERNAME
USERNAME=$1
# SET LOCALE
LOCALE="en_AU.UTF-8"
LOCALE_ALT="en_AU en_GB.UTF-8 en_GB en_US.UTF-8 en_US"
LANGUAGE="en_AU:en_GB:en"
locale-gen $LOCALE $LOCALE_ALT
update-locale LANG=$LOCALE
update-locale LANGUAGE=$LANGUAGE
update-locale LC_ALL=$LOCALE
update-locale LC_NUMERIC=$LOCALE
update-locale LC_TIME=$LOCALE
update-locale LC_MONETARY=$LOCALE
update-locale LC_PAPER=$LOCALE
update-locale LC_IDENTIFICATION=$LOCALE
update-locale LC_NAME=$LOCALE
update-locale LC_ADDRESS=$LOCALE
update-locale LC_TELEPHONE=$LOCALE
update-locale LC_MEASUREMENT=$LOCALE
dpkg-reconfigure --frontend noninteractive locales
# INSTALL SOFTWARE
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
#apt-get install -y \
#ubuntu-desktop
apt-get autoremove -y
# GEN SSH KEYS
ssh-keygen -A
# ALLOW SSH CONNECTIONS
ufw allow ssh
# MAKE DEV FOLDER
mkdir -p /development
chown $USERNAME:$USERNAME /development
# ADD USER TO VIRTUAL BOX GROUP
adduser $USERNAME vboxsf
# ADD MOUNT TO FSTAB
if ! grep -q "development" /etc/fstab; then
echo "development /development vboxsf rw,uid=$(id -u $USERNAME),gid=$(id -g $USERNAME) 0 0" | tee -a /etc/fstab
fi
# REBOOT
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.