diff --git a/README.md b/README.md index bb148c0..54b4bf6 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ The app can be used by multiple users, anonymously. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/) ## Limitations diff --git a/check_process b/check_process index f2ab4ae..0fefea2 100644 --- a/check_process +++ b/check_process @@ -24,6 +24,8 @@ upgrade=1 from_commit=f7bc083d037eb771afeddc2237a24505a5ef1c68 # 1.3.0~ynh6 upgrade=1 from_commit=cdec64125b179f6b19470ceb8379225ed03c10a8 + # 1.3.0~ynh7 + upgrade=1 from_commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a backup_restore=1 multi_instance=1 port_already_use=0 @@ -40,3 +42,5 @@ Notification=all name=1.3.0~ynh5 ; commit=cdec64125b179f6b19470ceb8379225ed03c10a8 name=1.3.0~ynh6 + ; commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a + name=1.3.0~ynh7 diff --git a/manifest.json b/manifest.json index b3f59d0..cbe0799 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Distributed pastebin with ActivityPub.", "fr": "Pastebin distribué utilisant le protocole ActivityPub." }, - "version": "1.3.0~ynh7", + "version": "1.3.0~ynh8", "url": "https://distbin.com/", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/change_url b/scripts/change_url index b934598..ad048fb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." diff --git a/scripts/install b/scripts/install index 1005197..937f27a 100644 --- a/scripts/install +++ b/scripts/install @@ -67,6 +67,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,6 +84,10 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -84,14 +96,6 @@ 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 --home_dir="$final_path" - #================================================= # SPECIFIC SETUP #================================================= @@ -111,24 +115,36 @@ mkdir -p "$final_path/distbin-db" mkdir -p "$final_path/distbin-db/activities" mkdir -p "$final_path/distbin-db/inbox" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # INSTALLING DISTBIN #================================================= ynh_script_progression --message="Installing Distbin..." -chown -R "$app":"$app" "$final_path" - pushd $final_path ynh_use_nodejs ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build - cp package* dist/ + sudo -u $app cp -af package* dist/ popd pushd $final_path/dist ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a config file..." + +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" + +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" + #================================================= # SETUP SYSTEMD #================================================= @@ -137,23 +153,8 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." - -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" - #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R $app:$app $final_path - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/restore b/scripts/restore index 78afd1b..df37250 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -50,6 +50,14 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -57,21 +65,9 @@ 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..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R $app:$app $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # CREATE LOG FOLDER @@ -127,7 +123,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." diff --git a/scripts/upgrade b/scripts/upgrade index 6f1a9c4..dbb4f0e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take ynh_backup_before_upgrade ynh_clean_setup () { ynh_clean_check_starting - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -64,6 +64,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped Distbin Service" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,6 +84,10 @@ then ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -92,14 +104,6 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC UPGRADE #================================================= @@ -121,24 +125,36 @@ if [ -d "$DIRECTORY" ]; then mv "$final_path/db" "$final_path/distbin-db" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # MAKE UPGRADE #================================================= ynh_script_progression --message="Making upgrade..." -chown -R "$app":"$app" "$final_path" - pushd $final_path ynh_use_nodejs ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build - cp package* dist/ + sudo -u $app cp -af package* dist/ popd pushd $final_path/dist ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a config file..." + +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" + +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" + #================================================= # SETUP SYSTEMD #================================================= @@ -147,23 +163,8 @@ ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a config file..." - -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" - #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app:$app $final_path - #================================================= # SETUP LOGROTATE #=================================================