mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-08-08 21:59:13 +02:00
HortusFox: start applying db migrations (#16324)
This commit is contained in:
+36
-9
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||||
# Copyright (c) 2021-2026 community-scripts ORG
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
# Author: MickLesk (CanbiZ)
|
# Author: MickLesk (CanbiZ) | Co-Author: Tom Frenzel (tomfrenzel)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://github.com/danielbrendel/hortusfox-web
|
# Source: https://github.com/danielbrendel/hortusfox-web
|
||||||
|
|
||||||
@@ -34,29 +34,56 @@ function update_script() {
|
|||||||
systemctl stop apache2
|
systemctl stop apache2
|
||||||
msg_ok "Stopped Service"
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
msg_info "Backing up current HortusFox installation"
|
cd /opt/hortusfox
|
||||||
cd /opt
|
if [[ ! -s app/migrations/migrations.list ]]; then
|
||||||
mv /opt/hortusfox/ /opt/hortusfox-backup
|
msg_info "Rebuilding HortusFox migration history"
|
||||||
msg_ok "Backed up current HortusFox installation"
|
local database_tables
|
||||||
|
database_tables="$(mariadb -u root -D hortusfox -NBe "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE();")"
|
||||||
|
: >app/migrations/migrations.list
|
||||||
|
local migration migration_file table_name
|
||||||
|
for migration in app/migrations/*.php; do
|
||||||
|
migration_file="${migration##*/}"
|
||||||
|
table_name="${migration_file%.php}"
|
||||||
|
if [[ "$migration_file" == "VersionModel.php" ]] || grep -Fxq "$table_name" <<<"$database_tables"; then
|
||||||
|
php -r 'echo hash("sha512", $argv[1]), PHP_EOL;' -- "$migration_file" >>app/migrations/migrations.list
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
msg_ok "Rebuilt HortusFox migration history"
|
||||||
|
fi
|
||||||
|
if [[ ! -f app/migrations/verhist.json && -f ~/.hortusfox ]]; then
|
||||||
|
printf '["%s"]\n' "$(<~/.hortusfox)" >app/migrations/verhist.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
create_backup \
|
||||||
|
/opt/hortusfox/.env \
|
||||||
|
/opt/hortusfox/app/migrations/migrations.list \
|
||||||
|
/opt/hortusfox/app/migrations/verhist.json \
|
||||||
|
/opt/hortusfox/public/img \
|
||||||
|
/opt/hortusfox/public/attachments \
|
||||||
|
/opt/hortusfox/public/backup \
|
||||||
|
/opt/hortusfox/public/exports \
|
||||||
|
/opt/hortusfox/public/snd \
|
||||||
|
/opt/hortusfox/public/themes
|
||||||
|
|
||||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hortusfox" "danielbrendel/hortusfox-web" "tarball"
|
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hortusfox" "danielbrendel/hortusfox-web" "tarball"
|
||||||
|
restore_backup
|
||||||
|
|
||||||
msg_info "Updating HortusFox"
|
msg_info "Updating HortusFox"
|
||||||
cd /opt/hortusfox
|
cd /opt/hortusfox
|
||||||
cp /opt/hortusfox-backup/.env /opt/hortusfox/.env
|
|
||||||
cp -a /opt/hortusfox-backup/public/img/. /opt/hortusfox/public/img/
|
|
||||||
export COMPOSER_ALLOW_SUPERUSER=1
|
export COMPOSER_ALLOW_SUPERUSER=1
|
||||||
$STD composer install --no-dev --optimize-autoloader
|
$STD composer install --no-dev --optimize-autoloader
|
||||||
|
$STD php asatru migrate:list
|
||||||
$STD php asatru migrate:upgrade
|
$STD php asatru migrate:upgrade
|
||||||
$STD php asatru plants:attributes
|
|
||||||
$STD php asatru calendar:classes
|
$STD php asatru calendar:classes
|
||||||
|
$STD php asatru plants:attributes
|
||||||
|
$STD php asatru aquashell:config
|
||||||
chown -R www-data:www-data /opt/hortusfox
|
chown -R www-data:www-data /opt/hortusfox
|
||||||
rm -r /opt/hortusfox-backup
|
|
||||||
msg_ok "Updated HortusFox"
|
msg_ok "Updated HortusFox"
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
systemctl start apache2
|
systemctl start apache2
|
||||||
msg_ok "Started Service"
|
msg_ok "Started Service"
|
||||||
|
|
||||||
msg_ok "Updated successfully!"
|
msg_ok "Updated successfully!"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copyright (c) 2021-2026 community-scripts ORG
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
# Author: MickLesk (CanbiZ)
|
# Author: MickLesk (CanbiZ) | Co-Author: Tom Frenzel (tomfrenzel)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://github.com/danielbrendel/hortusfox-web
|
# Source: https://github.com/danielbrendel/hortusfox-web
|
||||||
|
|
||||||
@@ -36,12 +36,15 @@ msg_ok "Composer dependencies installed"
|
|||||||
|
|
||||||
msg_info "Running DB migration"
|
msg_info "Running DB migration"
|
||||||
$STD php asatru migrate:fresh
|
$STD php asatru migrate:fresh
|
||||||
|
HORTUSFOX_VERSION="$(<~/.hortusfox)"
|
||||||
|
printf '["%s"]\n' "$HORTUSFOX_VERSION" >/opt/hortusfox/app/migrations/verhist.json
|
||||||
msg_ok "Migration finished"
|
msg_ok "Migration finished"
|
||||||
|
|
||||||
msg_info "Setting up HortusFox"
|
msg_info "Setting up HortusFox"
|
||||||
$STD mariadb -u root -D $MARIADB_DB_NAME -e "INSERT IGNORE INTO AppModel (workspace, language, created_at) VALUES ('Default Workspace', 'en', NOW());"
|
$STD mariadb -u root -D $MARIADB_DB_NAME -e "INSERT IGNORE INTO AppModel (workspace, language, created_at) VALUES ('Default Workspace', 'en', NOW());"
|
||||||
$STD php asatru plants:attributes
|
|
||||||
$STD php asatru calendar:classes
|
$STD php asatru calendar:classes
|
||||||
|
$STD php asatru plants:attributes
|
||||||
|
$STD php asatru aquashell:config
|
||||||
ADMIN_EMAIL="admin@example.com"
|
ADMIN_EMAIL="admin@example.com"
|
||||||
ADMIN_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)"
|
ADMIN_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)"
|
||||||
ADMIN_HASH=$(php -r "echo password_hash('$ADMIN_PASS', PASSWORD_BCRYPT);")
|
ADMIN_HASH=$(php -r "echo password_hash('$ADMIN_PASS', PASSWORD_BCRYPT);")
|
||||||
|
|||||||
Reference in New Issue
Block a user