2023-12-03 02:09:46 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
restoreDir="/etc/restore"
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_before() {
|
2023-12-03 02:09:46 -05:00
|
|
|
mkdir -p "$restoreDir" || exit 1
|
|
|
|
pushd "$restoreDir" || exit 2
|
|
|
|
|
|
|
|
which flatpak || exit 0
|
|
|
|
|
|
|
|
flatpak list --columns=application --app > flatpaks.lst
|
|
|
|
|
|
|
|
cat > restore-flatpak.sh <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ ! -f "flatpaks.lst" ]]; then
|
|
|
|
echo "This needs to be run inside the restore directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-27 22:29:39 -04:00
|
|
|
# Removal uninstalled packages:
|
|
|
|
echo
|
|
|
|
echo "=============================="
|
|
|
|
echo "INSTALL FLATPAK PACKAGES"
|
|
|
|
echo "=============================="
|
|
|
|
echo
|
|
|
|
echo "The following flatpak packages are listed to be installed:"
|
|
|
|
cat flatpaks.lst
|
|
|
|
echo
|
|
|
|
read -p "Do you want to proceed? [Y/n] " -n 1 -sr promptFlatpak
|
|
|
|
if [[ "\$promptFlatpak" =~ ^[Yy]$ ]]; then
|
|
|
|
# Do the thing
|
|
|
|
echo "Yes"
|
|
|
|
|
|
|
|
read -p "Do you want to omit any packages or cancel? [N, y, c] " -n 1 -sr promptFlatpakVerify
|
|
|
|
if [[ "\$promptFlatpakVerify" =~ ^[Yy]$ ]]; then
|
|
|
|
echo
|
|
|
|
read -p "What do you want to omit, seperated by spaces? " -r promptFlatpakOmit
|
|
|
|
omitfp="\$(echo "\$promptFlatpakOmit" | tr ' ' '|')"
|
|
|
|
echo
|
|
|
|
elif [[ "\$promptFlatpakVerify" =~ ^[Cc]$ ]]; then
|
|
|
|
echo -e "Cancelled\n"
|
|
|
|
omitfp="CANCEL"
|
|
|
|
else
|
|
|
|
omitfp=""
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "\$omitfp" != "CANCEL" ]]; then
|
|
|
|
egrep -v "(\$omitfp)" flatpaks.lst | xargs flatpak install -y
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -e "Cancelled\n"
|
|
|
|
fi
|
2023-12-03 02:09:46 -05:00
|
|
|
EOF
|
2024-06-27 22:29:39 -04:00
|
|
|
#which flatpak || exit 0
|
|
|
|
#xargs flatpak install -y < flatpaks.lst
|
|
|
|
#EOF
|
2024-06-27 22:34:14 -04:00
|
|
|
chmod ug+rx restore-flatpak.sh
|
2023-12-03 02:09:46 -05:00
|
|
|
popd || exit 2
|
|
|
|
}
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_after() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_fail() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_final() {
|
2023-12-03 02:09:46 -05:00
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2023-12-03 06:44:35 -05:00
|
|
|
before) hook_before || exit $?;;
|
|
|
|
after) hook_after || exit $?;;
|
|
|
|
fail) hook_fail || exit $?;;
|
|
|
|
finally) hook_final || exit $?;;
|
2023-12-03 02:09:46 -05:00
|
|
|
esac
|