#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # INSTALL NODEJS #================================================= ynh_script_progression --message="Updating NodeJS..." ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="src/client/config.js src/server/index.js" chmod -R o-rwx "$install_dir" chown -R "$app:$app" "$install_dir" #================================================= # SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template="client.config.js" --destination="$install_dir/src/client/config.js" chmod 400 "$install_dir/src/client/config.js" chown "$app:$app" "$install_dir/src/client/config.js" ynh_add_config --template="server.index.js" --destination="$install_dir/src/server/index.js" chmod 400 "$install_dir/src/server/index.js" chown "$app:$app" "$install_dir/src/server/index.js" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." pushd "$install_dir" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run package:discover ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" install --save --production @osjs/pam-auth popd ynh_replace_string --match_string="8000" --replace_string="$port" --target_file="$install_dir/src/server/config.js" chown -R "$app:$app" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 ynh_add_nginx_config ynh_add_systemd_config yunohost service add "$app" --description="Desktop you have accesss through your browser" --log="/var/log/$app/$app.log" ynh_use_logrotate --non-append #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Server listening on" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed"