From fdb764cf823d763e56e4ac163888f2a5a5916572 Mon Sep 17 00:00:00 2001 From: Fabian Wilkens Date: Wed, 23 Dec 2020 14:01:41 +0100 Subject: [PATCH] Update scripts, Set time --- manifest.json | 20 ------------ scripts/backup | 18 +++++------ scripts/change_url | 5 +-- scripts/install | 42 ++++++++++++------------- scripts/remove | 22 +++++++------- scripts/restore | 76 ++++++++++++++++++++++++++++++---------------- scripts/upgrade | 43 +++++++++++++------------- 7 files changed, 116 insertions(+), 110 deletions(-) diff --git a/manifest.json b/manifest.json index 211c378..6db94ca 100644 --- a/manifest.json +++ b/manifest.json @@ -33,26 +33,6 @@ }, "example": "example.com" }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for snweb", - "de": "Wähle einen Pfad für snweb" - }, - "example": "/", - "default": "/" - }, - { - "name": "admin", - "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur", - "de": "Wähle einen Admin Benutzer" - }, - "example": "johndoe" - }, { "name": "is_public", "type": "boolean", diff --git a/scripts/backup b/scripts/backup index 2e567d3..c636374 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -36,28 +36,28 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 +ynh_script_progression --message="Backing up the main app directory..." --weight=1 ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Backing up nginx web server configuration..." --weight=2 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -#ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 +#ynh_script_progression --message="Backing up fail2ban configuration..." --weight=1 #ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" #ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" @@ -67,21 +67,21 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Backing up logrotate configuration..." --weight=1 ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1 +ynh_script_progression --message="Backing up systemd configuration..." --weight=1 ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -89,4 +89,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url index c3b6f73..cc25876 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -17,7 +17,8 @@ old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#new_path=$YNH_APP_NEW_PATH +new_path="/" app=$YNH_APP_INSTANCE_NAME @@ -92,7 +93,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config - ynh_add_nginx_config + ynh_add_nginx_config "port" fi # Change the domain for nginx diff --git a/scripts/install b/scripts/install index 0974e43..063a387 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,8 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH +#path_url=$YNH_APP_ARG_PATH +path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN @@ -33,7 +34,7 @@ snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=2 final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -48,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -60,7 +61,7 @@ ynh_app_setting_set --app=$app --key=snserver_domain --value=$snserver_domain #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." --weight=1 # Find an available port port=$(ynh_find_port --port=3000) @@ -69,7 +70,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=30 ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -78,7 +79,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=16 # Download, check integrity, uncompress and patch the source from app.src git clone $SOURCE "$final_path/live" --quiet @@ -89,7 +90,7 @@ popd #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." --weight=3 # Create a dedicated nginx config ynh_add_nginx_config "port" @@ -97,7 +98,7 @@ ynh_add_nginx_config "port" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path @@ -107,14 +108,14 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=331 +ynh_script_progression --message="Installing Ruby..." --weight=212 ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --time --weight=2 +ynh_script_progression --message="Modifying a config file..." --weight=1 config_file="$final_path/live/.env" cp -f ../conf/env.sample $config_file @@ -132,7 +133,7 @@ ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --re #================================================= # BUILDING #================================================= -ynh_script_progression --message="Building..." +ynh_script_progression --message="Building..." --weight=497 ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin" @@ -151,7 +152,7 @@ popd #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=3 # Create a dedicated systemd config @@ -164,7 +165,7 @@ ynh_add_systemd_config --others_var="\ #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_script_progression --message="Storing the config file checksum..." +ynh_script_progression --message="Storing the config file checksum..." --weight=1 # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config_file" @@ -175,7 +176,7 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R root:root "$final_path" @@ -196,7 +197,7 @@ chown -R $app: "/var/log/$app" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=2 # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile="$final_path/live/log/production.log" @@ -205,14 +206,14 @@ ynh_use_logrotate --logfile="/var/log/$app/$app.log" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -221,7 +222,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] @@ -233,7 +234,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload @@ -241,7 +242,6 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" - +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 1e2a2c2..0e357a2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -30,14 +30,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." --time --weight=1 + ynh_script_progression --message="Removing $app service..." --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 # Remove the dedicated systemd config ynh_remove_systemd_config --service="$app" @@ -45,7 +45,7 @@ ynh_remove_systemd_config --service="$app" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=4 # Remove metapackage and its dependencies ynh_remove_ruby @@ -55,7 +55,7 @@ ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." --weight=2 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -63,7 +63,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -71,7 +71,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." --weight=2 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -82,14 +82,14 @@ ynh_remove_logrotate if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." + ynh_script_progression --message="Closing port $port..." --weight=1 ynh_exec_warn_less yunohost firewall disallow TCP $port fi #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -#ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1 +#ynh_script_progression --message="Removing fail2ban configuration..." --weight=1 # Remove the dedicated fail2ban config #ynh_remove_fail2ban_config @@ -103,7 +103,7 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app @@ -112,4 +112,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 6a6667c..400d033 100755 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -36,7 +36,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -54,39 +54,23 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R root:root "$final_path" -chown $app: "$final_path" -mkdir -p $app: "$final_path/.config" -chown $app: "$final_path/.config" -mkdir -p "$final_path/live/log" -chown -R $app: "$final_path/live/log" -mkdir -p "$final_path/live/public" -chown -R $app: "$final_path/live/public" -mkdir -p "$final_path/live/tmp" -chown -R $app: "$final_path/live/tmp" -chown $app: "$final_path/live/Gemfile.lock" #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -#ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1 +#ynh_script_progression --message="Restoring the fail2ban configuration..." --weight=1 #ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" #ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" @@ -97,7 +81,7 @@ chown $app: "$final_path/live/Gemfile.lock" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." --weight=294 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -105,10 +89,50 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_ruby --ruby_version=$RUBY_VERSION + +#================================================= +# BUILDING +#================================================= +ynh_script_progression --message="Reinstalling $app..." --weight=222 + +ynh_use_nodejs +ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin" + +chown -R $app: "$final_path" + +pushd "$final_path/live" + git submodule update --init --recursive + exec_as $app $ENV_PATH $ynh_npm ci + env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler + env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install + exec_as $app $ENV_PATH $ynh_npm run bundle + exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile +popd + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R root:root "$final_path" +chown $app: "$final_path" +chown $app: "$final_path/live" +mkdir -p $app: "$final_path/.config" +chown $app: "$final_path/.config" +mkdir -p $app: "$final_path/.cache" +chown $app: "$final_path/.cache" +mkdir -p "$final_path/live/log" +chown -R $app: "$final_path/live/log" +mkdir -p "$final_path/live/public" +chown -R $app: "$final_path/live/public" +mkdir -p "$final_path/live/tmp" +chown -R $app: "$final_path/live/tmp" +chown $app: "$final_path/live/Gemfile.lock" + #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -122,7 +146,7 @@ yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$a #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -137,7 +161,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload @@ -145,4 +169,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index de82f3c..9fd5bca 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -21,6 +21,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain) #================================================= # CHECK VERSION @@ -37,7 +39,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -57,7 +59,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=69 # Backup the current version of the app ynh_backup_before_upgrade @@ -73,14 +75,14 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_script_progression --message="Upgrading dependencies..." --weight=37 ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -91,8 +93,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 - + ynh_script_progression --message="Upgrading source files..." --weight=17 # Backup files to keep tmpdir=$(mktemp -d) if [ -d $final_path/live/log ] ; then @@ -108,14 +109,14 @@ then popd # Restore files if [ -d $tmpdir/log ] ; then - cp -Rp $tmpdir/log $final + cp -Rp $tmpdir/log "$final_path/live" fi fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3 # Create a dedicated nginx config ynh_add_nginx_config "port" @@ -124,7 +125,7 @@ ynh_add_nginx_config "port" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -143,7 +144,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Modifying a config file..." --time --weight=2 + ynh_script_progression --message="Modifying a config file..." --weight=2 config_file="$final_path/live/.env" cp -f ../conf/env.sample $config_file @@ -164,7 +165,7 @@ fi #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Building..." + ynh_script_progression --message="Building..." --weight=131 ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin" @@ -184,7 +185,7 @@ fi #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." --weight=4 # Create a dedicated systemd config ynh_add_systemd_config --others_var="\ @@ -205,7 +206,7 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." --weight=2 # Set permissions to app files chown -R root:root "$final_path" @@ -226,7 +227,7 @@ chown -R $app: "/var/log/$app" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile="$final_path/live/log/production.log" @@ -235,14 +236,14 @@ ynh_use_logrotate --logfile="/var/log/$app/$app.log" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -250,7 +251,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # UPGRADE FAIL2BAN #================================================= -#ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1 +#ynh_script_progression --message="Reconfiguring fail2ban..." --weight=1 # Create a dedicated fail2ban config #ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" @@ -258,7 +259,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] @@ -270,7 +271,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -278,4 +279,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last