Logging fix, using static IP, yaourt->yay, and changed to 10.10.10.200

This commit is contained in:
hak8or 2018-12-23 21:43:27 -05:00
parent b4026ccf13
commit 0167216d0c
2 changed files with 37 additions and 30 deletions

48
arch_setup.sh Normal file → Executable file
View File

@ -25,19 +25,19 @@ set -o pipefail
# Enable and start sshd so we can ssh in here in the future.
echo "$TAGSTR Enabling SSH"
systemctl enable sshd > $LOGFILE 2>&1
systemctl start sshd > $LOGFILE 2>&1
systemctl enable sshd >> $LOGFILE 2>&1
systemctl start sshd >> $LOGFILE 2>&1
# Setup keys for pacman
echo "$TAGSTR Setting up keys for pacman"
pacman-key --init > $LOGFILE 2>&1
pacman-key --populate archlinux > $LOGFILE 2>&1
pacman-key --init >> $LOGFILE 2>&1
pacman-key --populate archlinux >> $LOGFILE 2>&1
# Setup mirrors, hardcoded for now. Could have been done with rankmirror
# with USA and worldwide mirrors but eh.
echo "$TAGSTR Setting up mirror list"
if [[ -e /etc/pacman.d/mirrorlist ]]; then
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup # > $LOGFILE 2>&1
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup # >> $LOGFILE 2>&1
fi
cat <<- 'EOM05594313219813' > /etc/pacman.d/mirrorlist
# Server list generated by rankmirrors on 2017-11-03
@ -57,42 +57,42 @@ EOM05594313219813
# Update as needed.
echo "$TAGSTR Updating all packages as needed"
pacman -Syu --noconfirm > $LOGFILE 2>&1
pacman -Syu --noconfirm >> $LOGFILE 2>&1
# Do an update and install some packages.
echo "$TAGSTR Installing base-devel, git, htop, vim, rsync, go, dotnet-sdk, wget, tmux, and cowsay"
pacman -Syu base-devel git htop vim cowsay rsync go dotnet-sdk wget tmux --noconfirm --needed > $LOGFILE 2>&1
pacman -Syu base-devel git htop vim cowsay rsync go dotnet-sdk wget tmux --noconfirm --needed >> $LOGFILE 2>&1
# Change locale to EN US UTF-8
echo "$TAGSTR Changing locale to EN US UTF-8"
sed -i 's/if (( EUID == 0 )); then/if (( 0 )); then/' /usr/bin/makepkg > $LOGFILE 2>&1
sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen > $LOGFILE 2>&1
locale-gen > $LOGFILE 2>&1
echo LANG=en_US.UTF-8 > /etc/locale.conf > $LOGFILE 2>&1
sed -i 's/if (( EUID == 0 )); then/if (( 0 )); then/' /usr/bin/makepkg >> $LOGFILE 2>&1
sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen >> $LOGFILE 2>&1
locale-gen >> $LOGFILE 2>&1
echo LANG=en_US.UTF-8 > /etc/locale.conf >> $LOGFILE 2>&1
export LANG=en_US.UTF-8
# Install Yaourt. Why yaourt instead of pacaur? Because pacaur doesn't allow
# Install yay. Why yay 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
# and I don't want to bother fiddling with users just for this. Yay on the
# other hand works fine for this.
if ! type yaourt &> /dev/null; then
# 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 > $LOGFILE 2>&1
sed -i 's/if (( EUID == 0 )); then/if (( 0 )); then/' /usr/bin/makepkg >> $LOGFILE 2>&1
echo "$TAGSTR Installing package-query and yaourt"
echo "$TAGSTR Installing package-query and yay"
mkdir ~/tmp
cd ~/tmp
# ----------- package query for yaourt -----------
git clone https://aur.archlinux.org/package-query.git > $LOGFILE 2>&1
# ----------- package query for yay -----------
git clone https://aur.archlinux.org/package-query.git >> $LOGFILE 2>&1
cd package-query
makepkg -si --noconfirm > $LOGFILE 2>&1
makepkg -si --noconfirm >> $LOGFILE 2>&1
cd ..
# ----------- yaourt itself -----------
git clone https://aur.archlinux.org/yaourt.git > $LOGFILE 2>&1
cd yaourt
makepkg -si --noconfirm > $LOGFILE 2>&1
# ----------- yay itself -----------
git clone https://aur.archlinux.org/yay.git >> $LOGFILE 2>&1
cd yay
makepkg -si --noconfirm >> $LOGFILE 2>&1
cd ..
# Wipe tmp dir
cd ..
@ -101,8 +101,8 @@ fi
# Get the ip addresses using some grep and awk magic.
# Magic inspired by this: https://superuser.com/questions/468727/how-to-get-the-ipv6-ip-address-of-linux-machine
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]}')
ipv6addr=$(ip addr show dev eth0 | grep "inet6 fe80" | awk '{a=$2; split(a, b, "/"); print b[1]}')
ipv4addr=$(ip addr show dev eth0 | grep "inet 10" | awk '{a=$2; split(a, b, "/"); print b[1]}')
# Lastly, say we are done.
echo "$TAGSTR Completed $TITLE"

19
deploy.sh Normal file → Executable file
View File

@ -20,7 +20,7 @@ fi
echo "====== $TITLE ======"
# IP address of the Proxmox host
PROXMOX_IP_ADDR=192.168.1.2
PROXMOX_IP_ADDR=10.10.10.200
PROXMOX_PORT=2221
if [[ -z $PROXMOX_IP_ADDR ]]; then
echo "$TAGSTR PROXMOX_IP_ADDR was not set!"
@ -36,12 +36,12 @@ fi
# Retrieve the IP address of a container as IPv4,IPv6. Arg1 is the container ID.
FN_get_IPaddr (){
# IPv6 address fetch
IPv6ADDR=$(ssh root@$PROXMOX_IP_ADDR -p $PROXMOX_PORT "pct exec $1 ip addr show eth0 | grep /128 | grep -v fd75")
# IPv6 address fetch. We can't use the -4 or -6 flags because escaping turns into a nightmare.
IPv6ADDR=$(ssh root@$PROXMOX_IP_ADDR -p $PROXMOX_PORT "pct exec $1 ip addr show dev eth0 | grep \"inet6 fe80\"")
IPv6ADDR=$(echo $IPv6ADDR | awk '{a=$2; split(a, b, "/"); print b[1]}')
# IPv4 address fetch
IPv4ADDR=$(ssh root@$PROXMOX_IP_ADDR -p $PROXMOX_PORT "pct exec $1 ip addr show eth0 | grep inet")
IPv4ADDR=$(ssh root@$PROXMOX_IP_ADDR -p $PROXMOX_PORT "pct exec $1 ip addr show dev eth0 | grep \"inet 10\"")
IPv4ADDR=$(echo $IPv4ADDR | awk '{a=$2; split(a, b, "/"); print b[1]}')
}
@ -162,6 +162,12 @@ VMID=$(ssh -p $PROXMOX_PORT root@$PROXMOX_IP_ADDR /usr/bin/env bash <<-'AcRP030C
VMID=100
fi
# Get the IP Addresses
CTIP=10.10.10.$(($VMID + 100))/24
CTGW=10.10.10.1
CTIPv6=2001:470:8a74::$(($VMID + 100))/64
CTGWv6=2001:470:8a74::1
# Create a new container with the VMID
# Use Below to create a new container template. Can also right click in proxmox GUI
# but that does not handle clearing pacman cache, etc.
@ -170,7 +176,7 @@ VMID=$(ssh -p $PROXMOX_PORT root@$PROXMOX_IP_ADDR /usr/bin/env bash <<-'AcRP030C
# For Arch linux:
# 1. Login via pct enter isntead of ssh
# 2. Remove all contents of ~/.ssh folder
# 3. Clear pacman cache with yaourt -Scc
# 3. Clear pacman cache with yay -Scc
# 4. Exit and shutdown the container
# 5. Remove Network interface via proxmox web GUI
# 6. Create a backup (not snapshot!)
@ -179,7 +185,7 @@ VMID=$(ssh -p $PROXMOX_PORT root@$PROXMOX_IP_ADDR /usr/bin/env bash <<-'AcRP030C
TEMPLATE=archlinux_custombase_4-24-2018.tar.lzo
#TEMPLATE=archlinux-base_20170704-1_amd64.tar.gz
#TEMPLATE=archlinux_bootstrapped_11-14-2017.tar.gz
pct create $VMID /var/lib/vz/template/cache/$TEMPLATE -ssh-public-keys /tmp/id_rsa.pub -storage local-zfs -net0 name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp -ostype archlinux > /dev/null
pct create $VMID /var/lib/vz/template/cache/$TEMPLATE -ssh-public-keys /tmp/id_rsa.pub -storage local-zfs -net0 name=eth0,bridge=vmbr2004,ip=$CTIP,gw=$CTGW,ip6=$CTIPv6,gw6=$CTGWv6, -ostype archlinux > /dev/null
# Start the container.
pct start $VMID > /dev/null
@ -200,6 +206,7 @@ FN_get_IPaddr $VMID
# Wipe the fingerprint of the host in case it was used earlier.
ssh-keygen -R $IPv6ADDR > /dev/null
ssh-keygen -R $IPv4ADDR > /dev/null
# Run any potential secondary script.
if [[ -n $1 ]]; then