make relaunch.sh more generic, move IP info to deploy.pl

This commit is contained in:
mischa 2023-05-05 23:02:00 +02:00
parent a0b3e8fa3d
commit 9db62fa0eb
1 changed files with 22 additions and 10 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2022 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2023 Mischa Peters <mischa @ openbsd.amsterdam>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -38,25 +38,34 @@ else
chmod 600 ${VMS}/${1}.txt
fi
INSTANCE=$(awk -F'=' '/instance/ {print $2}' ${VMS}/${1}.txt | tr -d '"')
if [[ -z ${INSTANCE} ]]; then
INSTANCE=${1}
fi
deploy.pl
rcctl restart dhcpd
sleep 10
if [[ -z ${DHCPD} ]]; then
rcctl restart dhcpd
fi
vmctl reload
sleep 10
mkfifo -m 600 /tmp/pipe_${1}
install -g mischa -m 600 -o mischa /dev/null ${LOGS}/${1}.log
echo -n "autoinstall(8) ${1}, log output ${LOGS}/${1}.log... "
echo -n "autoinstall(8) ${INSTANCE}, log output ${LOGS}/${1}.log... "
vmctl start -c ${1} < /tmp/pipe_${1} | while read line; do
vmctl start -c ${INSTANCE} < /tmp/pipe_${1} | while read line; do
printf '%s\n' "$line" >&2
case $line in
*rebooting...*)
vmctl stop -f ${1}
vmctl stop -f ${INSTANCE}
break
;;
#Response file location\?*)
#vmctl stop -f ${1}
#rm -rf /tmp/pipe_${1}
#rm -rf /var/vmm/${1}.qcow2
#pushover.pl -m "${SERVER} ${1} failed deploy" -t "OpenBSD Amsterdam" -p 1
#exit 1
@ -67,13 +76,16 @@ done > /tmp/pipe_${1} 2> ${LOGS}/${1}.log
echo "completed"
deploy.pl
rcctl restart dhcpd
sleep 10
if [[ -z ${DHCPD} ]]; then
rcctl restart dhcpd
fi
vmctl reload
sleep 10
echo "booting ${1}"
echo "booting ${INSTANCE}"
vmctl start -c ${1} < /tmp/pipe_${1} | while read line; do
vmctl start -c ${INSTANCE} < /tmp/pipe_${1} | while read line; do
printf '%s\n' "$line" >&2
case $line in
*tty00*)
@ -85,6 +97,6 @@ done > /tmp/pipe_${1} 2>> ${LOGS}/${1}.log
rm -rf /tmp/pipe_${1}
echo
echo "SUCCES! - re-deployed ${1}"
echo "SUCCES! - re-deployed ${INSTANCE}"
notify.pl redeployed ${1}
pushover.pl -m "${SERVER} ${1} re-deployed" -t "OpenBSD Amsterdam"
pushover.pl -m "${SERVER} ${INSTANCE} re-deployed" -t "OpenBSD Amsterdam"