2022-10-01 22:33:11 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# root dir configuration
|
|
|
|
RISOTTO_DIR="/var/lib/risotto"
|
|
|
|
RISOTTO_IMAGE_DIR="$RISOTTO_DIR/images"
|
|
|
|
# image configuration
|
|
|
|
IMAGE_BASE_RISOTTO_BASE_DIR="$RISOTTO_IMAGE_DIR/image_bases"
|
|
|
|
|
|
|
|
rm -f $IMAGE_BASE_RISOTTO_BASE_DIR*.build
|
|
|
|
|
|
|
|
ls /var/lib/risotto/images_files/ | while read image; do
|
|
|
|
if [ -d /var/lib/risotto/images_files/"$image" ]; then
|
|
|
|
echo
|
|
|
|
echo "Install image $image"
|
|
|
|
/usr/local/sbin/build_image "$image"
|
|
|
|
fi
|
|
|
|
done
|
2022-10-17 18:48:32 +02:00
|
|
|
#rm -f $IMAGE_BASE_RISOTTO_BASE_DIR*.build
|
2022-10-01 22:33:11 +02:00
|
|
|
|
|
|
|
MACHINES=""
|
|
|
|
for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
|
|
|
nspawn_file=$(basename $nspawn)
|
|
|
|
machine=${nspawn_file%.*}
|
|
|
|
MACHINES="$MACHINES$machine "
|
|
|
|
MACHINE_MACHINES_DIR="/var/lib/machines/$machine"
|
|
|
|
SHA_MACHINE="$RISOTTO_DIR/configurations/sha/$machine".sha
|
|
|
|
content=$(cat $SHA_MACHINE)
|
|
|
|
IMAGE_NAME_RISOTTO_IMAGE_NAME=${content##* }
|
2022-10-17 18:48:32 +02:00
|
|
|
diff -q "$IMAGE_NAME_RISOTTO_IMAGE_NAME".sha "$SHA_MACHINE" > /dev/null || (
|
|
|
|
echo "Reinstall machine $machine"
|
2022-10-01 22:33:11 +02:00
|
|
|
machinectl stop $machine
|
|
|
|
while true; do
|
|
|
|
machinectl status "$machine" > /dev/null 2>&1 || break
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
rm -rf "$MACHINE_MACHINES_DIR"
|
|
|
|
mkdir "$MACHINE_MACHINES_DIR"
|
|
|
|
cd "$MACHINE_MACHINES_DIR"
|
|
|
|
tar xf "$IMAGE_NAME_RISOTTO_IMAGE_NAME"
|
|
|
|
cp -a "$IMAGE_NAME_RISOTTO_IMAGE_NAME".sha "$SHA_MACHINE"
|
|
|
|
)
|
|
|
|
done
|
|
|
|
machinectl start $MACHINES
|
2022-10-17 18:48:32 +02:00
|
|
|
diagnose
|