forked from stove/risotto
split update_images and diagnose
This commit is contained in:
parent
b9be6491cc
commit
74878cae0f
2 changed files with 5 additions and 39 deletions
|
@ -131,6 +131,7 @@ fi
|
||||||
if [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs ] && [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs ]; then
|
if [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs ] && [ -f "$IMAGE_NAME_RISOTTO_IMAGE_DIR".pkgs ]; then
|
||||||
echo " - différence(s) avec les paquets de base"
|
echo " - différence(s) avec les paquets de base"
|
||||||
diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs "$BASE_PKGS_FILE" && INSTALL=false || INSTALL=true
|
diff -u "$IMAGE_NAME_RISOTTO_IMAGE_DIR".base.pkgs "$BASE_PKGS_FILE" && INSTALL=false || INSTALL=true
|
||||||
|
[ ! -f "$IMAGE_NAME_RISOTTO_IMAGE_NAME" ] && INSTALL=true
|
||||||
else
|
else
|
||||||
INSTALL=true
|
INSTALL=true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -15,7 +15,7 @@ ls /var/lib/risotto/images_files/ | while read image; do
|
||||||
/usr/local/sbin/build_image "$image"
|
/usr/local/sbin/build_image "$image"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -f $IMAGE_BASE_RISOTTO_BASE_DIR*.build
|
#rm -f $IMAGE_BASE_RISOTTO_BASE_DIR*.build
|
||||||
|
|
||||||
MACHINES=""
|
MACHINES=""
|
||||||
for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
||||||
|
@ -23,11 +23,11 @@ for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
||||||
machine=${nspawn_file%.*}
|
machine=${nspawn_file%.*}
|
||||||
MACHINES="$MACHINES$machine "
|
MACHINES="$MACHINES$machine "
|
||||||
MACHINE_MACHINES_DIR="/var/lib/machines/$machine"
|
MACHINE_MACHINES_DIR="/var/lib/machines/$machine"
|
||||||
echo "Install machine $machine"
|
|
||||||
SHA_MACHINE="$RISOTTO_DIR/configurations/sha/$machine".sha
|
SHA_MACHINE="$RISOTTO_DIR/configurations/sha/$machine".sha
|
||||||
content=$(cat $SHA_MACHINE)
|
content=$(cat $SHA_MACHINE)
|
||||||
IMAGE_NAME_RISOTTO_IMAGE_NAME=${content##* }
|
IMAGE_NAME_RISOTTO_IMAGE_NAME=${content##* }
|
||||||
diff -q "$IMAGE_NAME_RISOTTO_IMAGE_NAME".sha "$SHA_MACHINE" || (
|
diff -q "$IMAGE_NAME_RISOTTO_IMAGE_NAME".sha "$SHA_MACHINE" > /dev/null || (
|
||||||
|
echo "Reinstall machine $machine"
|
||||||
machinectl stop $machine
|
machinectl stop $machine
|
||||||
while true; do
|
while true; do
|
||||||
machinectl status "$machine" > /dev/null 2>&1 || break
|
machinectl status "$machine" > /dev/null 2>&1 || break
|
||||||
|
@ -41,39 +41,4 @@ for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
machinectl start $MACHINES
|
machinectl start $MACHINES
|
||||||
STARTED=""
|
diagnose
|
||||||
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
|
|
||||||
|
|
||||||
exit $retcode
|
|
||||||
|
|
Loading…
Reference in a new issue