make launch.sh more generic, move IP info to deploy.pl
This commit is contained in:
parent
b73fd92ae1
commit
a0b3e8fa3d
33
launch.sh
33
launch.sh
|
@ -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,41 +38,46 @@ 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
|
||||
|
||||
if [[ "${SERVER}" == server* ]]; then
|
||||
HOST="s${SERVER#server}"
|
||||
elif [[ "${SERVER}" == mega* ]]; then
|
||||
HOST="m${SERVER#mega}"
|
||||
fi
|
||||
|
||||
if [[ "${SERVER}" == server* ]] || [[ "${SERVER}" == mega* ]]; then
|
||||
openrsync -va --del /home/mischa/vms/ mischa@wm1.obsda.ms:vms/${HOST}/
|
||||
ssh wm1.obsda.ms "doas ./create-user.pl ${HOST}${1}"
|
||||
openrsync -va --del /home/mischa/vms/ mischa@rx.high5.nl:vms/${HOST}/
|
||||
fi
|
||||
|
||||
deploy.pl
|
||||
sleep 10
|
||||
if [[ -z ${DHCPD} ]]; then
|
||||
rcctl restart dhcpd
|
||||
fi
|
||||
vmctl reload
|
||||
sleep 10
|
||||
|
||||
echo -n "Hostname: " ; grep -A7 ${1} /etc/dhcpd.conf | awk '/host-name/ {print $3}' | tr -d ';' | tr -d '"'
|
||||
echo -n "IPv4: " ; grep -A7 ${1} /etc/dhcpd.conf | awk '/fixed-address / {print $2}' | tr -d ';'
|
||||
echo -n "IPv6: " ; grep -A7 ${1} /etc/dhcpd.conf | awk '/fixed-address-ipv6/ {print $2}' | tr -d ';'
|
||||
echo
|
||||
|
||||
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
|
||||
|
@ -84,13 +89,15 @@ echo "completed"
|
|||
|
||||
deploy.pl
|
||||
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*)
|
||||
|
@ -102,6 +109,6 @@ done > /tmp/pipe_${1} 2>> ${LOGS}/${1}.log
|
|||
rm -rf /tmp/pipe_${1}
|
||||
|
||||
echo
|
||||
echo "SUCCES! - deployed ${1}"
|
||||
echo "SUCCES! - deployed ${INSTANCE}"
|
||||
notify.pl deployed ${1}
|
||||
pushover.pl -m "${SERVER} ${1} deployed" -t "OpenBSD Amsterdam"
|
||||
pushover.pl -m "${SERVER} ${INSTANCE} deployed" -t "OpenBSD Amsterdam"
|
||||
|
|
Loading…
Reference in New Issue