proxmox_scripts/arch_setup.sh

76 lines
2.6 KiB
Bash
Raw Normal View History

2017-11-03 23:41:14 +00:00
#!/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.
2017-11-04 00:24:52 +00:00
echo "----> Enabling SSH"
2017-11-03 23:41:14 +00:00
systemctl enable sshd
systemctl start sshd
# Setup keys for pacman
2017-11-04 00:24:52 +00:00
echo "----> Setting up keys for pacman"
2017-11-03 23:41:14 +00:00
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.
2017-11-04 00:24:52 +00:00
echo "----> Setting up mirror list"
2017-11-03 23:41:14 +00:00
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
2017-11-03 23:48:41 +00:00
cat > /etc/pacman.d/mirrorlist <<-`EOM05594313219813`
2017-11-03 23:41:14 +00:00
# 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
2017-11-03 23:51:05 +00:00
`EOM05594313219813`
2017-11-03 23:41:14 +00:00
2017-11-04 02:17:59 +00:00
# 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
2017-11-04 01:25:43 +00:00
# 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
2017-11-03 23:41:14 +00:00
# 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.
2017-11-04 00:24:52 +00:00
echo "----> Installing package-query and yaourt"
mkdir ~/tmp
cd ~/tmp
2017-11-03 23:41:14 +00:00
# ----------- package query for yaourt -----------
git clone https://aur.archlinux.org/package-query.git
cd package-query
2017-11-04 02:16:20 +00:00
makepkg -si --noconfirm
2017-11-03 23:41:14 +00:00
cd ..
# ----------- yaourt itself -----------
git clone https://aur.archlinux.org/yaourt.git
cd yaourt
2017-11-04 02:16:20 +00:00
makepkg -si --noconfirm
2017-11-03 23:41:14 +00:00
cd ..
2017-11-04 02:16:20 +00:00
# Wipe tmp dir
2017-11-04 00:20:45 +00:00
cd ..
rm -r -f ~/tmp
2017-11-04 02:16:20 +00:00
# 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]}')
2017-11-03 23:41:14 +00:00
2017-11-04 02:16:20 +00:00
# And say what the IP address is to the terminal.
cowsay "All Done! $ipv4addr $ipv6addr"