deploy script almost done! :D

5 years ago
parent 1890f3fb43
commit a741cde852
  1. 5
  2. 38

@ -18,7 +18,7 @@ pacman-key --populate archlinux
# 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`
cat <<- 'EOM05594313219813' > /etc/pacman.d/mirrorlist
# Server list generated by rankmirrors on 2017-11-03
## Arch Linux repository mirrorlist
@ -32,7 +32,8 @@ cat > /etc/pacman.d/mirrorlist <<-`EOM05594313219813`
Server =$repo/os/$arch
Server =$repo/os/$arch
Server =$repo/os/$arch
cat /etc/pacman.d/mirrorlist
# Do an update and install some packages.
echo "----> Updating and installing base-devel, git, htop, vim, and cowsay"

@ -57,8 +57,42 @@ if [[ $1 == "-ID" ]]; then
# Make sure SSH public key is in proxmox host. This overwrites if it exists.
scp $HOME/.ssh/ root@$PROXMOX_IP_ADDR:/tmp/ > /dev/null
# No specific container was provided, so we create one.
# Can pass small script like this:
ssh root@$PROXMOX_IP_ADDR /usr/bin/env bash <<-'AcRP030CAlfad6'
echo "Hello world! :D"
VMID=$(ssh root@$PROXMOX_IP_ADDR /usr/bin/env bash <<-'AcRP030CAlfad6'
# use the highest VMID+1 as our new VMID. This returns 1 if no VMID's exist.
VMID=$(pct list | awk 'NR > 1 {print $1}' | sort -nr | head -n1)
VMID=$(($VMID + 1))
# VMID's less than 100 are for internal proxmox use, make sure we are >= 100.
# This also could mean there were no proxmox boxes created.
if [[ $VMID -lt 100 ]]; then
# Create a new container with the VMID
pct create $VMID /var/lib/vz/template/cache/archlinux-base_20170704-1_amd64.tar.gz -ssh-public-keys /tmp/ -storage local-zfs -net0 name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp -ostype archlinux > /dev/null
# Start the container.
pct start $VMID > /dev/null
# And say all went well.
echo "$VMID"
echo "Completed Container Init, ID: $VMID"
# Send our default arch init script over to proxmox host. This overwrites any old file.
scp root@$PROXMOX_IP_ADDR:/tmp/ > /dev/null
# Copy the script into the container and run it.
ssh root@$PROXMOX_IP_ADDR /usr/bin/env bash <<- AcRP030CAlfad6
pct push $VMID /tmp/ /tmp/ > /dev/null
pct exec $VMID chmod +x /tmp/
pct exec $VMID /tmp/
echo " Complete!"