Skip to content
Snippets Groups Projects

fix: restore foris config from snapshots

Merged Karel Koci requested to merge hotfix/fix-config-foris-restore into master
1 unresolved thread
Files
2
+ 23
0
#!/bin/sh
set -eu
config="/etc/config/foris"
if [ ! -s "$config" ]; then
schnapps list | awk 'NR > 2 { print $1 }' | sort -rn \
| while read -r snapshot; do
schnapps mount "$snapshot" >/dev/null
mntp="/mnt/snapshot-@$snapshot"
if [ -s "${mntp}${config}" ]; then
cp -a "${mntp}${config}" "$config"
umount "$mntp"
exit 0
fi
umount "$mntp"
done
fi
if [ ! -s "$config" ]; then
echo "Failed to locate latest non-empty version of /etc/config/foris in snapshots! Config is empty and wizard has to be performed again." >&2
exit 1
fi