#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Cleanup legacy install dir if [ ! -d "$install_dir/sources" ]; then mkdir "$install_dir/sources" find . -mindepth 1 -maxdepth 1 ! -name "sources" -exec mv -t "$install_dir/sources" "{}" + mv "$install_dir/sources/config" "$install_dir" fi #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading NodeJS..." --weight=5 ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" mkdir -p "$install_dir/sources/dist" chown -R "$app:$app" "$install_dir/sources/dist" "$install_dir/sources/global" "$install_dir/config" #================================================= # SPECIFIC UPGRADE #================================================= # BUILD NODE DEPENDENCIES #================================================= ynh_script_progression --message="Building node dependencies..." --weight=20 pushd "$install_dir/sources" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn popd #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last