firefish/update.sh

99 lines
2.3 KiB
Bash
Raw Normal View History

#!/bin/sh
set -eu
. neko/update/utils
2023-07-22 20:25:52 +09:00
2023-11-18 16:37:55 +09:00
say 'Start upgrading Firefish!'
br
# Apply patches
run './neko/update/patch.sh'
br
# Pull changes
## git pull
2024-01-02 06:11:33 +09:00
OLD_COMMIT=$(git rev-parse --short HEAD)
2023-11-18 16:37:55 +09:00
say 'Pulling changes from the remote repo...'
run 'git checkout -- package.json packages/backend/assets'
run 'git pull --ff --no-edit --autostash --strategy-option theirs'
2024-01-02 06:11:33 +09:00
NEW_COMMIT=$(git rev-parse --short HEAD)
if [ "${OLD_COMMIT}" != "${NEW_COMMIT}" ]; then
run "git log --no-merges --reverse --format='%s (by %an)' ${OLD_COMMIT}..${NEW_COMMIT} > neko/volume/CHANGELOG"
2024-01-02 06:11:33 +09:00
fi
2023-11-21 21:33:56 +09:00
2023-11-18 16:37:55 +09:00
say 'Pulled successfully!'
br
## check if the update script itself is updated
2023-11-18 16:37:55 +09:00
say 'Checking if the update script itself has been modified by this update...'
if [ "$(git diff "${OLD_COMMIT}" "${NEW_COMMIT}" update.sh neko/update)" != '' ]; then
say 'Oh meow, that seems to be the case.'
sadsay "I'm sorry to bother you, but please run this script again!"
exit 1
else
2023-11-18 16:37:55 +09:00
say 'This script seems to be up-to-date!'
br
fi
## show messages
for message in neko/messages/*; do
file=$(basename -- "${message}")
2023-12-29 18:35:28 +09:00
case "${file}" in
*'.resolved') ;;
*)
if [ ! -f "neko/flags/${file}" ]; then
if [ "$#" != '1' ] || [ "$1" != '--skip-all-confirmations' ]; then
say 'There is an important notice!'
cat "${message}"
2023-12-29 18:35:28 +09:00
say 'Continue? (Are you ready for upgrading?)'
printf '[y/N] > '
read -r yn
case "${yn}" in
[Yy]|[Yy][Ee][Ss])
touch "neko/flags/${file}"
say "Let's go!"
say "To read the message again, run: \$ cat ${message}"
br
;;
*)
say "Okay, please run this script again when you're ready!"
exit 1
;;
esac
else
touch "neko/flags/${file}"
2023-12-29 18:35:28 +09:00
fi
fi
;;
esac
done
2024-01-05 08:03:42 +09:00
say 'Do you use Docker or Podman?'
printf 'd: Docker, p: Podman, n: No [d/p/N] > '
read -r resp
case "${resp}" in
2024-01-05 08:03:42 +09:00
[Dd])
./neko/update/docker.sh 'docker' "$@"
;;
[Pp])
./neko/update/docker.sh 'podman' "$@"
;;
[Yy]|[Yy][Ee][Ss])
sadsay "Watch out! ${resp} is not a valid answer." >&2
exit 1
;;
*)
2023-11-14 09:42:43 +09:00
./neko/update/native.sh "$@"
;;
esac
# Done
2023-11-18 16:37:55 +09:00
say 'Enjoy your sabakan life~'