punktdateien/bin/updater

53 lines
1.3 KiB
Text
Raw Normal View History

2023-12-13 20:03:46 +01:00
#!/bin/bash
2024-06-02 17:15:38 +02:00
cd "${HOME}/.dotfiles" || (
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
exit 1
)
# Define updater version
2024-06-02 21:30:34 +02:00
LOCAL_UPDATER_VERSION=3
2024-06-02 17:15:38 +02:00
case "${STAGE}" in
1)
if [ -z "${UPDATER_VERSION}" ] || [ "${UPDATER_VERSION}" -lt "3" ]; then
echo ":: S1 | Unlinking legacy file paths"
./uninstall.sh --remove-legacy-paths
2024-06-02 21:35:19 +02:00
echo ":: S1 | Uninstalling & unlinking (safety measure)"
./uninstall.sh
else
2024-06-02 21:35:19 +02:00
echo ":: S1 | Uninstalling"
./uninstall.sh
fi
2024-06-02 21:35:19 +02:00
echo ":: S1 | Installing"
2024-06-02 17:15:38 +02:00
./install.sh
# Remove legacy updater version file
2024-06-02 21:35:19 +02:00
[[ -f "${HOME}/.config/.jstm_dotfiles_updater" ]] && rm -rf "${HOME}/.config/.jstm_dotfiles_updater"
2024-06-02 17:15:38 +02:00
2024-06-02 21:22:21 +02:00
echo ":: S1 | Update complete."
2024-06-02 21:36:57 +02:00
echo " Make sure to execute \"dotfiles-install-software\""
echo " to install/update required software."
echo " Append \"--gui\" to install required GUI stuff."
2024-06-02 17:15:38 +02:00
;;
*)
echo ":: Checking for updates"
if [ ! "${1}" == "--force" ] && [ "$(env SCRIPTED=true dotfiles-updatechecker)" == "" ]; then
echo ":: No update is available. Use \"--force\" to update anyway."
exit 1
fi
echo ":: S0 | Unlinking files"
./uninstall.sh
echo ":: S0 | Pulling updates"
git pull
2024-06-02 21:35:19 +02:00
exec env STAGE=1 UPDATER_VERSION=${LOCAL_UPDATER_VERSION} "${HOME}/.dotfiles/bin/updater"
2024-06-02 17:15:38 +02:00
;;
esac