From 1c01142de0e7c7c7cd8befc8bf526546de3b7716 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 17:03:30 +0200 Subject: [PATCH 01/23] fix_update 4.1.0 --- conf/config.js | 4 +- conf/systemd.service | 4 +- manifest.json | 4 +- pull_request_template.md | 2 +- scripts/_common.sh | 2 +- scripts/backup | 29 ++-------- scripts/change_url | 27 +++------- scripts/install | 88 +++++++++++++----------------- scripts/remove | 40 +++++--------- scripts/restore | 37 +++++++------ scripts/upgrade | 113 ++++++++++++++++----------------------- 11 files changed, 140 insertions(+), 210 deletions(-) diff --git a/conf/config.js b/conf/config.js index 0b3b353..ceb4664 100644 --- a/conf/config.js +++ b/conf/config.js @@ -29,7 +29,7 @@ module.exports = { // @type int // @default 9000 // - port: 9009, + port: __PORT__, // // Set the local IP to bind to for outgoing connections. Leave to undefined @@ -56,7 +56,7 @@ module.exports = { // @type string // @default "example" // - theme: "example", + // theme: "example", // // Prefetch URLs diff --git a/conf/systemd.service b/conf/systemd.service index 526c2ff..cc12689 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,9 +9,9 @@ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="THELOUNGE_HOME=/home/yunohost.app/__APP__/" -ExecStart=__NODE__/node index.js start > /var/log/$app/$app.log +Environment="NODE_ENV=production" +ExecStart=/usr/bin/yarn start Restart=always [Install] WantedBy=default.target - diff --git a/manifest.json b/manifest.json index 7ada7da..6ca8f8c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "The Lounge is a web IRC client.", "fr": "The Lounge est un client web IRC." }, - "version": "4.1.0~ynh1", + "version": "4.1.0~ynh2", "url": "https://thelounge.chat/", "license": "MIT", "maintainer": { @@ -19,7 +19,7 @@ "email": "beudbeud@beudibox.fr" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md index f8635f5..f44dbc6 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -15,4 +15,4 @@ --- *If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-%20(USERNAME)/) \ No newline at end of file +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/_common.sh b/scripts/_common.sh index ff33779..7053ff0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # nodejs version -nodejs_version=12 +nodejs_version="12" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 3466358..57d4973 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,7 +19,6 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -27,61 +26,41 @@ final_path=$(ynh_app_setting_get $app final_path) config_path=$(ynh_app_setting_get $app config_path) domain=$(ynh_app_setting_get $app domain) -#================================================= -# STANDARD BACKUP STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --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_print_info --message="Backing up $app..." ynh_backup --src_path="$final_path" +ynh_backup --src_path="$config_path" + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1 ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # BACKUP CONFIG #================================================= -ynh_script_progression --message="Backing up config path..." --time --weight=1 ynh_backup --src_path="$config_path" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last \ No newline at end of file +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 0965c93..5a4817e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,17 +24,12 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -56,14 +51,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -89,25 +84,19 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -115,4 +104,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last \ No newline at end of file +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index b1f9d9e..efe74e3 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { -ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script @@ -37,24 +37,26 @@ ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app config_path=/home/yunohost.app/$app/ test ! -e "$final_path" || ynh_die "This path already contains a folder" -ynh_app_setting_set --app=$app --key=config_path --value=$config_path + +ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) # Check web path availability -ynh_webpath_available $domain $path_url +ynh_webpath_available "$domain" "$path_url" + # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register "$app" "$domain" "$path_url" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app="$app" --key="domain" --value="$domain" +ynh_app_setting_set --app="$app" --key="path" --value="$path_url" +ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" #================================================= # STANDARD MODIFICATIONS @@ -64,17 +66,22 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_script_progression --message="Configuring firewall..." # Find a free port -port=$(ynh_find_port 9009) -# Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 -ynh_app_setting_set $app port $port +port=$(ynh_find_port 9000) + +ynh_app_setting_set --app="$app" --key="port" --value="$port" #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." -ynh_install_nodejs $nodejs_version +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" + +#============================================== #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -82,8 +89,11 @@ ynh_install_nodejs $nodejs_version ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path + mkdir -p $final_path + mkdir -p $config_path + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -91,7 +101,10 @@ ynh_setup_source --dest_dir="$final_path" # COPY A CONFIG FILE #================================================= -cp -a ../conf/config.js $config_path +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" + +cp -a ../conf/config.js "$config_path" #================================================= # INSTALL THE LOUNGE @@ -99,15 +112,8 @@ cp -a ../conf/config.js $config_path ynh_script_progression --message="Installing The Lounge..." pushd $final_path -npm install --unsafe-perm -# Install webpack -npm install webpack -npm install webpack-cli -npm install copy-webpack-plugin - -# Build The Lounge -NODE_ENV=production npm run build +yarn install && ynh_exec_warn_less NODE_ENV=production yarn build popd @@ -125,18 +131,18 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create "$app" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." -# Create a dedicated systemd config -ynh_use_nodejs -ynh_replace_string "__NODEJS__" "$nodejs_version" "../conf/systemd.service" -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" + ynh_add_systemd_config #================================================= @@ -153,8 +159,8 @@ ynh_store_file_checksum "$config_path/config.js" #================================================= # Set permissions to app files -chown -R $app: $final_path -chown -R $app: $config_path +chown -R "$app": "$final_path" +chown -R "$app": "$config_path" #================================================= # SETUP LOGROTATE @@ -168,33 +174,15 @@ ynh_use_logrotate # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -### `yunohost service add` is a CLI yunohost command to add a service in the admin panel. -### You'll find the service in the 'services' section of YunoHost admin panel. -### This CLI command would be useless if the app does not have any services (systemd or sysvinit) -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script -### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script - -yunohost service add $app --log "/var/log/$app/$app.log" -# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added -#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log" +yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service -### If you're not using these lines: -### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script -### - As well as the section "START SYSTEMD SERVICE" in the restore script -### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script -### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script - # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="[INFO] Available at http://:::9000/ in private mode" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # SETUP SSOWAT @@ -205,7 +193,7 @@ ynh_script_progression --message="Configuring SSOwat..." if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" fi #================================================= diff --git a/scripts/remove b/scripts/remove index ecbd0d3..22084c9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,13 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +config_path=$(ynh_app_setting_get --app=$app --key=config_path --value=$config_path) #================================================= # STANDARD REMOVE @@ -29,14 +30,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove a service from the admin panel, added by `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 - yunohost service remove $app + ynh_script_progression --message="Removing $app service..." + 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..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,7 +45,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_nodejs @@ -52,15 +53,17 @@ 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..." # Remove the app directory securely ynh_secure_remove --file="$final_path" +ynh_secure_remove --file="$config_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..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -68,38 +71,23 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -#================================================= -# SPECIFIC REMOVE -#================================================= - #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username=$app +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 a587a96..e1f5650 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { -ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -35,7 +35,7 @@ config_path=$(ynh_app_setting_get $app config_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..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -53,40 +53,45 @@ 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..." 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..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username="$app" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." -ynh_install_nodejs $nodejs_version +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # RESTORE THE CONFIG #================================================= -ynh_script_progression --message="Restoring the config path..." --time --weight=1 +ynh_script_progression --message="Restoring the config path..." ynh_restore_file --origin_path="$config_path" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" + systemctl enable $app.service #================================================= @@ -98,9 +103,9 @@ yunohost service add $app --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="[INFO] Available at http://:::9000/ in private mode" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -113,15 +118,15 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # Restore permissions to app files -chown -R $app: $final_path -chown -R $app: $config_path +chown -R "$app": "$final_path" +chown -R "$app": "$config_path" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -129,4 +134,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 6e9b49d..6374699 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,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..." app=$YNH_APP_INSTANCE_NAME @@ -27,18 +27,12 @@ port=$(ynh_app_setting_get $app port) # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. 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..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -61,16 +55,14 @@ if [ -z "$config_path" ]; then ynh_app_setting_set --app=$app --key=config_path --value=$config_path 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)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -89,9 +81,9 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -99,18 +91,33 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." + + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" fi #================================================= -# UPGRADE NODEJS +# COPY A CONFIG FILE #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 -ynh_install_nodejs $nodejs_version +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" + +cp -a ../conf/config.js "$config_path" + +#================================================= +# UPGRADE NODEJS AND YARN +#================================================= +ynh_script_progression --message="Upgrading dependencies..." + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # UPGRADE THE LOUNGE @@ -118,25 +125,17 @@ ynh_install_nodejs $nodejs_version if [ "$upgrade_type" == "UPGRADE_APP" ] then -ynh_use_nodejs -pushd $final_path -npm install --unsafe-perm + pushd $final_path -# Install webpack -npm upgrade webpack -npm upgrade webpack-cli -npm upgrade copy-webpack-plugin + yarn install && ynh_exec_warn_less NODE_ENV=production yarn build -# Build The Lounge -NODE_ENV=production npm run build - -popd + popd fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -144,36 +143,23 @@ ynh_add_nginx_config #================================================= # 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..." # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username="$app" #================================================= # SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configuring a systemd service..." + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" -# Create a dedicated systemd config -ynh_use_nodejs -ynh_replace_string "__NODEJS__" "$nodejs_version" "../conf/systemd.service" -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" ynh_add_systemd_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= @@ -181,15 +167,16 @@ ynh_system_user_create --username=$app ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ynh_backup_if_checksum_is_different --file="$config_path/config.js" + # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config_path/config.js" -cp -a ../conf/config.js $config_path +cp -a ../conf/config.js "$config_path" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -201,32 +188,26 @@ ynh_use_logrotate --non-append #================================================= # Set right permissions for curl installation -chown -R $app: $final_path -chown -R $app: $config_path +chown -R "$app": "$final_path" +chown -R "$app": "$config_path" #================================================= -# SETUP SSOWAT +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi +yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="[INFO] Available at http://:::9000/ in private mode" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -234,4 +215,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 From 6b508c40228a7bdbfcb6b58a998dbe5fba533e3a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 18:18:11 +0200 Subject: [PATCH 02/23] cleaning up --- scripts/backup | 8 ++--- scripts/change_url | 2 +- scripts/install | 81 ++++++++++++++++++++-------------------------- scripts/remove | 4 +-- scripts/restore | 8 ++--- scripts/upgrade | 26 +++++++-------- 6 files changed, 57 insertions(+), 72 deletions(-) diff --git a/scripts/backup b/scripts/backup index 57d4973..557e38d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,17 +19,17 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Backing up $app..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -config_path=$(ynh_app_setting_get $app config_path) -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up $app..." ynh_backup --src_path="$final_path" diff --git a/scripts/change_url b/scripts/change_url index 5a4817e..30768ab 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -91,7 +91,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index efe74e3..645f535 100644 --- a/scripts/install +++ b/scripts/install @@ -36,9 +36,8 @@ ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app config_path=/home/yunohost.app/$app/ -test ! -e "$final_path" || ynh_die "This path already contains a folder" -ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" +test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) @@ -49,17 +48,6 @@ ynh_webpath_available "$domain" "$path_url" # Register (book) web path ynh_webpath_register "$app" "$domain" "$path_url" -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." - -ynh_app_setting_set --app="$app" --key="domain" --value="$domain" -ynh_app_setting_set --app="$app" --key="path" --value="$path_url" -ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" - -#================================================= -# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= @@ -70,6 +58,17 @@ port=$(ynh_find_port 9000) ynh_app_setting_set --app="$app" --key="port" --value="$port" +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." + +ynh_app_setting_set --app="$app" --key="domain" --value="$domain" +ynh_app_setting_set --app="$app" --key="path" --value="$path_url" +ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" +ynh_app_setting_set --app="$app" --key="final_path" --value="$final_path" +ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -81,18 +80,14 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#============================================== - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +mkdir -p "$final_path" -mkdir -p $final_path - -mkdir -p $config_path +mkdir -p "$config_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -106,25 +101,19 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f cp -a ../conf/config.js "$config_path" +ynh_store_file_checksum "$config_path/config.js" + #================================================= # INSTALL THE LOUNGE #================================================= ynh_script_progression --message="Installing The Lounge..." -pushd $final_path +pushd "$final_path" yarn install && ynh_exec_warn_less NODE_ENV=production yarn build popd -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring nginx web server..." - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -133,6 +122,14 @@ ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create "$app" +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring nginx web server..." + +# Create a dedicated nginx config +ynh_add_nginx_config + #================================================= # SETUP SYSTEMD #================================================= @@ -145,12 +142,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$config_path/config.js" +yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" #================================================= # GENERIC FINALIZATION @@ -170,19 +162,13 @@ ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" - #================================================= # 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" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # SETUP SSOWAT @@ -190,11 +176,14 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$ ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" -fi +#if [ $is_public -eq 1 ] +#then +# # unprotected_uris allows SSO credentials to be passed anyway. +# ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" +#fi + +# Make app public if necessary or protect it +[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index 22084c9..07f3894 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -config_path=$(ynh_app_setting_get --app=$app --key=config_path --value=$config_path) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # STANDARD REMOVE @@ -47,7 +47,7 @@ ynh_remove_systemd_config #================================================= ynh_script_progression --message="Removing dependencies..." -# Remove metapackage and its dependencies +# Remove NodeJS ynh_remove_nodejs #================================================= diff --git a/scripts/restore b/scripts/restore index e1f5650..0388215 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,10 +27,10 @@ ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -config_path=$(ynh_app_setting_get $app config_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # CHECK IF THE APP CAN BE RESTORED diff --git a/scripts/upgrade b/scripts/upgrade index 6374699..4aef1a4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,12 +16,12 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -config_path=$(ynh_app_setting_get $app config_path) -port=$(ynh_app_setting_get $app port) +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) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION @@ -83,7 +83,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -125,7 +125,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if [ "$upgrade_type" == "UPGRADE_APP" ] then - pushd $final_path + pushd "$final_path" yarn install && ynh_exec_warn_less NODE_ENV=production yarn build @@ -160,6 +160,8 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config +yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= @@ -191,18 +193,12 @@ ynh_use_logrotate --non-append chown -R "$app": "$final_path" chown -R "$app": "$config_path" -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # RELOAD NGINX From 3457ed5610b92f1a77846c97c442a13354e1e592 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 18:41:09 +0200 Subject: [PATCH 03/23] fix --- scripts/backup | 4 +--- scripts/install | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index 557e38d..cf15b1c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Backing up $app..." +ynh_print_info --message="Backing up The Lounge..." app=$YNH_APP_INSTANCE_NAME @@ -33,8 +33,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) ynh_backup --src_path="$final_path" -ynh_backup --src_path="$config_path" - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index 645f535..d1241a5 100644 --- a/scripts/install +++ b/scripts/install @@ -35,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app -config_path=/home/yunohost.app/$app/ +config_path=/home/yunohost.app/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" From fc590542d40cba6849f8495a83af766558add7cd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 19:53:28 +0200 Subject: [PATCH 04/23] fix --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index d1241a5..3ca3a5a 100644 --- a/scripts/install +++ b/scripts/install @@ -75,7 +75,7 @@ ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" ynh_script_progression --message="Installing dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" diff --git a/scripts/upgrade b/scripts/upgrade index 4aef1a4..23db55a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -114,7 +114,7 @@ cp -a ../conf/config.js "$config_path" ynh_script_progression --message="Upgrading dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" From d1bbb69f94d8326af4fee025d53270a3f3e943b8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 20:02:32 +0200 Subject: [PATCH 05/23] Revert "fix" This reverts commit fc590542d40cba6849f8495a83af766558add7cd. --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3ca3a5a..d1241a5 100644 --- a/scripts/install +++ b/scripts/install @@ -75,7 +75,7 @@ ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" ynh_script_progression --message="Installing dependencies..." # Install Nodejs -ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" diff --git a/scripts/upgrade b/scripts/upgrade index 23db55a..4aef1a4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -114,7 +114,7 @@ cp -a ../conf/config.js "$config_path" ynh_script_progression --message="Upgrading dependencies..." # Install Nodejs -ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" From 7579ff0337593725eca016fdfb360a82253eab6b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 22:13:19 +0200 Subject: [PATCH 06/23] add badges --- README.md | 4 ++-- README_fr.md | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d977ec0..4e4116a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The Lounge for YunoHost -[![Integration level](https://dash.yunohost.org/integration/thelounge.svg)](https://dash.yunohost.org/appci/app/thelounge) +[![Integration level](https://dash.yunohost.org/integration/thelounge.svg)](https://dash.yunohost.org/appci/app/thelounge) ![](https://ci-apps.yunohost.org/ci/badges/thelounge.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/thelounge.maintain.svg) [![Install The Lounge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=thelounge) *[Lire ce readme en français.](./README_fr.md)* @@ -61,4 +61,4 @@ To try the testing branch, please proceed like that. sudo yunohost app install https://github.com/YunoHost-Apps/thelounge_ynh/tree/testing --debug or sudo yunohost app upgrade thelounge -u https://github.com/YunoHost-Apps/thelounge_ynh/tree/testing --debug -``` \ No newline at end of file +``` diff --git a/README_fr.md b/README_fr.md index 1d593c1..8485b31 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,19 +1,19 @@ # The Lounge pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/thelounge.svg)](https://dash.yunohost.org/appci/app/thelounge) +[![Niveau d’intégration](https://dash.yunohost.org/integration/thelounge.svg)](https://dash.yunohost.org/appci/app/thelounge) ![](https://ci-apps.yunohost.org/ci/badges/thelounge.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/thelounge.maintain.svg) [![Installer The Lounge avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=thelounge) *[Read this readme in english.](./README.md)* > *Ce package vous permet d'installer The Lounge rapidement et simplement sur un serveur Yunohost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* -## Vue d'ensemble +## Vue d’ensemble The Lounge est un client Web IRC auto-hébergé. -**Version incluse:** 4.1.0 +**Version incluse :** 4.1.0 -## Captures d'écran +## Captures d’écran ![](https://raw.githubusercontent.com/thelounge/thelounge.github.io/master/img/thelounge-screenshot.png) @@ -23,18 +23,18 @@ The Lounge est un client Web IRC auto-hébergé. ## Configuration -Comment configurer cette application: via le panneau d'administration. +Comment configurer cette application: via le panneau d’administration. ## Documentation - * Documentation officielle: https://thelounge.chat/docs + * Documentation officielle : https://thelounge.chat/docs ## Caractéristiques spécifiques YunoHost #### Support multi-utilisateurs -* L'authentification LDAP est-elle prise en charge? **Oui** -* L'application peut-elle être utilisée par plusieurs utilisateurs? **Oui** +* L’authentification LDAP est-elle prise en charge ? **Oui** +* L’application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** #### Architectures supportées @@ -43,10 +43,10 @@ Comment configurer cette application: via le panneau d'administration. ## Liens - * Signaler un bug: https://github.com/YunoHost-Apps/thelounge_ynh/issues - * Site de l'application: https://thelounge.chat/ - * Dépôt de l'application principale: https://github.com/thelounge/thelounge - * Site web YunoHost: https://yunohost.org/ + * Signaler un bug : https://github.com/YunoHost-Apps/thelounge_ynh/issues + * Site de l’application : https://thelounge.chat/ + * Dépôt de l’application principale : https://github.com/thelounge/thelounge + * Site web YunoHost : https://yunohost.org/ --- From afa6b2be2bd86b4a92b52fce8d48c6f0e8c6f675 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 22:48:08 +0200 Subject: [PATCH 07/23] Update check_process --- check_process | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index 78a3fb3..8f8325f 100644 --- a/check_process +++ b/check_process @@ -9,7 +9,7 @@ path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) password="pass" - port="9009" (PORT) + port="9000" (PORT) ; Checks pkg_linter=1 setup_sub_dir=1 @@ -18,11 +18,10 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=7a4ce3de66d44b45ea08e8feb07b925a821ec760 backup_restore=1 multi_instance=0 - incorrect_path=1 - port_already_use=1 + incorrect_path=0 + port_already_use=0 change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. From 5535e7b78ae122172222745a33bf5f2f8ff459d9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 May 2020 22:51:29 +0200 Subject: [PATCH 08/23] add YunoHost doc --- README.md | 1 + README_fr.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e4116a..9b96b4f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ How to configure this app: by an admin panel. ## Documentation * Official documentation: https://thelounge.chat/docs + * YunoHost documentation: https://yunohost.org/#/app_thelounge ## YunoHost specific features diff --git a/README_fr.md b/README_fr.md index 8485b31..cefbce5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -23,11 +23,12 @@ The Lounge est un client Web IRC auto-hébergé. ## Configuration -Comment configurer cette application: via le panneau d’administration. +Comment configurer cette application : via le panneau d’administration. ## Documentation * Documentation officielle : https://thelounge.chat/docs + * Documentation YunoHost : https://yunohost.org/#/app_thelounge_fr ## Caractéristiques spécifiques YunoHost From 131be3a5543524f3cdb93c71cbe15d780bea99f3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 29 May 2020 22:51:48 +0200 Subject: [PATCH 09/23] cleaning up --- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/change_url | 4 ++-- scripts/install | 45 +++++++++++++++++++-------------------------- scripts/remove | 8 ++++---- scripts/restore | 14 +++++++------- scripts/upgrade | 20 ++++++++++---------- 7 files changed, 45 insertions(+), 52 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7053ff0..ff33779 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # nodejs version -nodejs_version="12" +nodejs_version=12 #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index cf15b1c..14f0869 100644 --- a/scripts/backup +++ b/scripts/backup @@ -31,7 +31,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path=$final_path #================================================= # BACKUP THE NGINX CONFIGURATION @@ -55,7 +55,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP CONFIG #================================================= -ynh_backup --src_path="$config_path" +ynh_backup --src_path=$config_path #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 30768ab..f08dfe8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -53,7 +53,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -91,7 +91,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index d1241a5..42f2636 100644 --- a/scripts/install +++ b/scripts/install @@ -43,10 +43,10 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" path_url=$(ynh_normalize_url_path $path_url) # Check web path availability -ynh_webpath_available "$domain" "$path_url" +ynh_webpath_available --app=$app --domain=$domain --path_url=$path_url # Register (book) web path -ynh_webpath_register "$app" "$domain" "$path_url" +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # FIND AND OPEN A PORT @@ -56,18 +56,18 @@ ynh_script_progression --message="Configuring firewall..." # Find a free port port=$(ynh_find_port 9000) -ynh_app_setting_set --app="$app" --key="port" --value="$port" +ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app="$app" --key="domain" --value="$domain" -ynh_app_setting_set --app="$app" --key="path" --value="$path_url" -ynh_app_setting_set --app="$app" --key="is_public" --value="$is_public" -ynh_app_setting_set --app="$app" --key="final_path" --value="$final_path" -ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +ynh_app_setting_set --app=$app --key=config_path --value=$config_path #================================================= # INSTALL DEPENDENCIES @@ -75,7 +75,7 @@ ynh_app_setting_set --app="$app" --key="config_path" --value="$config_path" ynh_script_progression --message="Installing dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -85,12 +85,12 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Setting up source files..." -mkdir -p "$final_path" +mkdir -p $final_path -mkdir -p "$config_path" +mkdir -p $config_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir=$final_path #================================================= # COPY A CONFIG FILE @@ -108,7 +108,7 @@ ynh_store_file_checksum "$config_path/config.js" #================================================= ynh_script_progression --message="Installing The Lounge..." -pushd "$final_path" +pushd $final_path yarn install && ynh_exec_warn_less NODE_ENV=production yarn build @@ -120,7 +120,7 @@ popd ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create "$app" +ynh_system_user_create --username=$app #================================================= # NGINX CONFIGURATION @@ -142,7 +142,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" +yunohost service add $app --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" #================================================= # GENERIC FINALIZATION @@ -151,8 +151,8 @@ yunohost service add "$app" --description "Self-hosted web IRC client" --log "/v #================================================= # Set permissions to app files -chown -R "$app": "$final_path" -chown -R "$app": "$config_path" +chown -R $app: $final_path +chown -R $app: $config_path #================================================= # SETUP LOGROTATE @@ -168,22 +168,15 @@ ynh_use_logrotate ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring SSOwat..." -# Make app public if necessary -#if [ $is_public -eq 1 ] -#then -# # unprotected_uris allows SSO credentials to be passed anyway. -# ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" -#fi - # Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" +[ $is_public -eq 1 ] || ynh_permission_update --permission "main" --add "visitors" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index 07f3894..1b25793 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,7 +31,7 @@ config_path=$(ynh_app_setting_get --app=$app --key=config_path) if ynh_exec_warn_less yunohost service status $app >/dev/null then ynh_script_progression --message="Removing $app service..." - yunohost service remove "$app" + yunohost service remove $app fi #================================================= @@ -56,9 +56,9 @@ ynh_remove_nodejs ynh_script_progression --message="Removing $app main directory..." # Remove the app directory securely -ynh_secure_remove --file="$final_path" +ynh_secure_remove --file=$final_path -ynh_secure_remove --file="$config_path" +ynh_secure_remove --file=$config_path #================================================= # REMOVE NGINX CONFIGURATION @@ -84,7 +84,7 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username="$app" +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 0388215..4ed05d9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path=$final_path #================================================= # RECREATE THE DEDICATED USER @@ -63,7 +63,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username="$app" +ynh_system_user_create --username=$app #================================================= # SPECIFIC RESTORATION @@ -73,7 +73,7 @@ ynh_system_user_create --username="$app" ynh_script_progression --message="Reinstalling dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -83,7 +83,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Restoring the config path..." -ynh_restore_file --origin_path="$config_path" +ynh_restore_file --origin_path=$config_path #================================================= # RESTORE SYSTEMD @@ -105,7 +105,7 @@ yunohost service add $app --log "/var/log/$app/$app.log" #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -118,8 +118,8 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # Restore permissions to app files -chown -R "$app": "$final_path" -chown -R "$app": "$config_path" +chown -R $app: $final_path +chown -R $app: $config_path #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 4aef1a4..2da7551 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -83,7 +83,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -93,10 +93,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - ynh_secure_remove --file="$final_path" + ynh_secure_remove --file=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir=$final_path fi #================================================= @@ -114,7 +114,7 @@ cp -a ../conf/config.js "$config_path" ynh_script_progression --message="Upgrading dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -125,7 +125,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if [ "$upgrade_type" == "UPGRADE_APP" ] then - pushd "$final_path" + pushd $final_path yarn install && ynh_exec_warn_less NODE_ENV=production yarn build @@ -146,7 +146,7 @@ ynh_add_nginx_config ynh_script_progression --message="Making sure dedicated system user exists..." # Create a system user -ynh_system_user_create --username="$app" +ynh_system_user_create --username=$app #================================================= # SETUP SYSTEMD @@ -160,7 +160,7 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add "$app" --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" +yunohost service add $app --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -190,15 +190,15 @@ ynh_use_logrotate --non-append #================================================= # Set right permissions for curl installation -chown -R "$app": "$final_path" -chown -R "$app": "$config_path" +chown -R $app: $final_path +chown -R $app: $config_path #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # RELOAD NGINX From 8ceb43d9a76dba27fe86c35892cc2c8dce183624 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 29 May 2020 23:14:19 +0200 Subject: [PATCH 10/23] fix --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 42f2636..1c3be44 100644 --- a/scripts/install +++ b/scripts/install @@ -43,7 +43,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" path_url=$(ynh_normalize_url_path $path_url) # Check web path availability -ynh_webpath_available --app=$app --domain=$domain --path_url=$path_url +ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url From b80fab9a238e52b55e05dbe01df698a0beb7f8a9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 11:57:12 +0200 Subject: [PATCH 11/23] fix CI test --- manifest.json | 4 ++-- scripts/change_url | 2 +- scripts/install | 4 ++-- scripts/restore | 20 ++++++++++---------- scripts/upgrade | 3 ++- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/manifest.json b/manifest.json index 6ca8f8c..79e9520 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "thelounge", "packaging_format": 1, "description": { - "en": "The Lounge is a web IRC client.", - "fr": "The Lounge est un client web IRC." + "en": "Self-hosted web IRC client.", + "fr": "Client Web IRC auto-hébergé." }, "version": "4.1.0~ynh2", "url": "https://thelounge.chat/", diff --git a/scripts/change_url b/scripts/change_url index f08dfe8..d92c78a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -91,7 +91,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 1c3be44..e0a210e 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -168,7 +168,7 @@ ynh_use_logrotate ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 4ed05d9..96123f8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -65,6 +65,14 @@ ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions to app files +chown -R $app: $final_path +chown -R $app: $config_path + #================================================= # SPECIFIC RESTORATION #================================================= @@ -105,7 +113,7 @@ yunohost service add $app --log "/var/log/$app/$app.log" #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -113,14 +121,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions to app files -chown -R $app: $final_path -chown -R $app: $config_path - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2da7551..abaf462 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -63,6 +63,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -198,7 +199,7 @@ chown -R $app: $config_path #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" #================================================= # RELOAD NGINX From eaa5c33162da7bc9d16a6b227ae763b2d4502600 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 14:26:08 +0200 Subject: [PATCH 12/23] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index e0a210e..96e9cc6 100644 --- a/scripts/install +++ b/scripts/install @@ -176,7 +176,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary or protect it -[ $is_public -eq 1 ] || ynh_permission_update --permission "main" --add "visitors" +[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" #================================================= # RELOAD NGINX From 85c756b161766ce7961c04ee2970d023e9f79e14 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 16:10:21 +0200 Subject: [PATCH 13/23] Update restore --- scripts/restore | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/restore b/scripts/restore index 96123f8..720a610 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,14 +65,6 @@ ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions to app files -chown -R $app: $final_path -chown -R $app: $config_path - #================================================= # SPECIFIC RESTORATION #================================================= @@ -93,6 +85,14 @@ ynh_script_progression --message="Restoring the config path..." ynh_restore_file --origin_path=$config_path +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions to app files +chown -R $app: $final_path +chown -R $app: $config_path + #================================================= # RESTORE SYSTEMD #================================================= From 26203f7b9a332457b4d10d5e8d5db679e358c396 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 18:55:27 +0200 Subject: [PATCH 14/23] remove logrotate --- scripts/backup | 6 ------ scripts/install | 8 -------- scripts/remove | 8 -------- scripts/restore | 6 ------ scripts/upgrade | 8 -------- 5 files changed, 36 deletions(-) diff --git a/scripts/backup b/scripts/backup index 14f0869..334b8eb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -39,12 +39,6 @@ ynh_backup --src_path=$final_path ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index 96e9cc6..e08c710 100644 --- a/scripts/install +++ b/scripts/install @@ -154,14 +154,6 @@ yunohost service add $app --description "Self-hosted web IRC client" --log "/var chown -R $app: $final_path chown -R $app: $config_path -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index 1b25793..b5870e0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -68,14 +68,6 @@ ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 720a610..28b0aa5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -115,12 +115,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index abaf462..2babab0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -176,14 +176,6 @@ ynh_store_file_checksum --file="$config_path/config.js" cp -a ../conf/config.js "$config_path" -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # GENERIC FINALIZATION #================================================= From d3d8210422a915fc53bc2d1abd58238703817b11 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 18:56:38 +0200 Subject: [PATCH 15/23] cleaning up --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index d92c78a..85f3330 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -104,4 +104,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index e08c710..56f704f 100644 --- a/scripts/install +++ b/scripts/install @@ -181,4 +181,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index b5870e0..2ac341f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -82,4 +82,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 28b0aa5..e4b8c4e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -128,4 +128,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 2babab0..294f38c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -204,4 +204,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" From 6c7d05b7f6dc0c35ea5118f384ce890d368161c5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 19:00:39 +0200 Subject: [PATCH 16/23] add ynh_use_nodejs --- scripts/install | 5 +++-- scripts/upgrade | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 56f704f..1a2c929 100644 --- a/scripts/install +++ b/scripts/install @@ -110,8 +110,9 @@ ynh_script_progression --message="Installing The Lounge..." pushd $final_path -yarn install && ynh_exec_warn_less NODE_ENV=production yarn build - + ynh_use_nodejs + yarn install && ynh_exec_warn_less NODE_ENV=production yarn build + popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 294f38c..abca621 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,7 +127,8 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if [ "$upgrade_type" == "UPGRADE_APP" ] then pushd $final_path - + + ynh_use_nodejs yarn install && ynh_exec_warn_less NODE_ENV=production yarn build popd From f8779f0f4db2fd0e34329fb0756fbe3250f11565 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 19:15:17 +0200 Subject: [PATCH 17/23] fix checksum and SSOWAT --- scripts/upgrade | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index abca621..dd76818 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -100,6 +100,17 @@ then ynh_setup_source --dest_dir=$final_path fi +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different --file="$config_path/config.js" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$config_path/config.js" + #================================================= # COPY A CONFIG FILE #================================================= @@ -187,6 +198,18 @@ cp -a ../conf/config.js "$config_path" chown -R $app: $final_path chown -R $app: $config_path +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi + #================================================= # START SYSTEMD SERVICE #================================================= From b97fafcd5b46b50e0cc19f74cd5d77ea7e1a9bf2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 19:18:05 +0200 Subject: [PATCH 18/23] Apply last example_ynh --- manifest.json | 1 - scripts/backup | 19 +++---- scripts/change_url | 2 +- scripts/install | 95 ++++++++++++++++------------------- scripts/remove | 21 ++++---- scripts/restore | 38 +++++++------- scripts/upgrade | 122 ++++++++++++++++++++++----------------------- 7 files changed, 141 insertions(+), 157 deletions(-) diff --git a/manifest.json b/manifest.json index 79e9520..29b7f95 100644 --- a/manifest.json +++ b/manifest.json @@ -56,7 +56,6 @@ }, "default": true } - ] } } diff --git a/scripts/backup b/scripts/backup index 14f0869..b3a8400 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -19,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Backing up The Lounge..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -27,11 +28,17 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= + +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path=$final_path +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -39,12 +46,6 @@ ynh_backup --src_path=$final_path ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= @@ -55,7 +56,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP CONFIG #================================================= -ynh_backup --src_path=$config_path +ynh_backup --src_path="$config_path" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index d92c78a..85f3330 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -104,4 +104,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 96e9cc6..7eb36e1 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting } - # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -36,28 +35,11 @@ ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app config_path=/home/yunohost.app/$app - -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Configuring firewall..." - -# Find a free port -port=$(ynh_find_port 9000) - -ynh_app_setting_set --app=$app --key=port --value=$port - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= @@ -66,16 +48,26 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=config_path --value=$config_path +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." + +# Find an available port +port=$(ynh_find_port 9000) +ynh_app_setting_set --app=$app --key=port --value=$port + #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." # Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -85,16 +77,34 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Setting up source files..." -mkdir -p $final_path - -mkdir -p $config_path - +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path #================================================= -# COPY A CONFIG FILE +# NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app + +#================================================= +# SPECIFIC SETUP +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." + +mkdir -p $config_path # Main config File ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" @@ -109,27 +119,10 @@ ynh_store_file_checksum "$config_path/config.js" ynh_script_progression --message="Installing The Lounge..." pushd $final_path - -yarn install && ynh_exec_warn_less NODE_ENV=production yarn build - + yarn install + ynh_exec_warn_less NODE_ENV=production yarn build popd -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring nginx web server..." - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # SETUP SYSTEMD #================================================= @@ -142,25 +135,23 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add $app --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" - #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path chown -R $app: $config_path #================================================= -# SETUP LOGROTATE +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Integrating service in YunoHost..." -# Use logrotate to manage application logfile(s) -ynh_use_logrotate +yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" #================================================= # START SYSTEMD SERVICE @@ -189,4 +180,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 1b25793..75eb175 100644 --- a/scripts/remove +++ b/scripts/remove @@ -24,10 +24,10 @@ config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove a service from the admin panel, added by `yunohost service add` +# 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..." @@ -53,12 +53,10 @@ ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing $app main directory..." +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove --file=$final_path - -ynh_secure_remove --file=$config_path +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION @@ -69,12 +67,13 @@ ynh_script_progression --message="Removing nginx web server configuration..." ynh_remove_nginx_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# SPECIFIC REMOVE #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +# REMOVE THE CONFIG FILE +#================================================= +ynh_script_progression --message="Removing the config file..." -# Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_secure_remove --file="$config_path" #================================================= # GENERIC FINALIZATION @@ -90,4 +89,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 720a610..155acb7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -16,7 +17,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting } - # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -47,6 +47,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -55,7 +56,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file --origin_path=$final_path +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER @@ -65,6 +66,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app +#================================================= +# RESTORE USER RIGHTS +#================================================= +ynh_script_progression --message="Restoring user rights..." + +# Restore permissions to app files +chown -R $app: $final_path +chown -R $app: $config_path + #================================================= # SPECIFIC RESTORATION #================================================= @@ -83,15 +93,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Restoring the config path..." -ynh_restore_file --origin_path=$config_path - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions to app files -chown -R $app: $final_path -chown -R $app: $config_path +ynh_restore_file --origin_path="$config_path" #================================================= # RESTORE SYSTEMD @@ -99,14 +101,14 @@ chown -R $app: $config_path ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" - systemctl enable $app.service #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log "/var/log/$app/$app.log" +yunohost service add $app --description "Self-hosted web IRC client" --log_path="systemd" --line_match="Available at http" #================================================= # START SYSTEMD SERVICE @@ -115,12 +117,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= @@ -134,4 +130,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index abaf462..71f2f16 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -75,7 +76,7 @@ ynh_abort_if_errors #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STANDARD UPGRADE STEPS @@ -97,40 +98,7 @@ then ynh_secure_remove --file=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path -fi - -#================================================= -# COPY A CONFIG FILE -#================================================= - -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" - -cp -a ../conf/config.js "$config_path" - -#================================================= -# UPGRADE NODEJS AND YARN -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -# Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - -#================================================= -# UPGRADE THE LOUNGE -#================================================= - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - pushd $final_path - - yarn install && ynh_exec_warn_less NODE_ENV=production yarn build - - popd + ynh_setup_source --dest_dir="$final_path" fi #================================================= @@ -141,18 +109,55 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +# Install Yarn +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" + #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create --username=$app +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPGRADE THE LOUNGE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading the lounge..." + pushd $final_path + yarn install && ynh_exec_warn_less NODE_ENV=production yarn build + popd +fi + +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." + +ynh_backup_if_checksum_is_different --file="$config_path" +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" + +cp -a ../conf/config.js "$config_path" +ynh_store_file_checksum "$config_path/config.js" + #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Upgrading systemd configuration..." ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" @@ -161,39 +166,32 @@ ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path ynh_add_systemd_config -yunohost service add $app --description "Self-hosted web IRC client" --log "/var/log/$app/$app.log" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$config_path/config.js" - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config_path/config.js" - -cp -a ../conf/config.js "$config_path" - -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." -# Set right permissions for curl installation +# Set permissions on app files chown -R $app: $final_path chown -R $app: $config_path +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." + +# Make app public if necessary or protect it +[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" + #================================================= # START SYSTEMD SERVICE #================================================= @@ -212,4 +210,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" From 9dc0be7ad6e5df08b19fd3ddd33bb4f69b79653d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 19:29:45 +0200 Subject: [PATCH 19/23] few changes --- scripts/change_url | 1 + scripts/install | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 85f3330..fd495ad 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -91,6 +91,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" #================================================= diff --git a/scripts/install b/scripts/install index 643dec1..699c427 100644 --- a/scripts/install +++ b/scripts/install @@ -67,7 +67,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." # Install Nodejs -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" From 93cdc8ec4b7a8935341d50e8d8a017cdd332a33d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 21:03:54 +0200 Subject: [PATCH 20/23] Reorder restore steps --- scripts/restore | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/restore b/scripts/restore index 155acb7..c916455 100644 --- a/scripts/restore +++ b/scripts/restore @@ -58,6 +58,13 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" +#================================================= +# RESTORE THE CONFIG +#================================================= +ynh_script_progression --message="Restoring the config path..." + +ynh_restore_file --origin_path="$config_path" + #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -88,13 +95,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#================================================= -# RESTORE THE CONFIG -#================================================= -ynh_script_progression --message="Restoring the config path..." - -ynh_restore_file --origin_path="$config_path" - #================================================= # RESTORE SYSTEMD #================================================= From 4b511de3d89eb446fed7da19ae52e0f18bc13bab Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 30 May 2020 21:53:56 +0200 Subject: [PATCH 21/23] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index c916455..f73d96b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -108,7 +108,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Self-hosted web IRC client" --log_path="systemd" --line_match="Available at http" +yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" #================================================= # START SYSTEMD SERVICE From 3267a8831d8857944acf6d2a731edb737e01c10c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 10 Jun 2020 23:43:27 +0200 Subject: [PATCH 22/23] Add Buster badge --- README.md | 3 ++- README_fr.md | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b96b4f..7d99cf1 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ How to configure this app: by an admin panel. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/thelounge/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/thelounge/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/thelounge/) +* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/thelounge/) ## Links diff --git a/README_fr.md b/README_fr.md index cefbce5..b2d9ba3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer The Lounge rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer The Lounge rapidement et simplement sur un serveur YunoHost. Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* ## Vue d’ensemble @@ -39,8 +39,9 @@ Comment configurer cette application : via le panneau d’administration. #### Architectures supportées -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/thelounge/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/thelounge/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/thelounge/) +* Buster x86-64 - [![](https://ci-buster.nohost.me/ci/logs/thelounge%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/thelounge/) ## Liens From 6efc5ad4eee7d237b3a214051c56de08dc7b06ee Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 18 Jun 2020 09:35:11 +0200 Subject: [PATCH 23/23] description in fr --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 699c427..225b1e0 100644 --- a/scripts/install +++ b/scripts/install @@ -152,7 +152,7 @@ chown -R $app: $config_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" +yunohost service add $app --description "Client Web IRC auto-hébergé" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index f73d96b..848d85b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -108,7 +108,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" +yunohost service add $app --description "Client Web IRC auto-hébergé" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 2e2d6a3..ea6f882 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -186,7 +186,7 @@ chown -R $app: $config_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Self-hosted web IRC client" --log_type "systemd" +yunohost service add $app --description "Client Web IRC auto-hébergé" --log_type "systemd" #================================================= # SETUP SSOWAT