1
0
Fork 1
mirror of https://example.com synced 2024-11-22 16:36:39 +09:00
firefish/update.sh

73 lines
1.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -eu
source neko/update/utils
2023-07-22 20:25:52 +09:00
2023-09-21 07:58:12 +09:00
say "Start upgrading Firefish!"
# Pull changes
## git pull
OLD_COMMIT=$(git rev-parse --short HEAD)
say "Pulling changes from the remote repo..."
running "git checkout -- package.json packages/backend/assets"
git checkout -- package.json packages/backend/assets
running "git pull --ff --no-edit --autostash --strategy-option theirs"
git pull --ff --no-edit --autostash --strategy-option theirs
NEW_COMMIT=$(git rev-parse --short HEAD)
say "Pulled successfully!\n"
## check if the update script itself is updated
say "Checking if the update script itself has been modified by this update..."
2023-11-14 09:42:43 +09:00
if [ "$(git diff "${OLD_COMMIT}" "${NEW_COMMIT}" update.sh)" != "" ]; then
say "Oh meow, that seems to be the case."
say "I'm sorry to bother you, but please run this script again!"
exit 1
else
say "This script seems to be up-to-date!\n"
fi
## show messages
for message in neko/messages/*; do
file=$(basename -- "${message}")
if [ ! -f "neko/flags/${file}" ]; then
if [ $# != 1 ] || [ "$1" != "--skip-all-confirmations" ]; then
say "There is an important notice!"
cat "${message}"
say "Continue? (Are you ready for upgrading?)"
read -r -p "[y/N] > " 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}"
;;
*)
say "Okay, please run this script again when you're ready!"
exit 1
;;
esac
else
touch "neko/flags/${file}"
fi
fi
done
say "Do you use Docker?"
read -r -p "[y/N] > " yn
case "${yn}" in
[Yy]|[Yy][Ee][Ss])
2023-11-14 09:42:43 +09:00
./neko/update/docker.sh "$@"
;;
*)
2023-11-14 09:42:43 +09:00
./neko/update/native.sh "$@"
;;
esac
# Done
say "Enjoy your sabakan life~"