From c6558b537bab8ebc6aca12c96c3d1335ce1f297a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 6 Apr 2021 21:45:01 +0200 Subject: [PATCH 01/13] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 8573b79..e6495d4 100644 --- a/check_process +++ b/check_process @@ -24,7 +24,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=yalh@yahoo.com Notification=all From a2b6dbf4bb92212506e4c9683589d04c3b8a7752 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 21:21:27 +0200 Subject: [PATCH 02/13] Apply last example_ynh --- .travis.yml | 7 ----- README.md | 4 +-- check_process | 2 +- conf/config.ini | 10 +++---- conf/systemd.service | 6 ++-- manifest.json | 29 +++----------------- scripts/backup | 2 +- scripts/change_url | 16 +++++------ scripts/install | 65 ++++++++++++++++---------------------------- scripts/remove | 6 ++-- scripts/restore | 24 +++++++--------- scripts/upgrade | 40 ++++++++++++--------------- 12 files changed, 78 insertions(+), 133 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6133a24..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: python - -before_install: - - git clone https://github.com/YunoHost/package_linter /tmp/package_linter - -script: -- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/README.md b/README.md index 300a790..ae78f7f 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ If User Mode is configured Multiple users, the app be used by multiple users #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/writefreely/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/writefreely.svg)](https://ci-apps-arm.yunohost.org/ci/apps/writefreely/) ## Limitations diff --git a/check_process b/check_process index 8573b79..e6495d4 100644 --- a/check_process +++ b/check_process @@ -24,7 +24,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=yalh@yahoo.com Notification=all diff --git a/conf/config.ini b/conf/config.ini index 48b1529..7ebe140 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -14,16 +14,16 @@ hash_seed = [database] type = mysql filename = -username = __DBUSER__ -password = __DBPWD__ -database = __DBNAME__ +username = __DB_USER__ +password = __DB_PWD__ +database = __DB_NAME__ host = localhost port = 3306 [app] site_name = WriteFreely site_description = WriteFreely_Blogs -host = __DOMAIN_URL__ +host = __DOMAIN__ theme = write editor = disable_js = false @@ -34,7 +34,7 @@ wf_modesty = false chorus = false forest = false disable_drafts = false -single_user = __SINGLEUSER__ +single_user = __SINGLE_USER__ open_registration = true min_username_len = 3 max_blogs = 4 diff --git a/conf/systemd.service b/conf/systemd.service index be2c2fb..9a62fe9 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,11 +6,11 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -StandardOutput=syslog -StandardError=syslog -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__FINALPATH__/ ExecStart=__FINALPATH__/writefreely Restart=always +StandardOutput=syslog +StandardError=syslog [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 55b7045..58aeac0 100644 --- a/manifest.json +++ b/manifest.json @@ -9,14 +9,9 @@ "version": "0.12.0~ynh4", "url": "https://writefreely.org", "license": "AGPL-3.0-or-later", - "maintainer": [ - { - "name": "Anmol Sharma", - "email": "anmol@datamol.org" - }, - { - "name": "yalh76" - }], + "maintainer": { + "name": "yalh76" + }, "requirements": { "yunohost": ">= 4.1.3" }, @@ -30,37 +25,21 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for WriteFreely", - "fr": "Choisissez un nom de domaine pour WriteFreely" - }, "example": "example.com" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { "name": "password", "type": "password", - "ask": { - "en": "Set the administrator password", - "fr": "Définissez le mot de passe administrateur" - }, "example": "Choose a password" }, { @@ -72,6 +51,6 @@ }, "default": true } - ] + ] } } diff --git a/scripts/backup b/scripts/backup index 63ac358..a03e0e6 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# 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 diff --git a/scripts/change_url b/scripts/change_url index a50bdba..d919a20 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= -# 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)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -45,7 +45,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # 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 @@ -79,19 +79,19 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi diff --git a/scripts/install b/scripts/install index 7c2dd83..f127e3b 100755 --- a/scripts/install +++ b/scripts/install @@ -79,6 +79,14 @@ ynh_script_progression --message="Finding an available port..." port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -98,22 +106,18 @@ 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" --source_id=$architecture +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# 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 #================================================= @@ -124,52 +128,29 @@ 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..." - -# setup application config -cp "../conf/config.ini" "$final_path/config.ini" - -ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$final_path/config.ini" -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$final_path/config.ini" -ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$final_path/config.ini" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.ini" -ynh_replace_string --match_string="__DOMAIN_URL__" --replace_string="https://$domain" --target_file="$final_path/config.ini" -ynh_replace_string --match_string="__SINGLEUSER__" --replace_string="$single_user" --target_file="$final_path/config.ini" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config.ini" - #================================================= # MAKE SETUP #================================================= ynh_script_progression --message="Making setup..." -chown -R "$app":"$app" "$final_path" - pushd $final_path sudo -u $app ./writefreely --init-db sudo -u $app ./writefreely --gen-keys sudo -u $app ./writefreely --create-admin "$admin":"$password" popd +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a config file..." + +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" + +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" + #================================================= # 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" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/remove b/scripts/remove index 29e310c..6d6f045 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `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 integration..." @@ -62,9 +62,9 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= diff --git a/scripts/restore b/scripts/restore index 8eb8358..086ae0e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# 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 @@ -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 @@ -48,17 +48,10 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." 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..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -68,12 +61,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring user rights..." +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R "$app":"$app" "$final_path" +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 2a07d1c..66e951e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -78,7 +78,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 @@ -93,6 +93,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Write Freely" +#================================================= +# 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 #================================================= @@ -105,6 +113,10 @@ then ynh_setup_source --dest_dir="$final_path" --source_id=$architecture fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -113,14 +125,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# 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 #================================================= @@ -145,25 +149,17 @@ ynh_script_progression --message="Upgrading systemd configuration..." ynh_add_systemd_config #================================================= -# STORE THE CONFIG FILE CHECKSUM +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Storing the config file checksum..." +ynh_script_progression --message="Adding a config file..." -ynh_backup_if_checksum_is_different --file="$final_path/config.ini" +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config.ini" +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" #================================================= # 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" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From 5e5478702a55853b134fdfa1d34888c460268667 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 21:23:04 +0200 Subject: [PATCH 03/13] upgrade version --- check_process | 4 ++++ manifest.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index e6495d4..6ec5656 100644 --- a/check_process +++ b/check_process @@ -21,6 +21,8 @@ upgrade=1 from_commit=4b7c851074c4e785c414944905a8cfb2a0d19ff1 # 0.12.0~ynh3 upgrade=1 from_commit=5ac207e14985bda77dc797353902548696622b41 + # 0.12.0~ynh4 + upgrade=1 from_commit=d75ccbc460b04ef95f3d8b1a72ee77fc7815c6a2 backup_restore=1 multi_instance=1 port_already_use=0 @@ -37,3 +39,5 @@ Notification=all name=0.12.0~ynh1 ; commit=5ac207e14985bda77dc797353902548696622b41 name=0.12.0~ynh3 + ; commit=d75ccbc460b04ef95f3d8b1a72ee77fc7815c6a2 + name=0.12.0~ynh4 diff --git a/manifest.json b/manifest.json index 58aeac0..7106ce3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "For starting a minimalist, federated blog — or an entire community.", "fr": "Permet de créer un blog fédéré minimaliste ou une communauté entière." }, - "version": "0.12.0~ynh4", + "version": "0.12.0~ynh5", "url": "https://writefreely.org", "license": "AGPL-3.0-or-later", "maintainer": { From 0ea90f954d9b086637973c0e4922514a1331dfd6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:08:53 +0200 Subject: [PATCH 04/13] Update change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index d919a20..e946b47 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -95,7 +95,7 @@ then ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location From d54fa52e331ea33c52ff8ea30740f2415e1e9fda Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:08:56 +0200 Subject: [PATCH 05/13] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 66e951e..eb304bb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,7 +70,7 @@ if ! ynh_permission_exists --permission="api"; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." From 7e5658dae6bf1cb9c43f5a495ce42e1c37821b01 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 02:10:23 +0200 Subject: [PATCH 06/13] Update install --- scripts/install | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index f127e3b..21c6977 100755 --- a/scripts/install +++ b/scripts/install @@ -128,6 +128,16 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a config file..." + +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" + +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" + #================================================= # MAKE SETUP #================================================= @@ -139,16 +149,6 @@ pushd $final_path sudo -u $app ./writefreely --create-admin "$admin":"$password" popd -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a config file..." - -ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" - -chmod 400 "$final_path/config.ini" -chown $app:$app "$final_path/config.ini" - #================================================= # GENERIC FINALIZATION #================================================= From d4057e34451c57f579451c72ac4212fb0386c27b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 17:57:35 +0200 Subject: [PATCH 07/13] Update upgrade --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index eb304bb..ae43814 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,7 +70,7 @@ if ! ynh_permission_exists --permission="api"; then fi #================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." @@ -149,9 +149,9 @@ ynh_script_progression --message="Upgrading systemd configuration..." ynh_add_systemd_config #================================================= -# ADD A CONFIGURATION +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Adding a config file..." +ynh_script_progression --message="Updating a config file..." ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" From ecabf6160ba8e3dd751b8bb185d3b3f5f6b80c5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 22:07:52 +0200 Subject: [PATCH 08/13] Fix rights --- scripts/install | 18 +++++++++--------- scripts/restore | 2 +- scripts/upgrade | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/install b/scripts/install index 21c6977..87dbb19 100755 --- a/scripts/install +++ b/scripts/install @@ -108,7 +108,7 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$architecture chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -120,14 +120,6 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # ADD A CONFIGURATION #================================================= @@ -138,6 +130,14 @@ ynh_add_config --template="../conf/config.ini" --destination="$final_path/config chmod 400 "$final_path/config.ini" chown $app:$app "$final_path/config.ini" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # MAKE SETUP #================================================= diff --git a/scripts/restore b/scripts/restore index 086ae0e..c2dddff 100755 --- a/scripts/restore +++ b/scripts/restore @@ -69,7 +69,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index ae43814..a5b58c8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,7 +115,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -140,14 +140,6 @@ pushd $final_path sudo -u $app ./writefreely --migrate popd -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -158,6 +150,14 @@ ynh_add_config --template="../conf/config.ini" --destination="$final_path/config chmod 400 "$final_path/config.ini" chown $app:$app "$final_path/config.ini" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= From 9321a98f1bcb43ef36c0cd0e677b09c475150620 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Apr 2021 01:41:08 +0200 Subject: [PATCH 09/13] Fix db_pwd missing --- scripts/restore | 2 +- scripts/upgrade | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index c2dddff..bd56f6e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -78,7 +79,6 @@ chown -R $app:$app "$final_path" #================================================= ynh_script_progression --message="Restoring the MySQL database..." -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql diff --git a/scripts/upgrade b/scripts/upgrade index a5b58c8..4f84902 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,6 @@ source _common.sh source ynh_detect_arch__2 -source ynh_check_app_version_changed source /usr/share/yunohost/helpers #================================================= @@ -23,6 +22,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) port=$(ynh_app_setting_get --app=$app --key=port) architecture=$(ynh_detect_arch) From bd631cac6ac920d7988ce70d58923081e7a9058d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 14 Apr 2021 20:43:00 +0200 Subject: [PATCH 10/13] Fix Variable $single_user wasn't initialized --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 4f84902..e4e1ebf 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) port=$(ynh_app_setting_get --app=$app --key=port) +single_user=$(ynh_app_setting_get --app=$app --key=single_user) architecture=$(ynh_detect_arch) From fd8ce98928d522c442006587fa2df3079ffb7dcf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:30:19 +0200 Subject: [PATCH 11/13] Fix chmod --- 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 87dbb19..c4d1a00 100755 --- a/scripts/install +++ b/scripts/install @@ -106,7 +106,7 @@ 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" --source_id=$architecture -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index bd56f6e..a069d7f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index e4e1ebf..b83d248 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,7 +115,7 @@ then ynh_setup_source --dest_dir="$final_path" --source_id=$architecture fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 963e66d95aac264cf14987a5077592a0afd8623f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:32:45 +0200 Subject: [PATCH 12/13] Fix recursive chmod --- 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 c4d1a00..87dbb19 100755 --- a/scripts/install +++ b/scripts/install @@ -106,7 +106,7 @@ 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" --source_id=$architecture -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index a069d7f..bd56f6e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index b83d248..e4e1ebf 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,7 +115,7 @@ then ynh_setup_source --dest_dir="$final_path" --source_id=$architecture fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 15701c06cce484c65d209608f34a35b3d1424e68 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:54:56 +0200 Subject: [PATCH 13/13] Fix rights --- 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 87dbb19..f594294 100755 --- a/scripts/install +++ b/scripts/install @@ -108,7 +108,7 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$architecture chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index bd56f6e..11b8ae4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index e4e1ebf..051fa7f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -117,7 +117,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION