3 # Copyright (c) 2019-2023 Mischa Peters <mischa @ openbsd.amsterdam>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 CONF_FILE="${PWD}/_deploy.conf"
18 if [[ -f "${CONF_FILE}" ]]; then
21 echo "unable to find _deploy.conf"
24 if [[ -z ${1} ]]; then
25 echo "usage: ${0##*/} vmXX"
28 if [[ ! -f "${VMS}/${1}.txt" ]]; then
29 echo "unable to find ${VMS}/${1}.txt"
30 if [[ -f "${VMS}/${1}.txt.free" ]]; then
31 echo "found ${VMS}/${1}.txt.free"
32 mv ${VMS}/${1}.txt.free ${VMS}/${1}.txt
37 chown mischa ${VMS}/${1}.txt
38 chmod 600 ${VMS}/${1}.txt
41 INSTANCE=$(awk -F'=' '/instance/ {print $2}' ${VMS}/${1}.txt | tr -d '"')
42 if [[ -z ${INSTANCE} ]]; then
48 if [[ -z ${DHCPD} ]]; then
54 mkfifo -m 600 /tmp/pipe_${1}
55 install -g mischa -m 600 -o mischa /dev/null ${LOGS}/${1}.log
57 echo -n "autoinstall(8) ${INSTANCE}, log output ${LOGS}/${1}.log... "
59 vmctl start -c ${INSTANCE} < /tmp/pipe_${1} | while read line; do
60 printf '%s\n' "$line" >&2
63 vmctl stop -f ${INSTANCE}
66 #Response file location\?*)
68 #rm -rf /tmp/pipe_${1}
69 #rm -rf /var/vmm/${1}.qcow2
70 #pushover.pl -m "${SERVER} ${1} failed deploy" -t "OpenBSD Amsterdam" -p 1
74 done > /tmp/pipe_${1} 2> ${LOGS}/${1}.log
80 if [[ -z ${DHCPD} ]]; then
86 echo "booting ${INSTANCE}"
88 vmctl start -c ${INSTANCE} < /tmp/pipe_${1} | while read line; do
89 printf '%s\n' "$line" >&2
95 done > /tmp/pipe_${1} 2>> ${LOGS}/${1}.log
100 echo "SUCCES! - re-deployed ${INSTANCE}"
101 notify.pl redeployed ${1}
102 pushover.pl -m "${SERVER} ${INSTANCE} re-deployed" -t "OpenBSD Amsterdam"