1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/reiverr_ynh.git synced 2024-09-03 20:16:14 +02:00
reiverr_ynh/scripts/upgrade

98 lines
4.2 KiB
Bash
Executable file

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression "Upgrading dependencies..."
ynh_nodejs_install
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service=$app --action="stop"
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Upgrading system configurations related to $app..."
# This should be a literal copypaste of what happened in the install's "System configuration" section
ynh_config_add_nginx
#=================================================
# BUILD APP
#=================================================
ynh_script_progression "Building __APP__..."
pushd $install_dir
npm install vite
ynh_script_progression "npm install... This can be very long, be patient !"
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --network-timeout=100000
ynh_script_progression "Building Yarn dev dependencies... This can be very long, be patient !"
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn run build
ynh_script_progression "Cleaning cache... "
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn cache clean 2>&1
popd
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config
ynh_config_add_systemd
#=================================================
# LOGROTATE
#=================================================
ynh_script_progression "Configuring logrotate to manage application logfiles"
# Use logrotate to manage application logfile(s)
ynh_config_add_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service=$app --action="start" --wait_until=""
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Upgrade of $app completed"