dataset/seed/base-machine/manual/install/install_machines

62 lines
1.6 KiB
Text
Raw Permalink Normal View History

2022-05-04 10:29:03 +02:00
#!/bin/bash -e
2022-03-08 19:42:28 +01:00
HOST_NAME=$1
if [ -z "$HOST_NAME" ]; then
echo "usage: $0 host name"
exit 1
fi
MACHINES=""
for image in *; do
if [ -d "$image" ]; then
for os in $image/configurations/*; do
if [ -d "$os" ]; then
osname="$(basename $os)"
if [ -f "host/configurations/$HOST_NAME/etc/systemd/nspawn/$osname.nspawn" ]; then
MACHINES="$MACHINES$osname "
fi
2022-08-19 20:30:13 +02:00
echo
2022-05-04 10:29:03 +02:00
echo "Install machine $image"
2022-03-08 19:42:28 +01:00
./install_machine "$HOST_NAME" "$image" "$osname"
fi
done
fi
done
machinectl enable $MACHINES
machinectl start $MACHINES
2022-08-19 20:30:13 +02:00
STARTED=""
DEGRADED=""
found=true
idx=0
while [ $found = true ]; do
found=false
echo "tentative $idx"
for machine in $MACHINES; do
if ! echo $STARTED | grep -q " $machine "; then
status=$(machinectl -q shell $machine /usr/bin/systemctl is-system-running || true)
if echo "$status" | grep -q degraded; then
STARTED="$STARTED $machine "
DEGRADED="$DEGRADED $machine"
elif echo "$status" | grep -q running; then
STARTED="$STARTED $machine "
else
found=true
echo "status actuel de $machine : $status"
fi
fi
done
sleep 2
idx=$((idx+1))
if [ $idx = 60 ]; then
break
fi
done
retcode=0
for machine in $DEGRADED; do
echo
echo "========= $machine"
machinectl -q shell $machine /usr/bin/systemctl --state=failed --no-legend --no-pager
retcode=1
done
2022-03-08 19:42:28 +01:00
2022-08-19 20:30:13 +02:00
exit $retcode