41 lines
705 B
Bash
Executable file
41 lines
705 B
Bash
Executable file
#!/bin/bash
|
|
|
|
restoreDir="/etc/restore"
|
|
|
|
|
|
hook_check() {
|
|
if [[ -d "$restoreDir" ]]; then
|
|
rm -rf "$restoreDir" || exit 1
|
|
fi
|
|
}
|
|
|
|
hook_pre() {
|
|
mkdir -p "$restoreDir" || exit 1
|
|
pushd "$restoreDir" || exit 2
|
|
|
|
rpm -qa | sort > Package.versions.list
|
|
rpm -qa --queryformat '%{NAME}\n' | sort > Package.list
|
|
|
|
cat > restore.sh <<EOF
|
|
#!/bin/bash
|
|
|
|
if [[ ! -f "Package.list" ]]; then
|
|
echo "This needs to be run inside the restore directory."
|
|
exit 1
|
|
fi
|
|
|
|
cat Package.list | xargs zypper install
|
|
EOF
|
|
|
|
popd || exit 2
|
|
}
|
|
|
|
hook_post() {
|
|
rm -rf "$restoreDir"
|
|
}
|
|
|
|
case "$1" in
|
|
before_check) hook_check;;
|
|
before_backup) hook_pre;;
|
|
after_backup) hook_post;;
|
|
esac
|