punktdateien/bin/updater

58 lines
1.4 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-03 01:55:54 +02:00
LOCAL_UPDATER_VERSION=4
2024-06-02 17:15:38 +02:00
case "${STAGE}" in
1)
2024-06-03 01:55:54 +02:00
# 0 - 2 -> 3
if [ -z "${UPDATER_VERSION}" ] || [ "${UPDATER_VERSION}" -lt "3" ]; then
2024-06-03 01:55:54 +02:00
echo ":: S1 | Updating to UPDATER_VERSION 3"
./uninstall.sh --remove-legacy-paths
fi
2024-06-03 01:55:54 +02:00
# 3 -> 4
2024-06-03 01:56:38 +02:00
if [ "${UPDATER_VERSION}" -lt "4" ]; then
2024-06-03 01:55:54 +02:00
echo ":: S1 | Updating to UPDATER_VERSION 4"
./uninstall.sh --remove-unshared-bashrcd
fi
echo ":: S1 | Uninstalling"
./uninstall.sh
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
2024-06-02 21:37:16 +02:00
echo ":: S0 | Uninstalling"
2024-06-02 17:15:38 +02:00
./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