#!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${MOTD_FROM="${DIR}/motd.sh"} : ${MOTD_TO="/etc/update-motd.d/90-privex"} # The default non-privileged user, for adding to groups and things. : ${BASE_USER='ubuntu'} # If set to 1 before running this script, debugging output will be shown. : ${PVXDEBUG=0} # List of locales to generate, will uncomment all locales starting with the given string # e.g. en_GB will cover en_GB.UTF-8 as well as en_GB.ISO-8859-1 etc. ENABLE_LOCALES=('en_GB' 'en_US') export DEBIAN_FRONTEND="noninteractive" INSTALL_PKGS=( # General git curl wget # Session management tmux screen # Security iptables-persistent fail2ban # Network tools mtr-tiny iputils-ping nmap netcat dnsutils # Development build-essential vim nano zsh jq # Server debugging/stats htop nmon iotop sysstat # sysstat = iotop # Compression/Decompression liblz4-tool # lz4 for fast compress/decompress zip unzip xz-utils # Python3 for various things python3 python3-pip python3-venv # Command-not-found, to tell you where to find a command in apt command-not-found ) export TERM="xterm-256color" RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" BOLD="$(tput bold)" NORMAL="$(tput sgr0)" RESET="$(tput sgr0)" debug() { if ((${PVXDEBUG}==1)); then >&2 echo "${BOLD}${YELLOW}$@${RESET}" fi } if [[ ! -f "$MOTD_TO" ]]; then debug "$MOTD_TO did not exist. Copying $MOTD_FROM into $MOTD_TO" sudo install "$MOTD_FROM" "$MOTD_TO" fi # Don't popup asking whether or not we want to save rules... echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections debug " >> Updating apt repos" sudo apt-get update -q > /dev/null for pkg in "${INSTALL_PKGS[@]}"; do debug "Installing package ${pkg}..." sudo apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" "$pkg" >/dev/null done debug " >> Making sure the 'locales' package is installed..." sudo apt install -qy locales >/dev/null debug " >> Removing /etc/default/locale" sudo rm /etc/default/locale debug " >> Generating /etc/default/locale" cat << EOF | sudo tee /etc/default/locale LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 EOF debug " >> Enabling locales in /etc/locale.gen specified in ENABLE_LOCALES " for l in "${ENABLE_LOCALES[@]}"; do debug " ... Uncommenting locales starting with $l " sudo sed -i "/^#.* ${l}.*/s/^# //g" /etc/locale.gen done echo " >> Re-generating locale files " sudo locale-gen debug " >> Installing /etc/gitignore" sudo install "$DIR/dotfiles/gitignore" /etc/gitignore debug " >> Installing /etc/vimrc.local" sudo install "$DIR/dotfiles/vimrc" /etc/vim/vimrc.local debug " >> Generating /etc/gitconfig to use global gitignore" cat << EOF | sudo tee /etc/gitconfig >/dev/null [core] excludesfile = /etc/gitignore EOF debug " >> Installing Docker" curl https://get.docker.com | sudo sh debug " >> Adding $BASE_USER to group 'docker'" if id -u "$BASE_USER"; then sudo gpasswd -a "$BASE_USER" docker fi