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

106 lines
3.5 KiB
Text
Raw Normal View History

2015-08-22 20:24:46 +02:00
#!/bin/bash
2018-05-01 12:25:53 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2015-08-22 20:24:46 +02:00
2018-05-01 12:25:53 +02:00
source _common.sh
source /usr/share/yunohost/helpers
2015-08-22 20:24:46 +02:00
2019-10-25 11:04:41 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
2018-05-01 12:25:53 +02:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
2019-10-25 11:04:41 +02:00
# STOP SYSTEMD SERVICE
2018-05-01 12:25:53 +02:00
#=================================================
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2018-05-01 12:25:53 +02:00
2021-03-22 10:00:33 +01:00
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
2015-08-22 20:24:46 +02:00
2018-05-01 12:25:53 +02:00
#=================================================
2019-10-25 11:04:41 +02:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2018-05-01 12:25:53 +02:00
#=================================================
2015-08-22 20:24:46 +02:00
2019-10-25 11:04:41 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=2
2020-05-27 17:03:30 +02:00
2019-10-25 11:04:41 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-03-14 16:44:09 +01:00
ynh_setup_source --dest_dir=$install_dir
2019-10-25 11:04:41 +02:00
fi
2018-05-01 12:25:53 +02:00
2023-03-14 16:44:09 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R $app:www-data $data_dir
2021-08-02 08:23:59 +02:00
2018-05-03 19:57:18 +02:00
#=================================================
2020-05-30 19:18:05 +02:00
# NGINX CONFIGURATION
2018-05-03 19:57:18 +02:00
#=================================================
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
2018-05-03 19:57:18 +02:00
2020-08-09 14:48:13 +02:00
# Create a dedicated NGINX config
2020-05-30 19:18:05 +02:00
ynh_add_nginx_config
2020-05-27 17:03:30 +02:00
#=================================================
2020-05-30 19:18:05 +02:00
# UPGRADE DEPENDENCIES
2020-05-27 17:03:30 +02:00
#=================================================
2023-03-14 16:44:09 +01:00
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5
2020-05-27 17:03:30 +02:00
# Install Nodejs
2020-05-29 22:51:48 +02:00
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
2020-05-27 17:03:30 +02:00
# Install Yarn
2023-03-14 16:44:09 +01:00
#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
2018-05-03 19:57:18 +02:00
2020-05-30 19:18:05 +02:00
#=================================================
# SPECIFIC UPGRADE
2018-05-01 22:09:53 +02:00
#=================================================
2019-10-25 11:04:41 +02:00
# UPGRADE THE LOUNGE
2018-05-01 22:09:53 +02:00
#=================================================
2019-10-25 11:04:41 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2023-03-14 16:44:09 +01:00
pushd $install_dir
2022-01-04 14:31:04 +01:00
ynh_use_nodejs
2022-01-04 11:14:08 +01:00
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
2022-01-04 14:31:04 +01:00
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production yarn build
2020-05-27 17:03:30 +02:00
popd
2019-10-25 11:04:41 +02:00
fi
2018-05-01 22:09:53 +02:00
2019-10-25 11:04:41 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
2018-05-01 22:09:53 +02:00
2022-03-27 10:59:38 +02:00
env_path="$PATH"
2020-05-27 17:03:30 +02:00
ynh_add_systemd_config
2018-05-01 12:25:53 +02:00
2019-10-25 11:04:41 +02:00
#=================================================
2020-05-30 19:18:05 +02:00
# GENERIC FINALIZATION
2018-05-01 12:25:53 +02:00
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2018-05-01 12:25:53 +02:00
2020-12-14 11:14:10 +01:00
yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$app.log"
2018-05-01 12:25:53 +02:00
2019-10-25 11:04:41 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2019-10-25 11:04:41 +02:00
2021-08-30 22:37:35 +02:00
ynh_systemd_action --service_name=$app --action=start --log_path=systemd
2019-10-25 11:04:41 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2018-05-01 12:25:53 +02:00
2021-11-23 08:28:18 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last