punktdateien/bin/updater

47 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
cd "${HOME}/.dotfiles" || (
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
exit 1
)
# Define updater version
UPDATER_VERSION=3
case "${STAGE}" in
1)
echo ":: 1 | Unlinking files"
./uninstall.sh
[[ -z "${UPDATER_VERSION}" ]] || [[ ! "${UPDATER_VERSION}" -gt "2" ]] &&
./uninstall.sh --remove-legacy-paths
echo ":: 1 | Linking files"
./install.sh
# Remove legacy updater version file
rm -rf "$HOME/.config/.jstm_dotfiles_updater"
echo ":: 1 | 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 | Unlinking files"
./uninstall.sh
echo ":: S0 | Pulling updates"
git pull
exec env STAGE=1 UPDATER_VERSION=${UPDATER_VERSION} "$HOME/.dotfiles/bin/updater"
;;
esac