.
diff --git a/README.md b/README.md
index d94b535..4e76ea8 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,71 @@
-[](https://dash.yunohost.org/appci/app/yourls)  
+# YOURLS for YunoHost
-What is YOURLS?
-YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
+[](https://dash.yunohost.org/appci/app/yourls)  
+[](https://install-app.yunohost.org/?app=yourls)
-Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
-For more information see:https://yourls.org/
-Github:https://github.com/YOURLS/YOURLS
-Version:1.7.6
+*[Lire ce readme en français.](./README_fr.md)*
+
+> *This package allows you to install YOURLS quickly and simply on a YunoHost server.
+If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
+
+## Overview
+YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
+
+**Shipped version:** 1.7.9
+
+## Screenshots
+
+
+
+## Demo
+
+* [Official demo](https://yourls.org/cookie+)
+
+## Configuration
+
+How to configure this app: From an admin panel, a plain file with SSH, or any other way.
+
+## Documentation
+
+ * Official documentation: Link to the official documentation of this app
+ * YunoHost documentation: If specific documentation is needed, feel free to contribute.
+
+## YunoHost specific features
+
+#### Multi-user support
+
+ * Are LDAP and HTTP auth supported?
+ * Can the app be used by multiple users?
+
+#### Supported architectures
+
+* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/yourls/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/yourls/)
+
+## Limitations
+
+* Any known limitations.
+
+## Additional information
+
+* Other info you would like to add about this app.
+
+## Links
+
+ * Report a bug: https://github.com/YunoHost-Apps/yourls_ynh/issues
+ * App website: https://yourls.org/
+ * Upstream app repository: https://github.com/YOURLS/YOURLS
+ * YunoHost website: https://yunohost.org/
+
+---
+
+## Developer info
+
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/yourls_ynh/tree/testing).
+
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade yourls -u https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
+```
diff --git a/README_fr.md b/README_fr.md
new file mode 100644
index 0000000..b053348
--- /dev/null
+++ b/README_fr.md
@@ -0,0 +1,71 @@
+# YOURLS pour YunoHost
+
+[](https://dash.yunohost.org/appci/app/yourls)  
+[](https://install-app.yunohost.org/?app=yourls)
+
+*[Read this readme in english.](./README.md)*
+
+> *Ce package vous permet d'installer YOURLS rapidement et simplement sur un serveur YunoHost.
+Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
+
+## Vue d'ensemble
+YOURLS signifie Your Own URL Shortener. C'est un petit ensemble de scripts PHP qui vous permettront d'exécuter votre propre service de raccourcissement d'URL (à la TinyURL ou bitly).
+
+**Version incluse :** 1.7.9
+
+## Captures d'écran
+
+
+
+## Démo
+
+* [Official demo](https://yourls.org/cookie+)
+
+## Configuration
+
+How to configure this app: From an admin panel, a plain file with SSH, or any other way.
+
+## Documentation
+
+ * Documentation officielle : Lien vers la documentation officielle de cette application.
+ * Documentation YunoHost : Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
+
+## Caractéristiques spécifiques YunoHost
+
+#### Support multi-utilisateur
+
+* L'authentification LDAP et HTTP est-elle prise en charge ?
+* L'application peut-elle être utilisée par plusieurs utilisateurs ?
+
+#### Architectures supportées
+
+* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/yourls/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/yourls/)
+
+## Limitations
+
+* Limitations connues.
+
+## Informations additionnelles
+
+* Autres informations que vous souhaitez ajouter sur cette application.
+
+## Links
+
+ * Signaler un bug : https://github.com/YunoHost-Apps/yourls_ynh/issues
+ * Site de l'application : https://yourls.org/
+ * Dépôt de l'application principale : https://github.com/YOURLS/YOURLS
+ * Site web YunoHost : https://yunohost.org/
+
+---
+
+## Informations pour les développeurs
+
+Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/yourls_ynh/tree/testing).
+
+Pour essayer la branche testing, procédez comme suit.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade yourls -u https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
+```
diff --git a/conf/add_sso_conf.py b/conf/add_sso_conf.py
deleted file mode 100644
index 9bc3bf7..0000000
--- a/conf/add_sso_conf.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import json
-
-with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
- data = json.load(jsonFile)
- if "protected_urls" in data:
- data["protected_urls"].append("__DOMAIN____PATH__/admin")
- else:
- data["protected_urls"] = ["__DOMAIN____PATH__/admin"]
-
-with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
- jsonFile.write(json.dumps(data, indent=4, sort_keys=True))
diff --git a/conf/app.src b/conf/app.src
index e0f21e8..219dac2 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/YOURLS/YOURLS/archive/1.7.6.zip
-SOURCE_SUM=ee17c844b4eb7323e5b22e633631703ded18eef8ed75fc42eb950378fba4f442
+SOURCE_URL=https://github.com/YOURLS/YOURLS/archive/1.7.9.zip
+SOURCE_SUM=1cc4ecd97e4c143ca85d684d9a5ce0a79c4b359d85b76c7ca58f1babed8a5cfe
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
diff --git a/conf/config.php b/conf/config.php
index c363d3a..ff41004 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -8,20 +8,20 @@
*/
/** MySQL database username */
-define( 'YOURLS_DB_USER', 'yunouser' );
+define( 'YOURLS_DB_USER', '__DB_NAME__' );
/** MySQL database password */
-define( 'YOURLS_DB_PASS', 'yunopass' );
+define( 'YOURLS_DB_PASS', '__DB_PASSWORD__' );
/** The name of the database for YOURLS */
-define( 'YOURLS_DB_NAME', 'yunobase' );
+define( 'YOURLS_DB_NAME', '__DB_NAME__' );
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port', eg. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );
/** MySQL tables prefix */
-define( 'YOURLS_DB_PREFIX', 'yourls_' );
+define( 'YOURLS_DB_PREFIX', '__DB_NAME___' );
/*
** Site options
@@ -29,7 +29,7 @@ define( 'YOURLS_DB_PREFIX', 'yourls_' );
/** YOURLS installation URL -- all lowercase and with no trailing slash.
** If you define it to "http://site.com", don't use "http://www.site.com" in your browser (and vice-versa) */
-define( 'YOURLS_SITE', 'https://yunodomain_yourlspath' );
+define( 'YOURLS_SITE', 'https://__DOMAIN____PATH__' );
/** Timezone GMT offset */
define( 'YOURLS_HOURS_OFFSET', 0 );
@@ -51,7 +51,7 @@ define( 'YOURLS_UNIQUE_URLS', true );
define( 'YOURLS_PRIVATE', false );
/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from http://yourls.org/cookie **/
-define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
+define( 'YOURLS_COOKIEKEY', '__RANDOM__' );
/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
** YOURLS will auto encrypt plain text passwords in this file
@@ -91,4 +91,3 @@ $yourls_reserved_URL = array(
//define( 'LDAPAUTH_PORT', '389' );
//define( 'LDAPAUTH_BASE', 'dc=yunohost,dc=org' );
//define( 'LDAPAUTH_USERNAME_FIELD', 'uid');
-
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 686b543..ae41dca 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,20 +1,21 @@
-location __PATH__ {
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
+location __PATH__/ {
+
alias __FINALPATH__/;
+ # Force usage of https
+ if ($scheme = http) {
+ rewrite ^ https://$server_name$request_uri? permanent;
+ }
- if ($scheme = http) {
- rewrite ^ https://$server_name$request_uri? permanent;
- }
-
- try_files $uri $uri/ __PATHTOCHANGE__/yourls-loader.php;
+ try_files $uri $uri/ __FINALPATH__/yourls-loader.php;
index index.php index.html index.htm;
-
- location ~ [^/]\.php(/|$) {
+ location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
+ fastcgi_pass unix:/var/run/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
@@ -22,7 +23,6 @@ location __PATH__ {
fastcgi_param SCRIPT_FILENAME $request_filename;
}
-
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf
index 56ab91d..1a1bfb6 100644
--- a/conf/php-fpm.conf
+++ b/conf/php-fpm.conf
@@ -30,7 +30,7 @@ group = __USER__
; 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__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
diff --git a/manifest.json b/manifest.json
index 20a13c7..c6259cd 100644
--- a/manifest.json
+++ b/manifest.json
@@ -3,19 +3,19 @@
"id": "yourls",
"packaging_format": 1,
"description": {
- "en": "An URL shortening service",
- "fr": "Un service de raccourcisseur d'url"
+ "en": "URL shortening service",
+ "fr": "Service de raccourcisseur d'URL"
},
- "version": "1.7.6",
+ "version": "1.7.9~ynh1",
"url": "https://github.com/YOURLS/YOURLS",
- "license": "free",
+ "license": "MIT",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org",
"url": ""
},
"requirements": {
- "yunohost": ">= 2.7.2"
+ "yunohost": ">= 3.8.1"
},
"previous_maintainers": {
"name": "courgette",
@@ -25,7 +25,7 @@
"multi_instance": true,
"services": [
"nginx",
- "php5-fpm",
+ "php7.0-fpm",
"mysql"
],
"arguments": {
@@ -34,8 +34,8 @@
"name": "domain",
"type": "domain",
"ask": {
- "en": "Choose a domain for Yourls",
- "fr": "Choisissez un domaine pour Yourls"
+ "en": "Choose a domain for YOURLS",
+ "fr": "Choisissez un domaine pour YOURLS"
},
"example": "domain.org"
},
@@ -43,8 +43,8 @@
"name": "path",
"type": "path",
"ask": {
- "en": "Choose a path for Yourls",
- "fr": "Choisissez un chemin pour Yourls"
+ "en": "Choose a path for YOURLS",
+ "fr": "Choisissez un chemin pour YOURLS"
},
"example": "/yourls",
"default": "/yourls"
@@ -53,12 +53,11 @@
"name": "admin",
"type": "user",
"ask": {
- "en": "Choose a Yourls administrator (admin privileges for Yourls will be granted to this user)",
- "fr": "Administrateur du site Yourls"
+ "en": "Choose an admin user",
+ "fr": "Choisissez l'administrateur"
},
- "example": "yoda"
+ "example": "johndoe"
}
-
]
}
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 7506acd..044b52f 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -4,8 +4,10 @@
# COMMON VARIABLES
#=================================================
+YNH_PHP_VERSION="7.3"
+
# dependencies used by the app
-pkg_dependencies="php-gmp php-bcmath php-curl"
+extra_php_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-curl"
#=================================================
# PERSONAL HELPERS
diff --git a/scripts/backup b/scripts/backup
index ddaa7c1..0767ff2 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -6,12 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-source _common.sh
+#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
#=================================================
@@ -21,49 +17,48 @@ source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
-
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading installation settings..." --time --weight=1
+ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
+ynh_print_info --message="Backing up YOURLS directory..."
ynh_backup --src_path="$final_path"
#=================================================
-# BACKUP THE NGINX CONFIGURATION
+# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
-ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
-ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
+ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
@@ -71,5 +66,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
-
+ynh_script_progression --message="Backup script completed for YOURLS. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/install b/scripts/install
index 40deda8..53f50ac 100644
--- a/scripts/install
+++ b/scripts/install
@@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
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
@@ -28,33 +27,14 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
-### 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
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
-### About --weight and --time
-### ynh_script_progression will show to your final users the progression of each scripts.
-### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
-### --time is a packager option, it will show you the execution time since the previous call.
-### This option should be removed before releasing your app.
-### Use the execution time, given by --time, to estimate the weight of a step.
-### A common way to do it is to set a weight equal to the execution time in second +1.
-### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
-ynh_script_progression --message="Validating installation parameters..." --time --weight=1
-### 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"
+ynh_script_progression --message="Validating installation parameters..." --weight=1
+
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@@ -64,40 +44,16 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
-ynh_script_progression --message="Storing installation settings..." --time --weight=1
+ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Installing dependencies..." --time --weight=1
-
-### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
-### Those deb packages will be installed as dependencies of this package.
-### If you're not using this helper:
-### - Remove the section "REMOVE DEPENDENCIES" in the remove script
-### - Remove the variable "pkg_dependencies" in _common.sh
-### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
-### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
-
-ynh_install_app_dependencies $pkg_dependencies
-
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
-ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
-
-### 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
+ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
@@ -107,11 +63,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
-ynh_script_progression --message="Setting up source files..." --time --weight=1
-
-### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
-### downloaded from an upstream source, like a git repository.
-### `ynh_setup_source` use the file conf/app.src
+ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
@@ -120,22 +72,14 @@ ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
+ynh_script_progression --message="Configuring NGINX web server..." --weight=2
-### `ynh_add_nginx_config` will use the file conf/nginx.conf
-
-# Create a dedicated nginx config
-if [ "$path_url" != "/" ]; then
- ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="../conf/nginx.conf"
-else
- ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string=" " --target_file="../conf/nginx.conf"
-fi
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
-ynh_script_progression --message="Configuring system user..." --time --weight=1
+ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app
@@ -143,21 +87,11 @@ ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
-
-### `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
-### 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
+ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated php-fpm config
-ynh_add_fpm_config
+ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# copy index file
sudo cp ../conf/index.php $final_path/
@@ -165,34 +99,22 @@ sudo cp ../conf/index.php $final_path/
#=================================================
# MODIFY A CONFIG FILE
#=================================================
-### `ynh_replace_string` is used to replace a string in a file.
-### (It's compatible with sed regular expressions syntax)
+
sudo cp ../conf/config.php $final_path/user/config.php
-ynh_replace_string --match_string="yunouser" --replace_string="$db_name" --target_file="$final_path/user/config.php"
-ynh_replace_string --match_string="yunopass" --replace_string="$db_pwd" --target_file="$final_path/user/config.php"
-ynh_replace_string --match_string="yunobase" --replace_string="$db_name" --target_file="$final_path/user/config.php"
-ynh_replace_string --match_string="yunodomain" --replace_string="$domain" --target_file="$final_path/user/config.php"
-ynh_replace_string --match_string="_yourlspath" --replace_string="${path_url%/}" --target_file="$final_path/user/config.php"
-ynh_replace_string --match_string="modify this text with something random" --replace_string="$(ynh_string_random 24)$(ynh_string_random 24)" --target_file="$final_path/user/config.php"
-# The script "add_sso_conf.py" will just add en entry for the path "/admin" in the sso conf.json.persistent file in the cathegory "protected_urls".
-cp ../conf/add_sso_conf.py $final_path/add_sso_conf.py
-cp ../conf/remove_sso_conf.py $final_path/remove_sso_conf.py
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/add_sso_conf.py"
-if [ "$path_url" != "/" ]; then
- ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/add_sso_conf.py"
- ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/remove_sso_conf.py"
-else
- ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$final_path/add_sso_conf.py"
- ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$final_path/remove_sso_conf.py"
-fi
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/remove_sso_conf.py"
+ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__RANDOM__" --replace_string="$(ynh_string_random 24)" --target_file="$final_path/user/config.php"
+# Calculate and store the config file checksum into the app settings
+ynh_store_file_checksum "$final_path/user/config.php"
-python3 $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/yourls_ynh"
+#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
-
-# Set permissions
chown -R $app: $final_path
# Reload Nginx and regenerate SSOwat conf
@@ -200,34 +122,25 @@ chown -R $app: $final_path
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
-# Restrict access to admin only
-yunohost app addaccess --users=$admin $app
-yunohost app ssowatconf
-
#=================================================
# RELOAD NGINX
#=================================================
-ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
+ynh_script_progression --message="Reloading NGINX web server..." --weight=3
ynh_systemd_action --service_name=nginx --action=reload
sleep 10
-# Start Yourls install (database table creation)
+# Start YOURLS install (database table creation)
ynh_local_curl "admin/install.php" "install=dummy"
sleep 10
-# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$final_path/user/config.php"
-
#=================================================
# SETUP SSOWAT
#=================================================
ynh_systemd_action --service_name=nginx --action=reload
-yunohost app ssowatconf
#=================================================
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Installation of $app completed" --time --last
-
+ynh_script_progression --message="Installation of YOURLS completed" --last
diff --git a/scripts/remove b/scripts/remove
index 328ddc4..bfc5c6f 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading installation settings..." --time --weight=1
+ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@@ -20,23 +20,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
-ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
+ynh_script_progression --message="Removing the MySQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing dependencies..." --time --weight=1
-
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
-
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@@ -47,7 +38,7 @@ python3 $final_path/remove_sso_conf.py
#=================================================
# REMOVE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Removing app main directory..." --time --weight=1
+ynh_script_progression --message="Removing YOURLS main directory..." --weight=4
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@@ -56,7 +47,7 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
+ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
ynh_remove_nginx_config
@@ -64,9 +55,9 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
+ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
-# Remove the dedicated php-fpm config
+# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
@@ -74,7 +65,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
-ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
+ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
@@ -83,4 +74,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Removal of $app completed" --time --last
+ynh_script_progression --message="Removal of YOURLS completed" --last
diff --git a/scripts/restore b/scripts/restore
index 782e086..579ef38 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
-#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -15,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
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
@@ -31,12 +29,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
admin=$(ynh_app_setting_get --app=$app --key=admin)
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
-ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
+ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
@@ -54,39 +54,18 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
+ynh_script_progression --message="Restoring YOURLS main directory..." --weight=3
ynh_restore_file --origin_path="$final_path"
-# The script "add_sso_conf.py" will just add en entry for the path "/admin" in the sso conf.json.persistent file in the cathegory "protected_urls".
-python3 $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/synapse_ynh/issues/32"
-
-
-#=================================================
-# RESTORE THE MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
-
-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
-
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
-ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
+ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
-
-# Define and install dependencies
-ynh_install_app_dependencies $pkg_dependencies
-
#=================================================
# RESTORE USER RIGHTS
#=================================================
@@ -97,37 +76,31 @@ chown -R $app: $final_path
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
+ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=10
-ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+#=================================================
+# RESTORE THE MYSQL DATABASE
+#=================================================
+ynh_script_progression --message="Restoring the MySQL database..." --weight=5
+
+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
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
-sudo yunohost app setting $app unprotected_uris -v "/"
+ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
-#=================================================
-# SETUP SSOWAT
-#=================================================
-
-# Restrict access to admin only
-yunohost app addaccess --users=$admin $app
-yunohost app ssowatconf
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# RELOAD NGINX AND PHP-FPM
-#=================================================
-ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
-
-ynh_systemd_action --service_name=php7.0-fpm --action=reload
+ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Restoration completed for $app" --time --last
+ynh_script_progression --message="Restoration completed for YOURLS" --last
diff --git a/scripts/upgrade b/scripts/upgrade
index 520fbd2..cb263f3 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -20,19 +20,13 @@ 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_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
-
-=================================================
+#=================================================
# CHECK VERSION
#=================================================
-### This helper will compare the version of the currently installed app and the version of the upstream package.
-### $upgrade_type can have 2 different values
-### - UPGRADE_APP if the upstream app version has changed
-### - UPGRADE_PACKAGE if only the YunoHost package has changed
-### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
-### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
@@ -53,7 +47,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
+ynh_script_progression --message="Backing up YOURLS before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@@ -64,18 +58,6 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
-#=================================================
-# CHECK THE PATH
-#=================================================
-
-# Normalize the URL path syntax
-# N.B. : this is for app installations before YunoHost 2.7
-# where this value might be something like /foo/ or foo/
-# instead of /foo ....
-# If nobody installed your app before 2.7, then you may
-# safely remove this line
-path_url=$(ynh_normalize_url_path --path_url=$path_url)
-
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@@ -102,48 +84,20 @@ cp -a "$tmpdir/index.php" "$final_path"
cp -a "$tmpdir/.htaccess" "$final_path"
cp -a "$tmpdir/user/config.php" "$final_path/user"
-# The script "add_sso_conf.py" will just add en entry for the path "/admin" in the sso conf.json.persistent file in the cathegory "protected_urls".
-cp ../conf/add_sso_conf.py $final_path
-cp ../conf/remove_sso_conf.py $final_path
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/add_sso_conf.py"
-if [ "$path_url" != "/" ]; then
- ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/add_sso_conf.py"
- ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/remove_sso_conf.py"
-else
- ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$final_path/add_sso_conf.py"
- ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$final_path/remove_sso_conf.py"
-fi
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/remove_sso_conf.py"
-
#remove tmp dir
rm -Rf "$tmpdir"
#=================================================
# NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
+ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
-# Create a dedicated nginx config
-if [ "$path_url" != "/" ]; then
- ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="../conf/nginx.conf"
-else
- ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string=" " --target_file="../conf/nginx.conf"
-fi
-
-# Create a dedicated nginx config
ynh_add_nginx_config
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
-
-ynh_install_app_dependencies $pkg_dependencies
-
#=================================================
# CREATE DEDICATED USER
#=================================================
-ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
+ynh_script_progression --message="Making sure dedicated system user exists..." --weight=3
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
@@ -151,17 +105,35 @@ ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
+ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=4
-# Create a dedicated php-fpm config
-ynh_add_fpm_config
+# Create a dedicated PHP-FPM config
+ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
+
+#=================================================
+# MODIFY A CONFIG FILE
+#=================================================
+ynh_script_progression --message="Modifying a config file..." --weight=2
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/user/config.php"
+
+sudo cp ../conf/config.php $final_path/user/config.php
+
+ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/user/config.php"
+ynh_replace_string --match_string="__RANDOM__" --replace_string="$(ynh_string_random 24)" --target_file="$final_path/user/config.php"
+
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/user/config.php"
-# Set right permissions for curl installation
+#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
+
+# Restore permissions on app files
chown -R $app: $final_path
#=================================================
@@ -172,13 +144,11 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Restrict access to admin only
yunohost app addaccess --users=$admin $app
-yunohost app ssowatconf
-
#=================================================
# RELOAD NGINX
#=================================================
-ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
+ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@@ -186,4 +156,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Upgrade of $app completed" --time --last
+ynh_script_progression --message="Upgrade of YOURLS completed" --last