#!/usr/bin/bash # To run this script, do the following: # For making the script stop if something fails like make. set -e set -o pipefail # Enable and start sshd so we can ssh in here in the future. echo "----> Enabling SSH" systemctl enable sshd systemctl start sshd # Setup keys for pacman echo "----> Setting up keys for pacman" pacman-key --init pacman-key --populate archlinux # Setup mirrors, hardcoded for now. Could have been done with rankmirror # with USA and worldwide mirrors but eh. echo "----> Setting up mirror list" mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup cat > /etc/pacman.d/mirrorlist <<-`EOM05594313219813` # Server list generated by rankmirrors on 2017-11-03 ## ## Arch Linux repository mirrorlist ## Generated on 2017-06-28 ## ## Worldwide ## United States Server = http://mirror.nexcess.net/archlinux/$repo/os/$arch Server = http://mirror.epiphyte.network/archlinux/$repo/os/$arch Server = http://arch.mirror.constant.com/$repo/os/$arch Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch `EOM05594313219813` # Do an update and install some packages. echo "----> Updating and installing base-devel, git, htop, vim, and cowsay" pacman -Syu base-devel git htop vim cowsay --noconfirm # Disable root check for makepkg since we are using root for everything. # Replace the "if (( EUID == 0 )); then" with "if (( 0 )); then" to force root # check to always fail. sed -i 's/if (( EUID == 0 )); then/if (( 0 )); then/' /usr/bin/makepkg # Install Yaourt. Why yaourt instead of pacaur? Because pacaur doesn't allow # itself to be ran as root, even though all we have is root in the container, # and I don't want to bother fiddling with users just for this. Yaourt on the # other hand works fine for this. echo "----> Installing package-query and yaourt" mkdir ~/tmp cd ~/tmp # ----------- package query for yaourt ----------- git clone https://aur.archlinux.org/package-query.git cd package-query makepkg -si --noconfirm cd .. # ----------- yaourt itself ----------- git clone https://aur.archlinux.org/yaourt.git cd yaourt makepkg -si --noconfirm cd .. # Wipe tmp dir cd .. rm -r -f ~/tmp # Get the ip addresses using some grep and awk magic. ipv6addr=$(ip -6 addr show eth0 | grep /128 | grep -v fd75 | awk '{a=$2; split(a, b, "/"); print b[1]}') ipv4addr=$(ip -4 addr show eth0 | grep inet | awk '{a=$2; split(a, b, "/"); print b[1]}') # And say what the IP address is to the terminal. cowsay "All Done! $ipv4addr $ipv6addr"