1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lufi_ynh.git synced 2024-09-03 19:36:28 +02:00
lufi_ynh/scripts/upgrade

122 lines
3.8 KiB
Text
Raw Permalink Normal View History

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
#=================================================
# CHECK VERSION
2017-04-03 19:21:30 +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..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="$install_dir/log/production.log"
2022-01-27 02:40:24 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2020-05-30 16:34:01 +02:00
ynh_script_progression --message="Ensuring downward compatibility..."
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
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
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
2019-03-27 01:11:24 +01:00
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2020-05-30 16:34:01 +02:00
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
2019-03-27 01:11:24 +01:00
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-01-27 02:40:24 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SETUP LUFI
#=================================================
ynh_script_progression --message="Configuring Lufi..."
ldap="#"
if [ $use_ldap -eq 1 ];
2019-03-03 18:04:55 +01:00
then
ldap=""
fi
ynh_add_config --template="../conf/lufi.conf" --destination="$install_dir/lufi.conf"
2019-03-03 18:04:55 +01:00
chmod 600 $install_dir/lufi.conf
chown $app:$app $install_dir/lufi.conf
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
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
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
# Create a dedicated NGINX config
ynh_add_nginx_config
2020-05-26 01:58:07 +02:00
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chmod +x $install_dir/script/lufi
2022-01-27 02:40:24 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
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
yunohost service add $app --description="Lufi service" --log="$install_dir/log/production.log"
2017-04-03 19:21:30 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2020-05-30 16:34:01 +02:00
ynh_script_progression --message="Starting a systemd service..."
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"