Skip to content

Commit f6388d2

Browse files
committed
Add upgrade task
1 parent 600771d commit f6388d2

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.crt
33
*.cer
44
*.key
5-
nginx.conf
5+
nginx.conf
6+
VERSION

Taskfile.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@ tasks:
1111
desc: Install the project
1212
cmds:
1313
- task _show_preinstall_notes
14+
- task _version_file
1415
- task _prepare_nginx_conf # Add this step to prepare nginx.conf
1516
- echo "Installing"
1617
- docker compose --env-file .env -f compose.yml pull
1718
- docker compose --env-file .env -f compose.yml up --force-recreate --detach --remove-orphans
1819
- task _show_notes
1920

21+
upgrade:
22+
desc: Upgrades the admin site to a newer version
23+
cmds:
24+
- task _show_upgrade_notes
25+
- task _version_file
26+
- task stop
27+
- docker compose --env-file .env -f compose.yml down
28+
- docker compose --env-file .env -f compose.yml pull
29+
- docker compose --env-file .env -f compose.yml up --force-recreate --detach --remove-orphans
30+
- task _show_notes
31+
2032
reinstall:
2133
desc: Reinstall from scratch. Removes the database, all containers, and volumes.
2234
deps:
@@ -30,6 +42,11 @@ tasks:
3042
- stop
3143
cmds:
3244
- docker compose --env-file .env -f compose.yml down -v
45+
- |
46+
if [ -f VERSION ]; then
47+
rm VERSION
48+
echo "VERSION file deleted."
49+
fi
3350
3451
up:
3552
desc: Take the environment up without altering the existing state of the containers
@@ -41,6 +58,28 @@ tasks:
4158
cmds:
4259
- docker compose --env-file .env -f compose.yml stop
4360

61+
_show_upgrade_notes:
62+
cmds:
63+
- |
64+
VERSION=$(grep ^VERSION= .env | cut -d '=' -f 2)
65+
if [ -f VERSION ] && [ "$(cat VERSION)" = "$VERSION" ]; then
66+
echo ""
67+
echo "===================================================="
68+
echo "It looks like version $VERSION is already installed."
69+
echo "To set the version you want to upgrade to, edit the VERSION value in .env."
70+
echo "===================================================="
71+
exit 0
72+
fi
73+
echo ""
74+
echo "===================================================="
75+
echo "You are about to upgrade to version $VERSION."
76+
echo "===================================================="
77+
echo "Are you sure you want to continue? (yes/no)"
78+
read answer && case $answer in
79+
[Yy][Ee][Ss]) ;;
80+
*) echo "Upgrade canceled."; exit 1;;
81+
esac
82+
4483
_show_preinstall_notes:
4584
cmds:
4685
- echo ""
@@ -49,7 +88,7 @@ tasks:
4988
- echo "===================================================="
5089
- echo ""
5190
- echo "To proceed with the installation, ensure the following steps are completed:"
52-
- echo "1. Update '.env'"
91+
- echo "1. Update '.env'. Change the passwords and secret keys."
5392
- echo "2. Place your SSL certificate files ('nginx.crt' and 'nginx.key') in the 'ssl' directory."
5493
- echo ""
5594
- echo "Have you completed the above pre-installation steps? (yes/no)"
@@ -66,13 +105,28 @@ tasks:
66105
DOMAIN=$(grep ^DOMAIN= .env | cut -d '=' -f 2)
67106
sed -i "s/\${DOMAIN}/$DOMAIN/g" nginx.conf
68107
108+
_version_file:
109+
desc: Write the value of VERSION from .env to a file called VERSION
110+
cmds:
111+
- |
112+
VERSION=$(grep ^VERSION= .env | cut -d '=' -f 2)
113+
echo $VERSION > VERSION
114+
echo "VERSION file updated with value: $VERSION"
115+
69116
_show_notes:
70117
cmds:
71118
- |
72119
DOMAIN=$(grep ^DOMAIN= .env | cut -d '=' -f 2)
120+
ADMIN_USERNAME=$(grep ^ADMIN_USERNAME= .env | cut -d '=' -f 2)
121+
ADMIN_PASSWORD=$(grep ^ADMIN_PASSWORD= .env | cut -d '=' -f 2)
73122
echo ""
74123
echo "===================================================="
75-
echo "OS2Borgerpc Admin is now is available via the URLs below"
124+
echo "OS2Borgerpc Admin is now available via the URLs below"
76125
echo "===================================================="
77126
echo "Admin: https://$DOMAIN"
127+
echo "Django Backend: https://$DOMAIN/admin"
128+
echo "===================================================="
129+
echo "You can log in with the following credentials:"
130+
echo "Username: $ADMIN_USERNAME"
131+
echo "Password: $ADMIN_PASSWORD"
78132
echo "===================================================="

0 commit comments

Comments
 (0)