From ae1791160a1d5a7a7b4f4b329b775459f46f5bae Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Mon, 28 May 2018 10:54:38 +0200
Subject: [PATCH 01/18] Create pull_request_template.md
Duplicated from https://github.com/YunoHost-Apps/searx_ynh/pull/35, merged as a micro decision
---
pull_request_template.md | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 pull_request_template.md
diff --git a/pull_request_template.md b/pull_request_template.md
new file mode 100644
index 0000000..79238c6
--- /dev/null
+++ b/pull_request_template.md
@@ -0,0 +1,25 @@
+## Problem
+- *Description of why you made this PR*
+
+## Solution
+- *And how you fix that*
+
+## PR Status
+- [ ] Code finished.
+- [ ] Tested with Package_check.
+- [ ] Fix or enhancement tested.
+- [ ] Upgrade from last version tested.
+- [ ] Can be reviewed and tested.
+
+## Validation
+---
+*Minor decision*
+- **Upgrade previous version** :
+- [ ] **Code review** :
+- [ ] **Approval (LGTM)** :
+- [ ] **Approval (LGTM)** :
+- **CI succeeded** :
+[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/my_webapp_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.*
+or
+[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/my_webapp_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.*
+When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.
From 803e8ff4a60314a7e223a9f9ed9224dc578bb3ed Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 03:32:55 +0100
Subject: [PATCH 02/18] Apply example_Ynh to solve CI error:
https://travis-ci.org/YunoHost-Apps/my_webapp_ynh/builds/481615933?utm_source=github_status&utm_medium=notification
---
README.md | 7 ++++--
conf/nginx.conf | 12 +++++++---
manifest.json | 18 +++++++-------
scripts/backup | 19 +++++++++------
scripts/install | 63 ++++++++++++++++++++++++++++++++++++++++---------
scripts/remove | 9 ++++---
scripts/restore | 19 +++++++++------
scripts/upgrade | 21 ++++++++++++++---
8 files changed, 123 insertions(+), 45 deletions(-)
diff --git a/README.md b/README.md
index a37e805..4f7d99f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
-Custom Webapp
--------------
+# Custom Webapp
+
+[](https://ci-apps.yunohost.org/jenkins/job/my_webapp%20%28Community%29/lastBuild/consoleFull)
+[](https://install-app.yunohost.org/?app=my_webapp)
+
Empty application with SFTP access to the Web directory.
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 2d343ab..c69065d 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,6 +1,10 @@
-location __PATH__ {
- alias __FINALPATH__/www/;
-
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
+location __PATH__/ {
+
+ # Path to source
+ alias __FINALPATH__/www/ ;
+
+ # Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
@@ -29,12 +33,14 @@ location __PATH__ {
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
+
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
+### End of PHP configuration part
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
diff --git a/manifest.json b/manifest.json
index 1152e2a..4da5d54 100644
--- a/manifest.json
+++ b/manifest.json
@@ -42,15 +42,6 @@
"example": "/site",
"default": "/site"
},
- {
- "name": "password",
- "type": "password",
- "ask": {
- "en": "Set the password for the SFTP access. ≥ 5 character",
- "fr": "Définissez le mot de passe pour l'accès SFTP. ≥ cinq charactères"
- },
- "example": "myreallystrengthpassword"
- },
{
"name": "is_public",
"type": "boolean",
@@ -60,6 +51,15 @@
},
"default": true
},
+ {
+ "name": "password",
+ "type": "password",
+ "ask": {
+ "en": "Set the password for the SFTP access. ≥ 5 character",
+ "fr": "Définissez le mot de passe pour l'accès SFTP. ≥ cinq charactères"
+ },
+ "example": "myreallystrengthpassword"
+ },
{
"name": "with_mysql",
"type": "boolean",
diff --git a/scripts/backup b/scripts/backup
index 13b9193..be17d69 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -2,19 +2,24 @@
#=================================================
# GENERIC START
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit on command errors and treat access to unset variables as an error
-set -eu
-
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
+source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
+#=================================================
+# MANAGE SCRIPT FAILURE
+#=================================================
+
+ynh_clean_setup () {
+ ### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
#=================================================
# LOAD SETTINGS
#=================================================
diff --git a/scripts/install b/scripts/install
index 9b32084..4369898 100644
--- a/scripts/install
+++ b/scripts/install
@@ -6,12 +6,17 @@
# IMPORT GENERIC HELPERS
#=================================================
+source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
+ynh_clean_setup () {
+ ### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -21,10 +26,21 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
-password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
+password=$YNH_APP_ARG_PASSWORD
+
with_mysql=$YNH_APP_ARG_WITH_MYSQL
+### If it's a multi-instance app, meaning it can be installed several times independently
+### The id of the app as stated in the manifest is available as $YNH_APP_ID
+### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
+### The app instance name is available as $YNH_APP_INSTANCE_NAME
+### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
+### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
+### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
+### The app instance name is probably what interests you most, since this is
+### guaranteed to be unique. This is a good unique identifier to define installation path,
+### db names, ...
app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER
@@ -32,6 +48,8 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
+### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
+### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@@ -66,6 +84,15 @@ ynh_app_setting_set $app final_path $final_path
# CREATE A MYSQL DATABASE
#=================================================
+### Use these lines if you need a database for the application.
+### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
+### The password will be stored as 'mysqlpwd' into the app settings,
+### and will be available as $db_pwd
+### If you're not using these lines:
+### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
+### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
+### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
+
if [ $with_mysql -eq 1 ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
@@ -76,6 +103,8 @@ fi
# NGINX CONFIGURATION
#=================================================
+### `ynh_add_nginx_config` will use the file conf/nginx.conf
+
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -83,16 +112,24 @@ ynh_add_nginx_config
# CREATE DEDICATED USER
#=================================================
-# Create a standard user (not a system user for sftp)
-ynh_system_user_exists "$user" || \
- useradd -d "$final_path" -M --user-group "$user"
-# Add the password to this user
-chpasswd <<< "${user}:${password}"
+# Create a system user
+ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
+### `ynh_add_fpm_config` is used to set up a PHP config.
+### You can remove it if your app doesn't use PHP.
+### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
+### If you're not using these lines:
+### - You can remove these files in conf/.
+### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
+### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
+### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
+### With the reload at the end of the script.
+### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
+
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
ynh_add_fpm_config
@@ -117,9 +154,12 @@ Match User ${user}
systemctl reload ssh
#=================================================
-# FILL AND COPY SOURCE FILES
+# MODIFY A CONFIG FILE
#=================================================
+### `ynh_replace_string` is used to replace a string in a file.
+### (It's compatible with sed regular expressions syntax)
+
ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
ynh_replace_string "{USER}" "$user" ../sources/www/index.html
@@ -138,11 +178,12 @@ cp -r ../sources "$final_path"
# SECURE FILES AND DIRECTORIES
#=================================================
+### For security reason, any app should set the permissions to root: before anything else.
+### Then, if write authorization is needed, any access should be given only to directories
+### that really need such authorization.
+
# Set permissions to app files
-chown -R $user: "$final_path"
-# Home directory of the user needs to be owned by root to allow
-# SFTP connections
-chown root: "$final_path"
+chown -R root: $final_path
#=================================================
# SETUP SSOWAT
diff --git a/scripts/remove b/scripts/remove
index 83e2ef3..05d2085 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
+source _common.sh
source /usr/share/yunohost/helpers
#=================================================
@@ -15,10 +16,12 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
+
+db_name=$(ynh_app_setting_get $app db_name)
+db_user=$db_name
+final_path=$(ynh_app_setting_get $app final_path)
with_mysql=$(ynh_app_setting_get $app with_mysql)
user=$(ynh_app_setting_get $app user)
-db_name=$(ynh_app_setting_get $app db_name)
-final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# STANDARD REMOVE
@@ -28,7 +31,7 @@ final_path=$(ynh_app_setting_get $app final_path)
if [ $with_mysql -eq 1 ]; then
# Remove a database if it exists, along with the associated user
- ynh_mysql_remove_db $db_name $db_name
+ ynh_mysql_remove_db $db_user $db_name
fi
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 6c5a219..dca448d 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -2,19 +2,24 @@
#=================================================
# GENERIC START
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit on command errors and treat access to unset variables as an error
-set -eu
-
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
+source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
+#=================================================
+# MANAGE SCRIPT FAILURE
+#=================================================
+
+ynh_clean_setup () {
+ #### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
#=================================================
# LOAD SETTINGS
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index abacad4..0ecf32b 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
+source _common.sh
source /usr/share/yunohost/helpers
#=================================================
@@ -16,8 +17,10 @@ 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)
+
db_name=$(ynh_app_setting_get $app db_name)
with_mysql=$(ynh_app_setting_get $app with_mysql)
password=$(ynh_app_setting_get $app password)
@@ -36,6 +39,15 @@ https://github.com/YunoHost-Apps/my_webapp_ynh#upgrade"
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
+# Fix is_public as a boolean value
+if [ "$is_public" = "Yes" ]; then
+ ynh_app_setting_set $app is_public 1
+ is_public=1
+elif [ "$is_public" = "No" ]; then
+ ynh_app_setting_set $app is_public 0
+ is_public=0
+fi
+
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
@@ -52,11 +64,14 @@ fi
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
-ynh_backup_before_upgrade # Backup the current version of the app
+# Backup the current version of the app
+ynh_backup_before_upgrade
ynh_clean_setup () {
- ynh_restore_upgradebackup # restore it if the upgrade fails
+ # restore it if the upgrade fails
+ ynh_restore_upgradebackup
}
-ynh_abort_if_errors # Exit if an error occurs during the execution of the script
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
#=================================================
# CHECK THE PATH
From 88d6867da5f8ef538fa695cb65aff9b0a8a2441e Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 03:35:52 +0100
Subject: [PATCH 03/18] Correct licence for [YEP-1.3]
---
manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/manifest.json b/manifest.json
index 4da5d54..b83a737 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,7 +8,7 @@
},
"version": "1.0",
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
- "license": "GPLv3",
+ "license": "GPL-3.0-only",
"maintainer": {
"name": "YunoHost Contributors",
"email": "apps@yunohost.org"
From d4227ddd74ab9dc0619f063e884a72665f48b6af Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 03:53:40 +0100
Subject: [PATCH 04/18] adding addition exmaple_ynh files
---
scripts/_common.sh | 13 ++++++
scripts/change_url | 102 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 115 insertions(+)
create mode 100644 scripts/_common.sh
create mode 100644 scripts/change_url
diff --git a/scripts/_common.sh b/scripts/_common.sh
new file mode 100644
index 0000000..bb04a03
--- /dev/null
+++ b/scripts/_common.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# ============= FUTURE YUNOHOST HELPER =============
+# Delete a file checksum from the app settings
+#
+# $app should be defined when calling this helper
+#
+# usage: ynh_remove_file_checksum file
+# | arg: file - The file for which the checksum will be deleted
+ynh_delete_file_checksum () {
+ local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
+ ynh_app_setting_delete $app $checksum_setting_name
+}
\ No newline at end of file
diff --git a/scripts/change_url b/scripts/change_url
new file mode 100644
index 0000000..f71fc77
--- /dev/null
+++ b/scripts/change_url
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source _common.sh
+source /usr/share/yunohost/helpers
+
+#=================================================
+# RETRIEVE ARGUMENTS
+#=================================================
+
+old_domain=$YNH_APP_OLD_DOMAIN
+old_path=$YNH_APP_OLD_PATH
+
+new_domain=$YNH_APP_NEW_DOMAIN
+new_path=$YNH_APP_NEW_PATH
+
+app=$YNH_APP_INSTANCE_NAME
+
+#=================================================
+# LOAD SETTINGS
+#=================================================
+
+# Needed for helper "ynh_add_nginx_config"
+final_path=$(ynh_app_setting_get $app final_path)
+
+# Add settings here as needed by your application
+#db_name=$(ynh_app_setting_get "$app" db_name)
+#db_pwd=$(ynh_app_setting_get $app db_pwd)
+
+#=================================================
+# CHECK THE SYNTAX OF THE PATHS
+#=================================================
+
+test -n "$old_path" || old_path="/"
+test -n "$new_path" || new_path="/"
+new_path=$(ynh_normalize_url_path $new_path)
+old_path=$(ynh_normalize_url_path $old_path)
+
+#=================================================
+# CHECK WHICH PARTS SHOULD BE CHANGED
+#=================================================
+
+change_domain=0
+if [ "$old_domain" != "$new_domain" ]
+then
+ change_domain=1
+fi
+
+change_path=0
+if [ "$old_path" != "$new_path" ]
+then
+ change_path=1
+fi
+
+#=================================================
+# STANDARD MODIFICATIONS
+#=================================================
+# MODIFY URL IN NGINX CONF
+#=================================================
+
+nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
+
+# 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
+ ynh_backup_if_checksum_is_different "$nginx_conf_path"
+ # Set global variables for nginx helper
+ domain="$old_domain"
+ path_url="$new_path"
+ # Create a dedicated nginx config
+ ynh_add_nginx_config
+fi
+
+# Change the domain for nginx
+if [ $change_domain -eq 1 ]
+then
+ # Delete file checksum for the old conf file location
+ ynh_delete_file_checksum "$nginx_conf_path"
+ mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
+ # Store file checksum for the new config file location
+ ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
+fi
+
+#=================================================
+# SPECIFIC MODIFICATIONS
+#=================================================
+# ...
+#=================================================
+
+#=================================================
+# GENERIC FINALISATION
+#=================================================
+# RELOAD NGINX
+#=================================================
+
+systemctl reload nginx
From 18916f692b636b67bd631113b46e2d82dd6cb143 Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 04:31:01 +0100
Subject: [PATCH 05/18] Fix installation
---
scripts/install | 9 +++++----
scripts/remove | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/scripts/install b/scripts/install
index 4369898..f4aac7f 100644
--- a/scripts/install
+++ b/scripts/install
@@ -103,8 +103,6 @@ fi
# NGINX CONFIGURATION
#=================================================
-### `ynh_add_nginx_config` will use the file conf/nginx.conf
-
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -112,8 +110,11 @@ ynh_add_nginx_config
# CREATE DEDICATED USER
#=================================================
-# Create a system user
-ynh_system_user_create $app
+# Create a standard user (not a system user for sftp)
+ynh_system_user_exists "$user" || \
+ useradd -d "$final_path" -M --user-group "$user"
+# Add the password to this user
+chpasswd <<< "${user}:${password}"
#=================================================
# PHP-FPM CONFIGURATION
diff --git a/scripts/remove b/scripts/remove
index 05d2085..86affea 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -25,6 +25,31 @@ user=$(ynh_app_setting_get $app user)
#=================================================
# STANDARD REMOVE
+#=================================================
+# STOP AND REMOVE SERVICE
+#=================================================
+
+# Remove the dedicated systemd config
+ynh_remove_systemd_config
+
+#=================================================
+# REMOVE SERVICE FROM ADMIN PANEL
+#=================================================
+
+# Remove a service from the admin panel, added by `yunohost service add`
+if yunohost service status | grep -q $app
+then
+ echo "Remove $app service"
+ yunohost service remove $app
+fi
+
+#=================================================
+# REMOVE DEPENDENCIES
+#=================================================
+
+# Remove metapackage and its dependencies
+ynh_remove_app_dependencies
+
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
From b0a9db465b5e2073489987a31814e9b3a16cdcc8 Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 05:07:11 +0100
Subject: [PATCH 06/18] Fix install
---
scripts/install | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/scripts/install b/scripts/install
index f4aac7f..5791a3b 100644
--- a/scripts/install
+++ b/scripts/install
@@ -103,6 +103,8 @@ fi
# NGINX CONFIGURATION
#=================================================
+### `ynh_add_nginx_config` will use the file conf/nginx.conf
+
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -186,6 +188,22 @@ cp -r ../sources "$final_path"
# Set permissions to app files
chown -R root: $final_path
+#=================================================
+# 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"
+
#=================================================
# SETUP SSOWAT
#=================================================
From 14373bc73c764c1f7ee297a17fbebaca23b5ead1 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sat, 19 Jan 2019 13:34:47 +0100
Subject: [PATCH 07/18] Clean scripts
---
check_process | 2 +-
manifest.json | 20 +++++++-------
scripts/backup | 4 ---
scripts/install | 69 ++++---------------------------------------------
scripts/remove | 29 ++-------------------
scripts/restore | 4 ---
scripts/upgrade | 2 --
7 files changed, 18 insertions(+), 112 deletions(-)
diff --git a/check_process b/check_process
index a270ddb..0250537 100644
--- a/check_process
+++ b/check_process
@@ -17,7 +17,7 @@
multi_instance=1
incorrect_path=1
port_already_use=0
- change_url=0
+ change_url=1
;;; Levels
Level 1=auto
Level 2=auto
diff --git a/manifest.json b/manifest.json
index b83a737..39c1d6f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,7 +8,7 @@
},
"version": "1.0",
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
- "license": "GPL-3.0-only",
+ "license": "free",
"maintainer": {
"name": "YunoHost Contributors",
"email": "apps@yunohost.org"
@@ -42,15 +42,6 @@
"example": "/site",
"default": "/site"
},
- {
- "name": "is_public",
- "type": "boolean",
- "ask": {
- "en": "Is it a public website?",
- "fr": "Est-ce un site public ?"
- },
- "default": true
- },
{
"name": "password",
"type": "password",
@@ -60,6 +51,15 @@
},
"example": "myreallystrengthpassword"
},
+ {
+ "name": "is_public",
+ "type": "boolean",
+ "ask": {
+ "en": "Is it a public website?",
+ "fr": "Est-ce un site public ?"
+ },
+ "default": true
+ },
{
"name": "with_mysql",
"type": "boolean",
diff --git a/scripts/backup b/scripts/backup
index be17d69..c493122 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
-ynh_clean_setup () {
- ### Remove this function if there's nothing to clean before calling the remove script.
- true
-}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
diff --git a/scripts/install b/scripts/install
index 5791a3b..e4bb733 100644
--- a/scripts/install
+++ b/scripts/install
@@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
-ynh_clean_setup () {
- ### Remove this function if there's nothing to clean before calling the remove script.
- true
-}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -26,21 +22,11 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
-is_public=$YNH_APP_ARG_IS_PUBLIC
password=$YNH_APP_ARG_PASSWORD
+is_public=$YNH_APP_ARG_IS_PUBLIC
with_mysql=$YNH_APP_ARG_WITH_MYSQL
-### If it's a multi-instance app, meaning it can be installed several times independently
-### The id of the app as stated in the manifest is available as $YNH_APP_ID
-### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
-### The app instance name is available as $YNH_APP_INSTANCE_NAME
-### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
-### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
-### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
-### The app instance name is probably what interests you most, since this is
-### guaranteed to be unique. This is a good unique identifier to define installation path,
-### db names, ...
app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER
@@ -48,8 +34,6 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
-### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
-### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@@ -84,15 +68,6 @@ ynh_app_setting_set $app final_path $final_path
# CREATE A MYSQL DATABASE
#=================================================
-### Use these lines if you need a database for the application.
-### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
-### The password will be stored as 'mysqlpwd' into the app settings,
-### and will be available as $db_pwd
-### If you're not using these lines:
-### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
-### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
-### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
-
if [ $with_mysql -eq 1 ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
@@ -103,8 +78,6 @@ fi
# NGINX CONFIGURATION
#=================================================
-### `ynh_add_nginx_config` will use the file conf/nginx.conf
-
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -122,17 +95,6 @@ chpasswd <<< "${user}:${password}"
# PHP-FPM CONFIGURATION
#=================================================
-### `ynh_add_fpm_config` is used to set up a PHP config.
-### You can remove it if your app doesn't use PHP.
-### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
-### If you're not using these lines:
-### - You can remove these files in conf/.
-### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
-### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
-### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
-### With the reload at the end of the script.
-### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
-
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
ynh_add_fpm_config
@@ -160,9 +122,6 @@ systemctl reload ssh
# MODIFY A CONFIG FILE
#=================================================
-### `ynh_replace_string` is used to replace a string in a file.
-### (It's compatible with sed regular expressions syntax)
-
ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
ynh_replace_string "{USER}" "$user" ../sources/www/index.html
@@ -181,28 +140,10 @@ cp -r ../sources "$final_path"
# SECURE FILES AND DIRECTORIES
#=================================================
-### For security reason, any app should set the permissions to root: before anything else.
-### Then, if write authorization is needed, any access should be given only to directories
-### that really need such authorization.
-
-# Set permissions to app files
-chown -R root: $final_path
-
-#=================================================
-# 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"
+chown -R $user: "$final_path"
+# Home directory of the user needs to be owned by root to allow
+# SFTP connections
+chown root: "$final_path"
#=================================================
# SETUP SSOWAT
diff --git a/scripts/remove b/scripts/remove
index 86affea..8fa7fb4 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -16,40 +16,15 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
+with_mysql=$(ynh_app_setting_get $app with_mysql)
+user=$(ynh_app_setting_get $app user)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
-with_mysql=$(ynh_app_setting_get $app with_mysql)
-user=$(ynh_app_setting_get $app user)
#=================================================
# STANDARD REMOVE
-#=================================================
-# STOP AND REMOVE SERVICE
-#=================================================
-
-# Remove the dedicated systemd config
-ynh_remove_systemd_config
-
-#=================================================
-# REMOVE SERVICE FROM ADMIN PANEL
-#=================================================
-
-# Remove a service from the admin panel, added by `yunohost service add`
-if yunohost service status | grep -q $app
-then
- echo "Remove $app service"
- yunohost service remove $app
-fi
-
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
-
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
diff --git a/scripts/restore b/scripts/restore
index dca448d..b2c873b 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
-ynh_clean_setup () {
- #### Remove this function if there's nothing to clean before calling the remove script.
- true
-}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
diff --git a/scripts/upgrade b/scripts/upgrade
index 0ecf32b..2c8e690 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -17,10 +17,8 @@ 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)
-
db_name=$(ynh_app_setting_get $app db_name)
with_mysql=$(ynh_app_setting_get $app with_mysql)
password=$(ynh_app_setting_get $app password)
From 06d1b5a5c562e9e9d053dfa18ca3710f5e652528 Mon Sep 17 00:00:00 2001
From: Yalh
Date: Sat, 19 Jan 2019 19:11:54 +0100
Subject: [PATCH 08/18] Removing deprecated ynh_webpath_available
---
scripts/install | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index e4bb733..647cbf1 100644
--- a/scripts/install
+++ b/scripts/install
@@ -44,8 +44,6 @@ 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
# Register (book) web path
ynh_webpath_register $app $domain $path_url
From 53d69b3677ae1f38af20e7503ccc07142d82600c Mon Sep 17 00:00:00 2001
From: yalh76
Date: Mon, 21 Jan 2019 01:22:11 +0100
Subject: [PATCH 09/18] Update links from Jenkins to CI
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4f7d99f..32e6af5 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Custom Webapp
-[](https://ci-apps.yunohost.org/jenkins/job/my_webapp%20%28Community%29/lastBuild/consoleFull)
+[](https://dash.yunohost.org/appci/app/my_webapp)
[](https://install-app.yunohost.org/?app=my_webapp)
From ef16ba21574d0c7d199848b8bcc39d3a61708cb1 Mon Sep 17 00:00:00 2001
From: Alexandre Aubin
Date: Mon, 28 Jan 2019 18:09:05 +0100
Subject: [PATCH 10/18] Update README
- Rework some explaination about the whole SFTP thing + add link to FileZilla doc
- Remove section about update (too old ?) and backup/restore (now integrated with the usual scripts)
---
README.md | 51 +++++++--------------------------------------------
1 file changed, 7 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index a37e805..edc962f 100644
--- a/README.md
+++ b/README.md
@@ -6,55 +6,18 @@ Empty application with SFTP access to the Web directory.
## Overview
This application allows you to easily install a custom Web application,
-providing files access with SFTP. It can also create a MySQL database -
+providing files access with [SFTP](https://yunohost.org/#/filezilla). It can also create a MySQL database -
which will be backed up and restored with your application. The connection
details will be stored in the file `db_accesss.txt` located in the root
directory.
-Once installed, go to the chosen URL to know the user, domain and port
-you will have to use for the SFTP access - the password is one you give
-at the installation. Under the Web directory, you will see a `www` folder
-which is the public and served one. You can put all the files of your
-custom Web application inside.
+**Once installed, go to the chosen URL to know the user, domain and port
+you will have to use for the SFTP access.** The password is one you chosen
+during the installation. Under the Web directory, you will see a `www` folder
+which contains the public files served by this app. You can put all the files
+of your custom Web application inside.
-## Upgrade
-
-Due to the SFTP access change, the upgrade can not be done from the last
-`my_webapp` application - provided with YunoHost 2.2. You will have to remove
-it first and install this new one, taking care of migrating your data.
-
-### Save your files and the database
-
-You will have to save the content of the `/var/www/my_webapp/files`
-directory, either from the Web admin interface provided by the old app or
-connecting to your server using SSH - or SFTP as `admin`.
-
-If you've created a MySQL database, you can also migrate it since the new
-version allows to manage it for you. To create a dump, you could either use
-[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
-your server and execute:
-`mysqldump -u root -p$(cat /etc/yunohost/mysql --no-create-db "$dbname" > ./dump.sql`
-(do not forget to replace `$dbname` by your database name).
-
-### Restore your custom Webapp
-
-When you've taken care of saving your files - and optionally your database,
-you can remove the app and install this new one. You can set the same
-settings as the previous installation.
-
-To restore your files, connect to the Web directory using the SFTP account - as
-described at the installation path - and put everything into the `www` directory.
-
-If you have chosen to migrate your database too, open the file `db_access.txt`
-to know the new database, user and password you will have to set in your app
-configuration. You can restore the dump you've created earlier either using
-[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
-your server and execute:
-`mysql -u "$dbuser" -p"$dbpass" "$dbname" < ./dump.sql`
-(do not forget to replace `$dbuser`, `$dbpass` and `$dbname` with the values
-given in the file).
-
-### SFTP port ###
+### SFTP port
You may have change the SSH port as described
[here (section "Modifier le port SSH"](https://yunohost.org/#/security_fr) ;
From 034e5fc83c8515d2a7781548600ab82b44c8611b Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sat, 16 Feb 2019 00:39:19 +0100
Subject: [PATCH 11/18] Normalization from example_ynh
---
README.md | 76 +++++++++++++++++++++++-------------------
conf/nginx.conf | 8 +++--
manifest.json | 4 +--
scripts/backup | 14 ++++----
scripts/install | 23 ++++++-------
scripts/restore | 14 ++++----
scripts/upgrade | 20 ++++++++---
sources/www/index.html | 4 +--
8 files changed, 93 insertions(+), 70 deletions(-)
diff --git a/README.md b/README.md
index a37e805..4c8a501 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,10 @@
-Custom Webapp
--------------
+# Custom Webapp for YunoHost
-Empty application with SFTP access to the Web directory.
+[](https://dash.yunohost.org/appci/app/my_webapp)
+[](https://install-app.yunohost.org/?app=my_webapp)
+
+> *This package allow you to install Custom Webapp quickly and simply on a YunoHost server.
+If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
@@ -17,49 +20,54 @@ at the installation. Under the Web directory, you will see a `www` folder
which is the public and served one. You can put all the files of your
custom Web application inside.
-## Upgrade
+**Shipped version:** 1.0
-Due to the SFTP access change, the upgrade can not be done from the last
-`my_webapp` application - provided with YunoHost 2.2. You will have to remove
-it first and install this new one, taking care of migrating your data.
+## Screenshots
-### Save your files and the database
+## Demo
-You will have to save the content of the `/var/www/my_webapp/files`
-directory, either from the Web admin interface provided by the old app or
-connecting to your server using SSH - or SFTP as `admin`.
+## Configuration
-If you've created a MySQL database, you can also migrate it since the new
-version allows to manage it for you. To create a dump, you could either use
-[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
-your server and execute:
-`mysqldump -u root -p$(cat /etc/yunohost/mysql --no-create-db "$dbname" > ./dump.sql`
-(do not forget to replace `$dbname` by your database name).
+## Documentation
-### Restore your custom Webapp
+ * YunoHost documentation: https://github.com/YunoHost/doc/blob/master/app_my_webapp.md
-When you've taken care of saving your files - and optionally your database,
-you can remove the app and install this new one. You can set the same
-settings as the previous installation.
+## YunoHost specific features
-To restore your files, connect to the Web directory using the SFTP account - as
-described at the installation path - and put everything into the `www` directory.
+#### Multi-users support
-If you have chosen to migrate your database too, open the file `db_access.txt`
-to know the new database, user and password you will have to set in your app
-configuration. You can restore the dump you've created earlier either using
-[phpMyAdmin](https://github.com/YunoHost-Apps/phpmyadmin_ynh) or connect to
-your server and execute:
-`mysql -u "$dbuser" -p"$dbpass" "$dbname" < ./dump.sql`
-(do not forget to replace `$dbuser`, `$dbpass` and `$dbname` with the values
-given in the file).
+#### Supported architectures
-### SFTP port ###
+* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/my_webapp/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/my_webapp/)
+* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/my_webapp/)
+
+## Limitations
+
+## Additional information
+
+#### SFTP port
You may have change the SSH port as described
[here (section "Modifier le port SSH"](https://yunohost.org/#/security_fr) ;
then you should use this port to update your website with SFTP.
-## Links
+## Links
-**YunoHost**: https://yunohost.org/
+ * Report a bug: https://github.com/YunoHost-Apps/my_webapp_ynh/issues
+ * YunoHost website: https://yunohost.org/
+
+---
+
+Developers info
+----------------
+
+**Only if you want to use a testing branch for coding, instead of merging directly into master.**
+Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing).
+
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade my_webapp -u https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
+```
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 2d343ab..6cbe641 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,6 +1,10 @@
-location __PATH__ {
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
+location __PATH__/ {
+
+ # Path to source
alias __FINALPATH__/www/;
-
+
+ # Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
diff --git a/manifest.json b/manifest.json
index 1152e2a..3268fdc 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,9 +6,9 @@
"en": "Custom Web app with SFTP access",
"fr": "Application Web personnalisée avec accès SFTP"
},
- "version": "1.0",
+ "version": "1.0~ynh1",
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
- "license": "GPLv3",
+ "license": "GPL-3.0-only",
"maintainer": {
"name": "YunoHost Contributors",
"email": "apps@yunohost.org"
diff --git a/scripts/backup b/scripts/backup
index 13b9193..7edc57f 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -2,19 +2,19 @@
#=================================================
# GENERIC START
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit on command errors and treat access to unset variables as an error
-set -eu
-
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
+#=================================================
+# MANAGE SCRIPT FAILURE
+#=================================================
+
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
#=================================================
# LOAD SETTINGS
#=================================================
diff --git a/scripts/install b/scripts/install
index 9b32084..624655e 100644
--- a/scripts/install
+++ b/scripts/install
@@ -42,8 +42,6 @@ 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
# Register (book) web path
ynh_webpath_register $app $domain $path_url
@@ -89,14 +87,6 @@ ynh_system_user_exists "$user" || \
# Add the password to this user
chpasswd <<< "${user}:${password}"
-#=================================================
-# PHP-FPM CONFIGURATION
-#=================================================
-
-# Create a dedicated php-fpm config
-ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
-ynh_add_fpm_config
-
#=================================================
# SPECIFIC SETUP
#=================================================
@@ -120,8 +110,8 @@ systemctl reload ssh
# FILL AND COPY SOURCE FILES
#=================================================
-ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
-ynh_replace_string "{USER}" "$user" ../sources/www/index.html
+ynh_replace_string "__DOMAIN__" "$domain" ../sources/www/index.html
+ynh_replace_string "__USER__" "$user" ../sources/www/index.html
if [ $with_mysql -eq 1 ]; then
# Store the database access
@@ -132,6 +122,15 @@ fi
# Copy files to the right place
cp -r ../sources "$final_path"
+#=================================================
+# PHP-FPM CONFIGURATION
+#=================================================
+ynh_print_info "Configuring php-fpm..."
+
+# Create a dedicated php-fpm config
+ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
+ynh_add_fpm_config
+
#=================================================
# GENERIC FINALIZATION
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 6c5a219..980286c 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -2,19 +2,19 @@
#=================================================
# GENERIC START
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit on command errors and treat access to unset variables as an error
-set -eu
-
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
+#=================================================
+# MANAGE SCRIPT FAILURE
+#=================================================
+
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
#=================================================
# LOAD SETTINGS
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index abacad4..5f70cba 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -36,6 +36,15 @@ https://github.com/YunoHost-Apps/my_webapp_ynh#upgrade"
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
+# Fix is_public as a boolean value
+if [ "$is_public" = "Yes" ]; then
+ ynh_app_setting_set $app is_public 1
+ is_public=1
+elif [ "$is_public" = "No" ]; then
+ ynh_app_setting_set $app is_public 0
+ is_public=0
+fi
+
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
@@ -52,11 +61,14 @@ fi
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
-ynh_backup_before_upgrade # Backup the current version of the app
+# Backup the current version of the app
+ynh_backup_before_upgrade
ynh_clean_setup () {
- ynh_restore_upgradebackup # restore it if the upgrade fails
+ # restore it if the upgrade fails
+ ynh_restore_upgradebackup
}
-ynh_abort_if_errors # Exit if an error occurs during the execution of the script
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
#=================================================
# CHECK THE PATH
@@ -130,7 +142,7 @@ fi
#=================================================
# Remove the previous config for upgrading it
-sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
+sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
# Harden SSH connection for the user
echo "##-> ${app}
# Hardening user connection
diff --git a/sources/www/index.html b/sources/www/index.html
index cb0cf2f..051a429 100644
--- a/sources/www/index.html
+++ b/sources/www/index.html
@@ -16,11 +16,11 @@
- Domain
- - {DOMAIN}
+ - __DOMAIN__
- Port
- 22 (or the port you defined if you change the ssh port)
- User
- - {USER}
+ - __USER__
- Password
- the one you set at installation
From 0f0bef3b8ca06d8f36f3de90c3502c529a6bc280 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sat, 16 Feb 2019 00:41:43 +0100
Subject: [PATCH 12/18] Use php7
---
conf/nginx.conf | 2 +-
conf/php-fpm.conf | 104 +++++++++++++++++++++++++++++++---------------
manifest.json | 4 +-
scripts/backup | 2 +-
scripts/restore | 4 +-
5 files changed, 77 insertions(+), 39 deletions(-)
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 6cbe641..566126f 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -32,7 +32,7 @@ location __PATH__/ {
# Execute and serve PHP files
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
+ fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf
index 0327114..4447349 100644
--- a/conf/php-fpm.conf
+++ b/conf/php-fpm.conf
@@ -1,10 +1,11 @@
; Start a new pool named 'www'.
-; the variable $pool can we used in any directive and will be replaced by the
+; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[__NAMETOCHANGE__]
; Per pool prefix
; It only applies on the following directives:
+; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
@@ -24,28 +25,35 @@ group = __USER__
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
-; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
+; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
-; 'port' - to listen on a TCP socket to all addresses on a
-; specific port;
+; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
+; a specific port;
+; 'port' - to listen on a TCP socket to all addresses
+; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
-listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
+listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
-; Set listen(2) backlog. A value of '-1' means unlimited.
-; Default Value: 128 (-1 on FreeBSD and OpenBSD)
-;listen.backlog = 128
+; Set listen(2) backlog.
+; Default Value: 511 (-1 on FreeBSD and OpenBSD)
+;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
-; BSD-derived systems allow connections regardless of permissions.
+; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
-
-; List of ipv4 addresses of FastCGI clients which are allowed to connect.
+; When POSIX Access Control Lists are supported you can set them using
+; these options, value is a comma separated list of user/group names.
+; When set, listen.owner and listen.group are ignored
+;listen.acl_users =
+;listen.acl_groups =
+
+; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
@@ -59,7 +67,13 @@ listen.group = www-data
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
-; priority = -19
+; process.priority = -19
+
+; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
+; or group is differrent than the master process user. It allows to create process
+; core dump and ptrace the process for the pool user.
+; Default Value: no
+; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
@@ -96,7 +110,7 @@ pm = dynamic
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
-pm.max_children = 10
+pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
@@ -117,12 +131,12 @@ pm.max_spare_servers = 3
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
-
+
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
-pm.max_requests = 500
+;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
@@ -170,7 +184,7 @@ pm.max_requests = 500
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
-; Example:
+; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
@@ -215,7 +229,7 @@ pm.max_requests = 500
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
-; It's available in: ${prefix}/share/fpm/status.html
+; It's available in: /usr/share/php/7.0/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
@@ -275,7 +289,7 @@ pm.max_requests = 500
; - %{megabytes}M
; - %{mega}M
; %n: pool name
-; %o: ouput header
+; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
@@ -283,7 +297,7 @@ pm.max_requests = 500
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
-; %q: the query string
+; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
@@ -291,47 +305,51 @@ pm.max_requests = 500
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
+; The strftime(3) format must be encapsuled in a %{}t tag
+; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
+; The strftime(3) format must be encapsuled in a %{}t tag
+; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
-
+
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
-slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
-
+;slowlog = log/$pool.log.slow
+
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
-request_slowlog_timeout = 5s
-
+;request_slowlog_timeout = 0
+
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 1d
-
+
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
-
+
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
-
+
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
-; Note: chrooting is a great security feature and should be used whenever
+; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
@@ -347,16 +365,25 @@ chdir = __FINALPATH__
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
-catch_workers_output = yes
+;catch_workers_output = yes
+
+; Clear environment in FPM workers
+; Prevents arbitrary environment variables from reaching FPM worker processes
+; by clearing the environment in workers before env vars specified in this
+; pool configuration are added.
+; Setting to "no" will make all environment variables available to PHP code
+; via getenv(), $_ENV and $_SERVER.
+; Default Value: yes
+;clear_env = no
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
-; exectute php code.
+; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
-;security.limit_extensions = .php .php3 .php4 .php5
-
+;security.limit_extensions = .php .php3 .php4 .php5 .php7
+
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
@@ -370,7 +397,7 @@ catch_workers_output = yes
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
-; be overwritten from PHP call 'ini_set'.
+; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
@@ -391,6 +418,17 @@ catch_workers_output = yes
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
+; Common values to change to increase file upload limit
+; php_admin_value[upload_max_filesize] = 50M
+; php_admin_value[post_max_size] = 50M
+; php_admin_flag[mail.add_x_header] = Off
+
+; Other common parameters
+; php_admin_value[max_execution_time] = 600
+; php_admin_value[max_input_time] = 300
+; php_admin_value[memory_limit] = 256M
+; php_admin_flag[short_open_tag] = On
+
; Additional php.ini defines, specific to this pool of workers.
php_value[upload_max_filesize] = 1G
php_value[post_max_size] = 1G
diff --git a/manifest.json b/manifest.json
index 3268fdc..c5d2d8e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -14,12 +14,12 @@
"email": "apps@yunohost.org"
},
"requirements": {
- "yunohost": ">= 2.7.2"
+ "yunohost": ">= 3.0"
},
"multi_instance": true,
"services": [
"nginx",
- "php5-fpm"
+ "php7.0-fpm"
],
"arguments": {
"install" : [
diff --git a/scripts/backup b/scripts/backup
index 7edc57f..b0eedbe 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -44,7 +44,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
-ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
+ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
diff --git a/scripts/restore b/scripts/restore
index 980286c..8822a76 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -86,7 +86,7 @@ chown root: "$final_path"
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
-ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
+ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
@@ -113,5 +113,5 @@ systemctl reload ssh
# RELOAD NGINX AND PHP-FPM
#=================================================
-systemctl reload php5-fpm
+systemctl reload php7.0-fpm
systemctl reload nginx
From 6fa397587f6edd2ac311e9961ea4ff2705b00d60 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sat, 16 Feb 2019 00:44:14 +0100
Subject: [PATCH 13/18] Give up upgrade from very old version
---
scripts/upgrade | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/scripts/upgrade b/scripts/upgrade
index 5f70cba..91fd49f 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -23,15 +23,6 @@ with_mysql=$(ynh_app_setting_get $app with_mysql)
password=$(ynh_app_setting_get $app password)
user=$(ynh_app_setting_get $app user)
-#=================================================
-# CHECK IF THE UPGRADE CAN BE AUTOMATED
-#=================================================
-
-([[ -n "$with_mysql" ]] && [[ -n "$password" ]] && [[ -n "$user" ]]) \
- || ynh_die "The app changed and can not be automatically upgraded. \
-You will have to manually upgrade it following these instructions: \
-https://github.com/YunoHost-Apps/my_webapp_ynh#upgrade"
-
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
From d5e9add734927395d48bd449b99ac81bd91dd009 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sat, 16 Feb 2019 00:45:30 +0100
Subject: [PATCH 14/18] Use ynh_backup_if_checksum_is_different instead of a
dedicated function
---
scripts/upgrade | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/scripts/upgrade b/scripts/upgrade
index 91fd49f..d042ba2 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -70,32 +70,13 @@ path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
-#=================================================
-
-# Check if a config file was modified
-is_checksum_different () {
- local file=$1
- local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
- local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
- if [ -n "$checksum_value" ]
- then # Proceed only if a value was stored into the app settings
- if ! echo "$checksum_value $file" | sudo md5sum -c --status
- then # If the checksum is now different
- echo "File $file has been manually modified since the installation or last upgrade. So it will not be replaced." >&2
- echo "1"
- else
- echo "0"
- fi
- else
- echo "0"
- fi
-}
-
#=================================================
# NGINX CONFIGURATION
#=================================================
-if [ $(is_checksum_different "/etc/nginx/conf.d/$domain.d/$app.conf") -eq 0 ]
+modified_config=$(ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf")
+# Replace nginx config only if it wasn't modified.
+if [ -z "$modified_config" ]
then
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -119,7 +100,9 @@ usermod -g "$user" "$user"
# PHP-FPM CONFIGURATION
#=================================================
-if [ $(is_checksum_different "/etc/php5/fpm/pool.d/$app.conf") -eq 0 ]
+modified_config=$(ynh_backup_if_checksum_is_different "/etc/php5/fpm/pool.d/$app.conf")
+# Replace nginx config only if it wasn't modified.
+if [ -z "$modified_config" ]
then
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
From 8c2f9fa5c7a6ab90ebbbee4eb4b82ed2be6ee292 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sun, 17 Feb 2019 20:55:53 +0100
Subject: [PATCH 15/18] Add progression with ynh_print_info
---
scripts/backup | 11 +++++++++++
scripts/install | 14 ++++++++++++++
scripts/remove | 14 ++++++++++++++
scripts/restore | 13 +++++++++++++
scripts/upgrade | 15 +++++++++++++++
5 files changed, 67 insertions(+)
diff --git a/scripts/backup b/scripts/backup
index b0eedbe..021bb79 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -18,6 +18,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -31,18 +32,21 @@ with_mysql=$(ynh_app_setting_get $app with_mysql)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
+ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
+ynh_print_info "Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
+ynh_print_info "Backing up php-fpm configuration..."
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
@@ -51,5 +55,12 @@ ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
if [ $with_mysql -eq 1 ]; then
+ ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql
fi
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/install b/scripts/install
index 624655e..f4952f6 100644
--- a/scripts/install
+++ b/scripts/install
@@ -31,6 +31,7 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
+ynh_print_info "Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@@ -48,6 +49,7 @@ ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
+ynh_print_info "Storing installation settings..."
user=webapp${app_nb}
ynh_app_setting_set $app domain $domain
@@ -65,6 +67,7 @@ ynh_app_setting_set $app final_path $final_path
#=================================================
if [ $with_mysql -eq 1 ]; then
+ ynh_print_info "Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
@@ -73,6 +76,7 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@@ -80,6 +84,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_print_info "Configuring system user..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@@ -92,6 +97,7 @@ chpasswd <<< "${user}:${password}"
#=================================================
# CONFIGURE SSH
#=================================================
+ynh_print_info "Configuring ssh..."
# Harden SSH connection for the user
echo "##-> ${app}
@@ -146,6 +152,7 @@ chown root: "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
+ynh_print_info "Configuring SSOwat..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@@ -156,5 +163,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
+ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info "Installation of $app completed"
diff --git a/scripts/remove b/scripts/remove
index 83e2ef3..c909ea9 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -27,6 +28,7 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
if [ $with_mysql -eq 1 ]; then
+ ynh_print_info "Removing the MySQL database"
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name
fi
@@ -34,6 +36,7 @@ fi
#=================================================
# REMOVE APP MAIN DIR
#=================================================
+ynh_print_info "Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@@ -41,6 +44,8 @@ ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
+ynh_print_info "Removing nginx web server configuration"
+
# Remove the dedicated nginx config
ynh_remove_nginx_config
@@ -48,6 +53,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
+ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
@@ -57,6 +63,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE THE CUSTOM SSH CONFIG
#=================================================
+ynh_print_info "Removing the custom ssh config"
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
systemctl reload ssh
@@ -66,6 +73,13 @@ systemctl reload ssh
#=================================================
# REMOVE DEDICATED USER
#=================================================
+ynh_print_info "Removing the dedicated system user"
# Delete an user
ynh_system_user_delete $user
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info "Removal of $app completed"
diff --git a/scripts/restore b/scripts/restore
index 8822a76..efb77e8 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -18,6 +18,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -32,6 +33,7 @@ user=$(ynh_app_setting_get $app user)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
+ynh_print_info "Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
@@ -49,6 +51,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
+ynh_print_info "Restoring the app main directory..."
ynh_restore_file "$final_path"
@@ -57,6 +60,7 @@ ynh_restore_file "$final_path"
#=================================================
if [ $with_mysql -eq 1 ]; then
+ ynh_print_info "Restoring the mysql database..."
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
@@ -65,6 +69,7 @@ fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
+ynh_print_info "Recreating the dedicated system user..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@@ -93,6 +98,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# CONFIGURE SSH
#=================================================
+ynh_print_info "Configuring ssh..."
# Harden SSH connection for the user
echo "##-> ${app}
@@ -112,6 +118,13 @@ systemctl reload ssh
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
+ynh_print_info "Reloading nginx web server and php-fpm..."
systemctl reload php7.0-fpm
systemctl reload nginx
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info "Restoration completed for $app"
diff --git a/scripts/upgrade b/scripts/upgrade
index d042ba2..4a7912f 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -26,6 +27,7 @@ user=$(ynh_app_setting_get $app user)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
+ynh_print_info "Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
@@ -51,6 +53,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
+ynh_print_info "Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@@ -78,6 +81,7 @@ modified_config=$(ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain
# Replace nginx config only if it wasn't modified.
if [ -z "$modified_config" ]
then
+ ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
fi
@@ -85,6 +89,7 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_print_info "Making sure dedicated system user exists..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@@ -104,6 +109,7 @@ modified_config=$(ynh_backup_if_checksum_is_different "/etc/php5/fpm/pool.d/$app
# Replace nginx config only if it wasn't modified.
if [ -z "$modified_config" ]
then
+ ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
ynh_add_fpm_config
@@ -114,6 +120,7 @@ fi
#=================================================
# CONFIGURE SSH
#=================================================
+ynh_print_info "Configuring ssh..."
# Remove the previous config for upgrading it
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
@@ -143,6 +150,7 @@ chown root: "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
+ynh_print_info "Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@@ -153,5 +161,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
+ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info "Upgrade of $app completed"
From 7bae826582232a703e7cc68c26d92372873f189e Mon Sep 17 00:00:00 2001
From: Kayou
Date: Tue, 19 Mar 2019 19:32:57 +0100
Subject: [PATCH 16/18] Remove unnecessary comments
---
scripts/change_url | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/scripts/change_url b/scripts/change_url
index f71fc77..a4eed15 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -28,10 +28,6 @@ app=$YNH_APP_INSTANCE_NAME
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
-# Add settings here as needed by your application
-#db_name=$(ynh_app_setting_get "$app" db_name)
-#db_pwd=$(ynh_app_setting_get $app db_pwd)
-
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
@@ -87,12 +83,6 @@ then
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
-#=================================================
-# SPECIFIC MODIFICATIONS
-#=================================================
-# ...
-#=================================================
-
#=================================================
# GENERIC FINALISATION
#=================================================
From 4f37db1582f79a3d57a8d0a2f598dcea55a09521 Mon Sep 17 00:00:00 2001
From: Kayou
Date: Tue, 19 Mar 2019 19:34:21 +0100
Subject: [PATCH 17/18] Bump version number
---
manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/manifest.json b/manifest.json
index c5d2d8e..a62df13 100644
--- a/manifest.json
+++ b/manifest.json
@@ -14,7 +14,7 @@
"email": "apps@yunohost.org"
},
"requirements": {
- "yunohost": ">= 3.0"
+ "yunohost": ">= 3.2.0"
},
"multi_instance": true,
"services": [
From b4ab39a97cbf8ffc8ff1017cf381cbe28b23ae3f Mon Sep 17 00:00:00 2001
From: Maniack Crudelis
Date: Sun, 24 Mar 2019 16:46:16 +0100
Subject: [PATCH 18/18] Update pull_request_template.md
---
pull_request_template.md | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/pull_request_template.md b/pull_request_template.md
index 79238c6..07fa2bb 100644
--- a/pull_request_template.md
+++ b/pull_request_template.md
@@ -19,7 +19,6 @@
- [ ] **Approval (LGTM)** :
- [ ] **Approval (LGTM)** :
- **CI succeeded** :
-[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/my_webapp_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.*
-or
-[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/my_webapp_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.*
+[](https://ci-apps-dev.yunohost.org/jenkins/job/my_webapp_ynh%20PR-NUM-/)
+*Please replace '-NUM-' in this link by the PR number.*
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.