1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/concrete5_ynh.git synced 2024-09-03 18:25:54 +02:00

Merge pull request #3 from yalh76/master

Fix Installation Issue
This commit is contained in:
frju365 2019-04-03 00:59:24 +02:00 committed by GitHub
commit 5f92cc8185
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 828 additions and 762 deletions

View file

@ -1,6 +1,12 @@
[![Install concrete5 with YunoHost](https://github.com/ABLD/install-app/blob/master/install-with-yunohost-community.png)](https://install-app.yunohost.org/?app=concrete5)
# concrete5_ynh # concrete5_ynh
[![Integration level](https://dash.yunohost.org/integration/concrete5.svg)](https://dash.yunohost.org/appci/app/concrete5)
[![Install concrete5 with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=concrete5)
> *This package allow you to install concrete5 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
Concrete5 is a modern CMS. Concrete5 is a modern CMS.
Features : Features :
* SEO Tools * SEO Tools
@ -11,8 +17,42 @@ Features :
* Marketing tools * Marketing tools
* **and more**... * **and more**...
## Etat : NOT WORKING **Shipped version:** 8.4.5
## Screenshot
## Documentation
Site officiel : https://www.concrete5.org/ * Official documentation: https://documentation.concrete5.org/
## YunoHost specific features
#### Multi-users support
LDAP and HTTP auth are not supported
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/concrete5%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/concrete5/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/concrete5%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/concrete5/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/concrete5%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/concrete5/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/concrete5_ynh/issues
* App website: https://www.concrete5.org/
* GitHub App website: https://github.com/concrete5/concrete5
* 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/concrete5_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/concrete5_ynh/tree/testing --debug
or
sudo yunohost app upgrade concrete5 -u https://github.com/YunoHost-Apps/concrete5_ynh/tree/testing --debug
```

View file

@ -1,15 +1,17 @@
;; Nom du test # See here for more information
auto_remove=1 # https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
is_public="Yes" (PUBLIC|public=Yes|private=No)
admin_name="john" (USER) admin_name="john" (USER)
admin_pass="123456789AaBbCc" (PASSWORD) language="fr_FR"
admin_email="abc@example.com" is_public=1 (PUBLIC|public=1|private=0)
admin_pass="pass"
website_title="site" website_title="site"
language="Fr"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -18,25 +20,24 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
backup_restore=0 backup_restore=1
multi_instance=1 multi_instance=1
wrong_user=1
wrong_path=1
incorrect_path=1 incorrect_path=1
corrupt_source=1
fail_download_source=1
port_already_use=0 port_already_use=0
final_path_already_use=1 change_url=1
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto
Level 3=auto Level 3=auto
Level 4=na # Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
# level 4: for instance there is no ldap integration. There is already a MySQL integration. # If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
Level 5=1 Level 4=0
# level 5: le test ne semble pas tout à fait savoir ce qu'est vraiment un "exit". Level 5=auto
Level 6=auto Level 6=auto
Level 7=auto Level 7=auto
Level 8=0 Level 8=0
Level 9=0 Level 9=0
Level 10=0 Level 10=0
;;; Options
Email=
Notification=none

View file

@ -1,2 +1,6 @@
SOURCE_URL=https://github.com/concrete5/concrete5/archive/8.2.1.tar.gz SOURCE_URL=https://github.com/concrete5/concrete5/archive/8.4.5.tar.gz
SOURCE_SUM=3cd496c25f3bc02451219ce39e471cdc SOURCE_SUM=a8708e6d55dba3bcf6aeb2a377eaa851650cb8634343c7ce4e88045fd58d565e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,38 +0,0 @@
appNamespace: "chooseAnUniqueNameForYourApp"
timezone: "Europe/Paris"
doctrine:
driver: "pdo_mysql"
host: "localhost"
user: "db_user"
password: 'db_pass'
dbname: "db_name"
port: null
unix_socket: null
path: null
cacheDriver:
type: null
host: null
port: null
security:
secret: 'change#this#secret#very#important'
mailer:
type: null
host: "localhost"
port: 25
encryption: false
username: ''
password: ''
entities:
- "src/Roadiz/Core/Entities"
- "src/Roadiz/Core/AbstractEntities"
- "gen-src/GeneratedNodeSources"
rememberMeLifetime: 2592000
additionalServiceProviders: { }
additionalCommands:
- \Themes\DefaultTheme\Commands\DefaultThemeCommand
assetsProcessing:
driver: gd
defaultQuality: 90
maxPixelSize: 1920
jpegoptimPath: null
pngquantPath: null

View file

@ -1,35 +1,24 @@
location {LOCATION} { #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
alias {DESTDIR}; location __PATH__/ {
# Default indexes and catch-all # Path to source
index index.html index.php; alias __FINALPATH__/ ;
try_files $uri $uri/ {PATH}/index.php?$args;
# Force HTTPS # Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
# Prevent useless logs index index.php;
location = {PATH}/favicon.ico {
log_not_found off;
access_log off;
}
location = {PATH}/robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny access to hidden files and directories # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
location ~ ^{PATH}/(.+/|)\.(?!well-known\/) { #client_max_body_size 50M;
deny all;
}
# Execute and serve PHP files try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-{POOLNAME}.sock; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;

View file

@ -1,10 +1,11 @@
; Start a new pool named 'www'. ; 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) ; pool name ('www' here)
[__NAMETOCHANGE__] [__NAMETOCHANGE__]
; Per pool prefix ; Per pool prefix
; It only applies on the following directives: ; It only applies on the following directives:
; - 'access.log'
; - 'slowlog' ; - 'slowlog'
; - 'listen' (unixsocket) ; - 'listen' (unixsocket)
; - 'chroot' ; - 'chroot'
@ -19,22 +20,24 @@
; Unix user/group of processes ; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group ; Note: The user is mandatory. If the group is not set, the default user's group
; will be used. ; will be used.
user = www-data user = __USER__
group = www-data group = __USER__
; The address on which to accept FastCGI requests. ; The address on which to accept FastCGI requests.
; Valid syntaxes are: ; 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; ; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; specific port; ; 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. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; 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. ; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128 ;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write ; 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 ; permissions must be set in order to allow connections from a web server. Many
@ -44,8 +47,13 @@ listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
listen.owner = www-data listen.owner = www-data
listen.group = www-data listen.group = www-data
;listen.mode = 0660 ;listen.mode = 0660
; 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 ipv4 addresses of FastCGI clients which are allowed to connect. ; 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 ; 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 ; 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 ; 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 ; - The pool processes will inherit the master process priority
; unless it specified otherwise ; unless it specified otherwise
; Default Value: no set ; 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. ; Choose how the process manager will control the number of child processes.
; Possible Values: ; Possible Values:
@ -215,7 +229,7 @@ pm.max_requests = 500
; last request memory: 0 ; last request memory: 0
; ;
; Note: There is a real-time FPM status monitoring sample web page available ; 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 ; 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 ; 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 ; - %{megabytes}M
; - %{mega}M ; - %{mega}M
; %n: pool name ; %n: pool name
; %o: ouput header ; %o: output header
; it must be associated with embraces to specify the name of the header: ; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o ; - %{Content-Type}o
; - %{X-Powered-By}o ; - %{X-Powered-By}o
@ -291,9 +305,13 @@ pm.max_requests = 500
; %t: server time the request was received ; %t: server time the request was received
; it can accept a strftime(3) format: ; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default) ; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsuled in a %{<strftime_format>}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) ; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format: ; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default) ; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %u: remote user ; %u: remote user
; ;
; Default: "%R - %u %t \"%m %r\" %s" ; Default: "%R - %u %t \"%m %r\" %s"
@ -349,13 +367,22 @@ chdir = __FINALPATH__
; Default Value: no ; 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 ; 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 ; 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 ; 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. ; Note: set an empty value to allow all extensions.
; Default Value: .php ; 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 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment. ; the current environment.
@ -390,3 +417,14 @@ catch_workers_output = yes
;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on ;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M ;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
php_admin_value[upload_max_filesize] = 16M
php_admin_value[post_max_size] = 16M
; 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

View file

@ -1,2 +0,0 @@
upload_max_filesize=16M
post_max_size=16M

View file

@ -2,23 +2,25 @@
"name": "Concrete5", "name": "Concrete5",
"id": "concrete5", "id": "concrete5",
"packaging_format": 1, "packaging_format": 1,
"requirements": {
"yunohost": ">=2.6"
},
"description": { "description": {
"en": "Create a modern Website", "en": "Create a modern Website",
"fr": "Créer un site web moderne avec un CMS moderne" "fr": "Créer un site web moderne avec un CMS moderne"
}, },
"license": "MIT", "version": "8.4.5~ynh1",
"url": "www.concrete5.org", "url": "www.concrete5.org",
"license": "MIT",
"maintainer": { "maintainer": {
"name": "frju365", "name": "frju365",
"email": "win10@tutanota.com" "email": "win10@tutanota.com"
}, },
"requirements": {
"yunohost": ">= 3.4"
},
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx", "nginx",
"php5-fpm" "php7.0-fpm",
"mysql"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [
@ -29,7 +31,7 @@
"en": "Choose a domain for Concrete5", "en": "Choose a domain for Concrete5",
"fr": "Choisissez un domaine pour Concrete5" "fr": "Choisissez un domaine pour Concrete5"
}, },
"example": "domain.org" "example": "example.com"
}, },
{ {
"name": "path", "name": "path",
@ -41,61 +43,56 @@
"example": "/concrete", "example": "/concrete",
"default": "/concrete" "default": "/concrete"
}, },
{
"name": "is_public",
"ask": {
"en": "Is it a public Concrete5 site ?",
"fr": "Est-ce un site public ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
},
{ {
"name": "admin_name", "name": "admin_name",
"type": "user", "type": "user",
"ask": { "ask": {
"en": "Choose the Concrete5 administrator (must be an existing YunoHost user)", "en": "Choose an admin user",
"fr": "Choisissez l'administrateur de Concrete5 (doit être un utilisateur YunoHost existant)" "fr": "Choisissez ladministrateur"
}, },
"example": "homer" "example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["en_US", "fr_FR", "de_DE", "pt_PT"],
"default": "en_US"
}, },
{ {
"name": "admin_pass", "name": "admin_pass",
"type": "password", "type": "password",
"ask": { "ask": {
"en": "Set the password for the Admin user ≥ 5 character", "en": "Set the administrator password",
"fr": "Définissez le mot de passe pour l'Administrateur. ≥ cinq charactères" "fr": "Définissez le mot de passe administrateur"
}, },
"example": "myreallystrengthpassword" "help": {
"en": "Use the help field to add an information for the admin about this question.",
"fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
}, },
{ "example": "Choose a password"
"name": "admin_email",
"type": "email",
"ask": {
"en": "Your mail address.",
"fr": "Votre adresse mail."
},
"exemple": "abc@efg.hi"
}, },
{ {
"name": "website_title", "name": "website_title",
"type": "title", "type": "string",
"ask": { "ask": {
"en": "Your website's title.", "en": "Your website's title.",
"fr": "Le titre de votre site." "fr": "Le titre de votre site."
}, },
"exemple": "MY BIG WEBSITE" "exemple": "MY BIG WEBSITE",
}, "default": "Concrete"
{
"name": "language",
"ask": {
"en": "Default language to be used in your website admin",
"fr": "Langue par défaut à utiliser dans votre interface d'administration"
},
"choices": [
"En", "Fr", "De", "Pt"
],
"default": "English"
} }
] ]
} }

View file

@ -1,330 +0,0 @@
#!/bin/bash
#=================================================
# CHECKING
#=================================================
CHECK_USER () { # Vérifie la validité de l'user admin
# $1 = Variable de l'user admin.
ynh_user_exists "$1" || ynh_die "Wrong user"
}
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
sudo yunohost app checkurl $domain$path_url -a $app
}
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
}
#=================================================
# DISPLAYING
#=================================================
NO_PRINT () { # Supprime l'affichage dans stdout pour la commande en argument.
set +x
eval "$@"
set -x
}
WARNING () { # Écrit sur le canal d'erreur pour passer en warning.
eval "$@" >&2
}
SUPPRESS_WARNING () { # Force l'écriture sur la sortie standard
eval "$@" 2>&1
}
QUIET () { # Redirige la sortie standard dans /dev/null
eval "$@" > /dev/null
}
ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
eval "$@" > /dev/null 2>&1
}
#=================================================
# SETUP
#=================================================
SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path
src_url=$(cat ../conf/app.src | grep SOURCE_URL | cut -d= -f2)
src_checksum=$(cat ../conf/app.src | grep SOURCE_SUM | cut -d= -f2)
# Download sources from the upstream
wget -nv -O source.tar.gz $src_url
# Vérifie la somme de contrôle de la source téléchargée.
echo "$src_checksum source.tar.gz" | md5sum -c --status || ynh_die "Corrupt source"
# Extract source into the app dir
sudo mkdir -p $final_path
sudo tar -x -f source.tar.gz -C $final_path --strip-components 1
}
POOL_FPM () { # Créer le fichier de configuration du pool php-fpm et le configure.
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
sed -i "s@__USER__@$app@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo service php5-fpm reload
}
#=================================================
# REMOVE
#=================================================
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
echo "Delete nginx config"
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
sudo service nginx reload
fi
}
REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
echo "Delete fpm config"
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
fi
if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config
echo "Delete php config"
sudo rm "/etc/php5/fpm/conf.d/20-$app.ini"
fi
sudo service php5-fpm reload
}
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
no_var=0
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
do
no_var=1
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière.
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
if test -z "$real_var" || [ "$real_var" = "/" ]; then
WARNING echo "Variable $only_var is empty, suppression of $chaine cancelled."
return 1
fi
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
done
if [ "$no_var" -eq 1 ]
then
if [ -e "$chaine" ]; then
echo "Delete directory $chaine"
sudo rm -r "$chaine"
fi
return 0
else
WARNING echo "No detected variable."
return 1
fi
}
REMOVE_SYS_USER () { # Supprime l'utilisateur système dédié à l'app
if ynh_system_user_exists "$app" # Test l'existence de l'utilisateur
then
sudo userdel $app
fi
}
#=================================================
# BACKUP
#=================================================
BACKUP_FAIL_UPGRADE () {
WARNING echo "Upgrade failed."
if ALL_QUIET sudo yunohost backup list | grep -q $app-before-upgrade$backup_number; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
sudo yunohost backup restore --ignore-hooks $app-before-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
ynh_die "The app was restored to the way it was before the failed upgrade."
fi
}
BACKUP_BEFORE_UPGRADE () { # Backup the current version of the app, restore it if the upgrade fails
backup_number=1
old_backup_number=2
if ALL_QUIET sudo yunohost backup list | grep -q $app-before-upgrade1; then # Vérifie l'existence d'une archive déjà numéroté à 1.
backup_number=2 # Et passe le numéro de l'archive à 2
old_backup_number=1
fi
sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade$backup_number # Créer un backup différent de celui existant.
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
if ALL_QUIET sudo yunohost backup list | grep -q $app-before-upgrade$old_backup_number; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur.
QUIET sudo yunohost backup delete $app-before-upgrade$old_backup_number
fi
else # Si le backup a échoué
ynh_die "Backup failed, the upgrade process was aborted."
fi
}
#=================================================
# CONFIGURATION
#=================================================
STORE_MD5_CONFIG () { # Enregistre la somme de contrôle du fichier de config
# $1 = Nom du fichier de conf pour le stockage dans settings.yml
# $2 = Nom complet et chemin du fichier de conf.
ynh_app_setting_set $app $1_file_md5 $(sudo md5sum "$2" | cut -d' ' -f1)
}
CHECK_MD5_CONFIG () { # Créé un backup du fichier de config si il a été modifié.
# $1 = Nom du fichier de conf pour le stockage dans settings.yml
# $2 = Nom complet et chemin du fichier de conf.
if [ "$(ynh_app_setting_get $app $1_file_md5)" != $(sudo md5sum "$2" | cut -d' ' -f1) ]; then
sudo cp -a "$2" "$2.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')" # Si le fichier de config a été modifié, créer un backup.
fi
}
# Normalize the url path syntax
# Handle the slash at the beginning of path and its absence at ending
# Return a normalized url path
#
# example: url_path=$(ynh_normalize_url_path $url_path)
# ynh_normalize_url_path example -> /example
# ynh_normalize_url_path /example -> /example
# ynh_normalize_url_path /example/ -> /example
#
# usage: ynh_normalize_url_path path_to_normalize
# | arg: url_path_to_normalize - URL path to normalize before using it
ynh_normalize_url_path () {
path_url=$1
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
path_url="/$path_url" # Add / at begin of path variable
fi
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
fi
echo $path_url
}
# Create a database, an user and its password. Then store the password in the app's config
#
# User of database will be store in db_user's variable.
# Name of database will be store in db_name's variable.
# And password in db_pwd's variable.
#
# usage: ynh_mysql_generate_db user name
# | arg: user - Owner of the database
# | arg: name - Name of the database
ynh_mysql_generate_db () {
db_pwd=$(ynh_string_random) # Generate a random password
ynh_mysql_create_db "$2" "$1" "$db_pwd" # Create the database
ynh_app_setting_set $app mysqlpwd $db_pwd # Store the password in the app's config
}
# Remove a database if it exist and the associated user
#
# usage: ynh_mysql_remove_db user name
# | arg: user - Proprietary of the database
# | arg: name - Name of the database
ynh_mysql_remove_db () {
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $2"; then # Check if the database exist
echo "Remove database $2" >&2
ynh_mysql_drop_db $2 # Remove the database
ynh_mysql_drop_user $1 # Remove the associated user to database
else
echo "Database $2 not found" >&2
fi
}
# Correct the name given in argument for mariadb
#
# Avoid invalid name for your database
#
# Exemple: dbname=$(ynh_make_valid_dbid $app)
#
# usage: ynh_make_valid_dbid name
# | arg: name - name to correct
# | ret: the corrected name
ynh_make_valid_dbid () {
dbid=${1//[-.]/_} # Mariadb doesn't support - and . in the name of databases. It will be replace by _
echo $dbid
}
# Install dependencies with a equivs control file
#
# usage: ynh_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence
ynh_app_dependencies () {
dependencies=$@
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version=$(sudo python3 -c "import sys, json;print(json.load(open(\"$manifest_path\"))['version'])") # Retrieve the version number in the manifest file.
dep_app=${app//_/-} # Replace all '_' by '-'
cat > ./${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies}
Architecture: all
Description: Fake package for ${app} (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs ./${dep_app}-ynh-deps.control \
|| ynh_die "Unable to install dependencies" # Install the fake package and its dependencies
}
# Remove fake package and its dependencies
#
# Dependencies will removed only if no other package need them.
#
# usage: ynh_remove_app_dependencies
ynh_remove_app_dependencies () {
dep_app=${app/_/-} # Replace all '_' by '-'
ynh_package_autoremove ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used.
}
# Manage a fail of the script
#
# Print a warning to inform that the script was failed
# Execute the ynh_clean_setup function if used in the app script
#
# usage of ynh_clean_setup function
# This function provide a way to clean some residual of installation that not managed by remove script.
# To use it, simply add in your script:
# ynh_clean_setup () {
# instructions...
# }
# This function is optionnal.
#
# Usage: ynh_exit_properly is used only by the helper ynh_check_error.
# You must not use it directly.
ynh_exit_properly () {
exit_code=$?
if [ "$exit_code" -eq 0 ]; then
exit 0 # Exit without error if the script ended correctly
fi
trap '' EXIT # Ignore new exit signals
set +eu # Do not exit anymore if a command fail or if a variable is empty
echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
ynh_clean_setup # Call the function to do specific cleaning for the app.
fi
ynh_die # Exit with error status
}
# Exit if an error occurs during the execution of the script.
#
# Stop immediatly the execution if an error occured or if a empty variable is used.
# The execution of the script is derivate to ynh_exit_properly function before exit.
#
# Usage: ynh_check_error
ynh_check_error () {
set -eu # Exit if a command fail, and if a variable is used unset.
trap ynh_exit_properly EXIT # Capturing exit signals on shell script
}

70
scripts/_common.sh Normal file
View file

@ -0,0 +1,70 @@
#!/bin/bash
#=================================================
# PERSONAL HELPERS
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
# Send the email to the recipients
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,49 +1,67 @@
#!/bin/bash #!/bin/bash
set -eu #=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# This is a multi-instance app, meaning it can be installed several times independently #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# The id of the app as stated in the manifest is available as $YNH_APP_ID source ../settings/scripts/_common.sh
# 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 you are interested the 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
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve arguments #=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
### MySQL (remove if not used) ### #=================================================
# If a MySQL database is used: # STANDARD BACKUP STEPS
# # Dump the database #=================================================
db_name=$app # BACKUP THE APP MAIN DIR
db_user=$app #=================================================
db_pass=$(ynh_app_setting_get "$app" mysqlpwd) ynh_print_info "Backing up the main app directory..."
mysqldump -u "$db_user" -p"$db_pass" --no-create-db "$db_name" > ./dump.sql
### MySQL end ###
ynh_backup "$final_path"
# Backup directory location for the app from where the script is executed and #=================================================
# which will be compressed afterward # BACKUP THE NGINX CONFIGURATION
backup_dir=$YNH_APP_BACKUP_DIR #=================================================
ynh_print_info "Backing up nginx web server configuration..."
# Backup sources & data ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/var/www/$app" "sources"
# Copy Nginx conf #=================================================
sudo mkdir -p ./conf # BACKUP THE PHP-FPM CONFIGURATION
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" #=================================================
ynh_print_info "Backing up php-fpm configuration..."
### PHP (remove if not used) ### ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
# If a dedicated php-fpm process is used:
# # Copy PHP-FPM pool configuration #=================================================
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" # BACKUP THE MYSQL DATABASE
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" "php-fpm.ini" #=================================================
### PHP end ### ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

111
scripts/change_url Normal file
View file

@ -0,0 +1,111 @@
#!/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
#=================================================
ynh_print_info "Loading installation 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
#=================================================
ynh_print_info "Updating nginx web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
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
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Change of URL completed for $app"

View file

@ -1,19 +1,20 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source .fonctions source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE FAILURE OF THE SCRIPT # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_check_error # Active trap pour arrêter le script si une erreur est détectée. # Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
@ -21,147 +22,153 @@ ynh_check_error # Active trap pour arrêter le script si une erreur est détect
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin_name=$YNH_APP_ARG_ADMIN_NAME admin_name=$YNH_APP_ARG_ADMIN_NAME
admin_pass=$YNH_APP_ARG_ADMIN_PASS is_public=$YNH_APP_ARG_IS_PUBLIC
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
website_title=$YNH_APP_ARG_WEBSITE_TITLE
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
admin_pass=$YNH_APP_ARG_ADMIN_PASS
website_title=$YNH_APP_ARG_WEBSITE_TITLE
admin_email=$(ynh_user_get_info $admin_name 'mail')
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..."
CHECK_USER "$admin_name" # Vérifie la validité de l'user admin final_path=/var/www/$app
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path. test ! -e "$final_path" || ynh_die "This path already contains a folder"
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé. # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Register (book) web path
ynh_webpath_register $app $domain $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..."
user="$app" ynh_app_setting_set $app domain $domain
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set $app path $path_url
ynh_app_setting_set "$app" admin_pass "$admin_pass" ynh_app_setting_set $app admin_name $admin_name
ynh_app_setting_set "$app" admin_name "$admin_name" ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set "$app" admin_email "$admin_email" ynh_app_setting_set $app language $language
ynh_app_setting_set "$app" language "$language" ynh_app_setting_set $app admin_email $admin_email
ynh_app_setting_set "$app" website_title "$website_title" ynh_app_setting_set $app website_title $website_title
#=================================================
# Check password strength
#=================================================
[[ ${#admin_pass} -gt 5 ]] || ynh_die \
"The password is too weak, it must be longer than 5 characters"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# CREATE A SQL BDD # CREATE A MYSQL DATABASE
#================================================= #=================================================
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
db_name=$app
db_user=$app
db_pass=$(ynh_string_random)
ynh_mysql_create_db "$db_name" "$db_user" "$db_pass"
ynh_app_setting_set "$app" db_name "$db_name"
ynh_app_setting_set "$app" db_pass "$db_pass"
ynh_app_setting_set "$app" db_user "$db_user"
ynh_app_setting_set "$app" mysqlpwd "$db_pass"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..."
final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
POOL_FPM
#=================================================
# SPECIFIC SETUP
#=================================================
# LANGUAGE
#=================================================
if [ $language = "En" ]
then
language=en_GB
elif [ $language = "Fr" ]
then
language=fr_FR
elif [ $language = "De" ]
then
language=de_DE
elif [ $language = "Pt" ]
then
language=pt_PT
else
ynh_die "Language is no available"
fi
#================================================
# Installation : Get Composer:
#=================================================
echo "The installation can take long. So be patient ! :)"
pushd $final_path
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"
sudo ./composer.phar install
sudo ./concrete/bin/concrete5 c5:install --db-server=localhost \
--db-username=$db_user \
--db-password=$db_pass \
--db-database=$db_name \
--site="'$website_title'" \
--admin-email="'$admin_email'" \
--admin-password=$admin_pass \
--language=$language
popd
#=================================================
# Set permissions
#=================================================
sudo chown www-data:www-data $final_path -R
sudo chmod 777 $final_path -R
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..."
nginxconf="../conf/nginx.conf" # Create a dedicated nginx config
# Copy and set nginx configuration ynh_add_nginx_config
sed -i "s@{PATH}@${path_url}@g" $nginxconf
sed -i "s@{LOCATION}@${path_url:-/}@g" $nginxconf #=================================================
sed -i "s@{DESTDIR}@${final_path}@g" $nginxconf # CREATE DEDICATED USER
sed -i "s@{POOLNAME}@${app}@g" $nginxconf #=================================================
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/${domain}.d/${app}.conf ynh_print_info "Configuring system user..."
# Create a system user
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#================================================
# CONCRETE5 INSTALLATION
#=================================================
ynh_print_info "Concrete5 Installation, the installation can take long. So be patient ! :)"
pushd $final_path
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"
sudo ./composer.phar install
sudo ./concrete/bin/concrete5 c5:install --db-server=localhost \
--db-database=$db_name \
--db-username=$db_name \
--db-password=$db_pwd \
--site="$website_title" \
--admin-email="$admin_email" \
--admin-password="$admin_pass" \
--language=$language \
--site-locale=$language \
--verbose \
--no-interaction \
--allow-as-root
popd
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R $app: $final_path
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Configuring SSOwat..."
# Make app private if necessary # Make app public if necessary
ynh_app_setting_set "$app" is_public "$is_public" if [ $is_public -eq 1 ]
if [ "$is_public" = "Yes" ];
then then
ynh_app_setting_set "$app" unprotected_uris "/" # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..."
sudo service nginx reload systemctl reload nginx
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# WARNING : theses command are used in INSTALL, RESTORE
# For any update do it in all files
message="To connect to your Concrete Website go to https://$domain$path_url/ with Username: admin"
ynh_send_readme_to_admin "$message"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -1,36 +1,73 @@
#!/bin/bash #!/bin/bash
set -u #=================================================
# Source app helpers # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx #=================================================
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config # LOAD SETTINGS
echo "Delete nginx config" #=================================================
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_print_info "Loading installation settings..."
fi
}
REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
echo "Delete fpm config"
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
fi
}
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
dbname=$app
dbuser=$app
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
# Drop MySQL database and user #=================================================
ynh_mysql_drop_db "$dbname" # STANDARD REMOVE
ynh_mysql_drop_user "$dbuser" #=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_print_info "Removing the MySQL database"
sudo rm -rf /var/www/$app # Remove a database if it exists, along with the associated user
REMOVE_NGINX_CONF ynh_mysql_remove_db $db_user $db_name
REMOVE_FPM_CONF
sudo service nginx reload #=================================================
sudo service php5-fpm reload # REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely
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
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user
ynh_system_user_delete $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -1,53 +1,103 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Exit on command errors and treat unset variables as an error #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
set -eu source ../settings/scripts/_common.sh
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # MANAGE SCRIPT FAILURE
path=$(ynh_app_setting_get "$app" path) #=================================================
# Check domain/path availability # Exit if an error occurs during the execution of the script
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ ynh_abort_if_errors
|| ynh_die "Path not available: ${domain}${path}"
# Restore sources & data #=================================================
src_path="/var/www/${app}" # LOAD SETTINGS
sudo cp -a ./sources "$src_path" #=================================================
ynh_print_info "Loading settings..."
# Restore permissions to app files app=$YNH_APP_INSTANCE_NAME
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
### MySQL (remove if not used) ### domain=$(ynh_app_setting_get $app domain)
# If a MySQL database is used: path_url=$(ynh_app_setting_get $app path)
# # Create and restore the database final_path=$(ynh_app_setting_get $app final_path)
dbname=$app db_name=$(ynh_app_setting_get $app db_name)
dbuser=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration #=================================================
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
### PHP (remove if not used) ### ynh_webpath_available $domain $path_url \
# If a dedicated php-fpm process is used: || ynh_die "Path not available: ${domain}${path_url}"
# # Copy PHP-FPM pool configuration and reload the service test ! -d $final_path \
sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" || ynh_die "There is already a directory: $final_path "
sudo cp -a ./php-fpm.ini "/etc/php5/fpm/conf.d/20-$app.ini"
sudo service php5-fpm reload
### PHP end ###
# Restart webserver #=================================================
sudo service nginx reload # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
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"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R $app: $final_path
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
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
#=================================================
# GENERIC FINALIZATION
#=================================================
# 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"

View file

@ -1,76 +1,150 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# See comments in install script source _common.sh
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # LOAD SETTINGS
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
admin=$(ynh_app_setting_get "$app" admin) ynh_print_info "Loading installation settings..."
is_public=$(ynh_app_setting_get "$app" is_public)
language=$(ynh_app_setting_get "$app" language)
# Remove trailing "/" for next commands app=$YNH_APP_INSTANCE_NAME
path_url=${path_url%/}
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin_name=$(ynh_app_setting_get $app admin_name)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
language=$(ynh_app_setting_get $app language)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring 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)
ynh_app_setting_set $app db_name $db_name
fi
# If final_path doesn't exist, create it
if [ -z $final_path ]; then
final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path
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
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Upgrading source files..."
final_path=/var/www/$app # Download, check integrity, uncompress and patch the source from app.src
ynh_app_setting_set $app final_path $final_path ynh_setup_source "$final_path"
sudo git pull origin master;
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPGRADE CONCRETE
#=================================================
pushd $final_path pushd $final_path
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" sudo ./concrete/bin/concrete5 c5:update --rerun --verbose --allow-as-root
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"
sudo ./composer update -n --no-dev;
sudo ./bin/roadiz generate:nsentities;
sudo ./bin/roadiz orm:schema-tool:update --dump-sql;
sudo ./bin/roadiz orm:schema-tool:update --force;
sudo ./bin/roadiz cache:clear -e prod
popd popd
# Modify Nginx configuration file and copy it to Nginx conf directory #=================================================
nginx_conf=../conf/nginx.conf # GENERIC FINALIZATION
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf #=================================================
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf # SECURE FILES AND DIRECTORIES
# If a dedicated php-fpm process is used: #=================================================
#
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP (remove if not used) ### # Set permissions on app files
# If a dedicated php-fpm process is used: chown -R $app: $final_path
# # Modify PHP-FPM pool configuration and copy it to the pool directory
final_path=/var/www/$app
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
sed -i "s@__USER__@$app@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo chmod 644 $finalphpini
sudo service php5-fpm restart
### PHP end ###
# If app is public, add url to SSOWat conf as skipped_uris #=================================================
if [[ $is_public -eq 1 ]]; then # SETUP SSOWAT
# See install script #=================================================
ynh_app_setting_set "$app" unprotected_uris "/" ynh_print_info "Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/"
fi fi
# Reload nginx service #=================================================
sudo service nginx reload # RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"