punktdateien/bin/updater

58 lines
1.4 KiB
Text
Raw Normal View History

2024-06-03 22:40:52 +02:00
#!/usr/bin/env bash
2024-06-02 17:15:38 +02:00
cd "${HOME}/.dotfiles" || (
2024-06-03 20:10:39 +02:00
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
exit 1
2024-06-02 17:15:38 +02:00
)
# 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
2024-06-03 20:10:39 +02:00
1)
# 0 - 2 -> 3
if [ -z "${UPDATER_VERSION}" ] || [ "${UPDATER_VERSION}" -lt "3" ]; then
echo ":: S1 | Updating to UPDATER_VERSION 3"
./uninstall.sh --remove-legacy-paths
fi
# 3 -> 4
if [ "${UPDATER_VERSION}" -lt "4" ]; then
echo ":: S1 | Updating to UPDATER_VERSION 4"
./uninstall.sh --remove-unshared-bashrcd
fi
echo ":: S1 | Uninstalling"
./uninstall.sh
echo ":: S1 | Installing"
./install.sh
# Remove legacy updater version file
[[ -f "${HOME}/.config/.jstm_dotfiles_updater" ]] && rm -rf "${HOME}/.config/.jstm_dotfiles_updater"
echo ":: S1 | Update complete."
echo " Make sure to execute \"dotfiles-install-software\""
echo " to install/update required software."
echo " Append \"--gui\" to install required GUI stuff."
;;
*)
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 | Uninstalling"
./uninstall.sh
echo ":: S0 | Pulling updates"
git pull
exec env STAGE=1 UPDATER_VERSION=${LOCAL_UPDATER_VERSION} "${HOME}/.dotfiles/bin/updater"
;;
2024-06-02 17:15:38 +02:00
esac