2014-10-20 12:55:53 -04:00
#!/bin/bash
2015-10-27 11:03:21 -04:00
2017-06-02 12:44:37 -04:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-06-05 07:06:35 -04:00
source _common.sh
2017-06-02 12:44:37 -04:00
source /usr/share/yunohost/helpers
2024-02-21 10:34:51 -05:00
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2024-11-15 18:35:15 -05:00
2024-06-20 17:49:43 -04:00
ynh_script_progression "Stopping $app's systemd service..."
2024-02-21 10:34:51 -05:00
2024-06-20 17:49:43 -04:00
ynh_systemctl --service="$app" --action="stop"
2024-02-21 10:34:51 -05:00
2017-06-02 12:44:37 -04:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2019-04-18 13:58:47 -04:00
2024-11-15 18:35:15 -05:00
ynh_script_progression "Upgrading source files..."
2020-05-30 08:59:12 -04:00
2024-11-15 18:35:15 -05:00
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="database uploads minio"
2020-05-30 08:59:12 -04:00
2024-11-15 18:35:15 -05:00
chown -R "$app:www-data" "$install_dir"
2021-03-17 11:32:11 -04:00
2017-06-02 12:44:37 -04:00
2024-02-21 10:34:51 -05:00
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
2024-11-15 18:35:15 -05:00
ynh_script_progression "Upgrading system configurations related to $app..."
2024-02-21 10:34:51 -05:00
2024-06-20 17:49:43 -04:00
ynh_config_add_nginx
2024-02-21 10:34:51 -05:00
2024-11-15 20:47:00 -05:00
ynh_config_add_systemd --service= "${app}-backend" --template="backend.service"
2024-02-21 10:34:51 -05:00
2024-11-15 20:47:00 -05:00
ynh_config_add_systemd --service= "${app}-frontend" --template="frontend.service"
2024-11-15 20:25:22 -05:00
2024-11-15 20:33:12 -05:00
yunohost service add "${app}-backend" --description="a beautiful and performant vault to save all your files in the cloud" --log="/var/log/$app/$app.log"
2024-11-15 20:25:22 -05:00
2024-11-15 20:33:12 -05:00
yunohost service add "${app}-frontend" --description="a beautiful and performant vault to save all your files in the cloud" --log="/var/log/$app/$app.log"
2024-11-15 18:35:15 -05:00
ynh_script_progression "Installing $app..."
2024-02-21 10:34:51 -05:00
2024-11-15 18:35:15 -05:00
pushd $install_dir
ynh_hide_warnings ynh_exec_as_app yarn install
ynh_hide_warnings ynh_exec_as_app yarn workspace @chibisafe/backend generate
ynh_hide_warnings ynh_exec_as_app yarn workspace @chibisafe/backend migrate
ynh_hide_warnings ynh_exec_as_app yarn build
2024-11-17 13:52:26 -05:00
ynh_hide_warnings ynh_exec_as_app bash -c "echo "BASE_API_URL=http://127.0.0.1:8000" >> ./packages/next/.env"
2024-11-15 18:35:15 -05:00
popd
2024-02-21 10:34:51 -05:00
2019-05-02 14:44:22 -04:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-06-20 17:49:43 -04:00
ynh_script_progression "Starting $app's systemd service..."
2019-05-02 14:44:22 -04:00
2024-11-15 20:33:12 -05:00
ynh_systemctl --service="${app}-backend" --action="start"
2024-11-15 20:25:22 -05:00
2024-11-15 20:33:12 -05:00
ynh_systemctl --service="${app}-frontend" --action="start"
2019-05-02 14:44:22 -04:00
2019-02-10 09:02:38 -05:00
#=================================================
# END OF SCRIPT
#=================================================
2024-06-20 17:49:43 -04:00
ynh_script_progression "Upgrade of $app completed"