2017-04-01 18:16:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-03 19:21:30 +02:00
|
|
|
#=================================================
|
2019-03-03 18:04:55 +01:00
|
|
|
# GENERIC START
|
2017-04-03 19:21:30 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
source _common.sh
|
2017-04-03 19:21:30 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2020-04-20 04:16:40 +02:00
|
|
|
# CHECK VERSION
|
2017-04-03 19:21:30 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="$install_dir/log/production.log"
|
2022-01-27 02:40:24 +01:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
if [ -z "${max_file_size:-}" ]; then
|
2019-03-03 18:04:55 +01:00
|
|
|
max_file_size=100 # 100 Mo
|
2020-05-26 01:58:07 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size
|
2019-03-03 18:04:55 +01:00
|
|
|
fi
|
|
|
|
|
2023-07-18 12:54:19 +02:00
|
|
|
if [ -z "${use_ldap:-}" ]; then
|
|
|
|
use_ldap=0
|
|
|
|
ynh_app_setting_set --app=$app --key=use_ldap --value=$use_ldap
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${secret:-}" ]; then
|
|
|
|
secret=$(ynh_string_random --length=24)
|
|
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
|
|
|
fi
|
2019-03-27 01:11:24 +01:00
|
|
|
#=================================================
|
2020-04-20 04:16:40 +02:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2019-03-27 01:11:24 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-18 17:06:24 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2019-03-27 01:11:24 +01:00
|
|
|
fi
|
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP LUFI
|
|
|
|
#=================================================
|
2021-05-08 23:38:59 +02:00
|
|
|
ynh_script_progression --message="Configuring Lufi..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2022-01-19 21:01:53 +01:00
|
|
|
ldap="#"
|
2022-01-19 20:47:13 +01:00
|
|
|
if [ $use_ldap -eq 1 ];
|
2019-03-03 18:04:55 +01:00
|
|
|
then
|
2022-01-19 21:01:53 +01:00
|
|
|
ldap=""
|
|
|
|
fi
|
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
ynh_add_config --template="../conf/lufi.conf" --destination="$install_dir/lufi.conf"
|
2019-03-03 18:04:55 +01:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
chmod 600 $install_dir/lufi.conf
|
|
|
|
chown $app:$app $install_dir/lufi.conf
|
2021-05-08 23:38:59 +02:00
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
# BUILD LUFI
|
2017-04-03 19:21:30 +02:00
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Building Lufi..."
|
2017-04-03 19:21:30 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
pushd $install_dir
|
2023-12-12 11:05:13 +01:00
|
|
|
# Patch cpanfile.snapshot to bump dependency
|
|
|
|
sed -i 's|Cpanel-JSON-XS-4.19|Cpanel-JSON-XS-4.37|' cpanfile.snapshot
|
|
|
|
sed -i 's|Cpanel::JSON::XS 4.19|Cpanel::JSON::XS 4.37|' cpanfile.snapshot
|
2021-05-08 23:38:59 +02:00
|
|
|
carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test
|
2019-03-03 18:04:55 +01:00
|
|
|
popd
|
2017-04-03 19:21:30 +02:00
|
|
|
|
2020-05-26 01:58:07 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP CRON
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Setuping cron..."
|
2020-05-26 01:58:07 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-05-26 01:58:07 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
|
|
chmod +x $install_dir/script/lufi
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
2017-04-03 19:21:30 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
yunohost service add $app --description="Lufi service" --log="$install_dir/log/production.log"
|
2017-04-03 19:21:30 +02:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2023-04-18 17:06:24 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/log/production.log" --line_match="Creating process id file"
|
2019-03-03 18:04:55 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-04-03 19:21:30 +02:00
|
|
|
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|