|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
3 | 3 | # Copyright (c) 2021-2026 community-scripts ORG |
4 | | -# Author: MickLesk (CanbiZ) |
| 4 | +# Author: MickLesk (CanbiZ) | Co-Author: Tom Frenzel (tomfrenzel) |
5 | 5 | # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
6 | 6 | # Source: https://github.com/danielbrendel/hortusfox-web |
7 | 7 |
|
@@ -34,29 +34,56 @@ function update_script() { |
34 | 34 | systemctl stop apache2 |
35 | 35 | msg_ok "Stopped Service" |
36 | 36 |
|
37 | | - msg_info "Backing up current HortusFox installation" |
38 | | - cd /opt |
39 | | - mv /opt/hortusfox/ /opt/hortusfox-backup |
40 | | - msg_ok "Backed up current HortusFox installation" |
| 37 | + cd /opt/hortusfox |
| 38 | + if [[ ! -s app/migrations/migrations.list ]]; then |
| 39 | + msg_info "Rebuilding HortusFox migration history" |
| 40 | + local database_tables |
| 41 | + database_tables="$(mariadb -u root -D hortusfox -NBe "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE();")" |
| 42 | + : >app/migrations/migrations.list |
| 43 | + local migration migration_file table_name |
| 44 | + for migration in app/migrations/*.php; do |
| 45 | + migration_file="${migration##*/}" |
| 46 | + table_name="${migration_file%.php}" |
| 47 | + if [[ "$migration_file" == "VersionModel.php" ]] || grep -Fxq "$table_name" <<<"$database_tables"; then |
| 48 | + php -r 'echo hash("sha512", $argv[1]), PHP_EOL;' -- "$migration_file" >>app/migrations/migrations.list |
| 49 | + fi |
| 50 | + done |
| 51 | + msg_ok "Rebuilt HortusFox migration history" |
| 52 | + fi |
| 53 | + if [[ ! -f app/migrations/verhist.json && -f ~/.hortusfox ]]; then |
| 54 | + printf '["%s"]\n' "$(<~/.hortusfox)" >app/migrations/verhist.json |
| 55 | + fi |
| 56 | + |
| 57 | + create_backup \ |
| 58 | + /opt/hortusfox/.env \ |
| 59 | + /opt/hortusfox/app/migrations/migrations.list \ |
| 60 | + /opt/hortusfox/app/migrations/verhist.json \ |
| 61 | + /opt/hortusfox/public/img \ |
| 62 | + /opt/hortusfox/public/attachments \ |
| 63 | + /opt/hortusfox/public/backup \ |
| 64 | + /opt/hortusfox/public/exports \ |
| 65 | + /opt/hortusfox/public/snd \ |
| 66 | + /opt/hortusfox/public/themes |
41 | 67 |
|
42 | 68 | CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hortusfox" "danielbrendel/hortusfox-web" "tarball" |
| 69 | + restore_backup |
43 | 70 |
|
44 | 71 | msg_info "Updating HortusFox" |
45 | 72 | cd /opt/hortusfox |
46 | | - cp /opt/hortusfox-backup/.env /opt/hortusfox/.env |
47 | | - cp -a /opt/hortusfox-backup/public/img/. /opt/hortusfox/public/img/ |
48 | 73 | export COMPOSER_ALLOW_SUPERUSER=1 |
49 | 74 | $STD composer install --no-dev --optimize-autoloader |
| 75 | + $STD php asatru migrate:list |
50 | 76 | $STD php asatru migrate:upgrade |
51 | | - $STD php asatru plants:attributes |
52 | 77 | $STD php asatru calendar:classes |
| 78 | + $STD php asatru plants:attributes |
| 79 | + $STD php asatru aquashell:config |
53 | 80 | chown -R www-data:www-data /opt/hortusfox |
54 | | - rm -r /opt/hortusfox-backup |
55 | 81 | msg_ok "Updated HortusFox" |
56 | 82 |
|
57 | 83 | msg_info "Starting Service" |
58 | 84 | systemctl start apache2 |
59 | 85 | msg_ok "Started Service" |
| 86 | + |
60 | 87 | msg_ok "Updated successfully!" |
61 | 88 | fi |
62 | 89 | exit |
|
0 commit comments