#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # 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" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." if [ -z "${max_file_size:-}" ]; then max_file_size=100 # 100 Mo ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size 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 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then 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" fi chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC UPGRADE #================================================= # SETUP LUFI #================================================= ynh_script_progression --message="Configuring Lufi..." ldap="#" if [ $use_ldap -eq 1 ]; then ldap="" fi ynh_add_config --template="../conf/lufi.conf" --destination="$install_dir/lufi.conf" chmod 600 $install_dir/lufi.conf chown $app:$app $install_dir/lufi.conf #================================================= # BUILD LUFI #================================================= ynh_script_progression --message="Building Lufi..." pushd $install_dir # 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 popd #================================================= # SETUP CRON #================================================= ynh_script_progression --message="Setuping cron..." # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" chmod +x $install_dir/script/lufi # Create a dedicated systemd config ynh_add_systemd_config # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append yunohost service add $app --description="Lufi service" --log="$install_dir/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= 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" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed"