1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grav_ynh.git synced 2024-09-03 19:16:01 +02:00

Merge pull request #10 from Jibec/master

Full rewrite
This commit is contained in:
tituspijean 2018-09-12 22:45:39 +02:00 committed by GitHub
commit 9d464b5dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 589 additions and 530 deletions

122
README.md
View file

@ -1,114 +1,46 @@
# [EN] Grav for YunoHost [![Integration level](https://dash.yunohost.org/integration/grav.svg)](https://ci-apps.yunohost.org/jenkins/job/grav%20%28Community%29/lastBuild/consoleFull)
[![Install Grav with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=grav) [![Install Grav with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=grav)
* http://getgrav.org/ Grav is a modern open source flat-file CMS.
* https://github.com/getgrav/grav
## Installation > *This package allow you to install Grav 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.*
From YunoHost admin panel:
1. Enter repository url https://github.com/YunoHost-Apps/grav_ynh
2. Configure the app
3. Click install
4. Go to the url you configured
From command line:
```sh
sudo yunohost app install -l grav https://github.com/YunoHost-Apps/grav_ynh
```
Options:
1. __Choose a domain for Grav__
Domain for your installation (example.org).
2. __Choose a path for Grav__
Path for your installation (/grav).
3. __Is it a public application ?__
If public, everybody will be able to access your Grav instance (example.org/grav).
4. __Do you wish to install the Admin plugin ?__
Grav has an optional admin panel, answer `Yes` if you want to use it.
5. __Make admin panel private ?__
_Only valid if admin panel is installed._
Protect the admin panel behind Yunohost authentication.
6. __Create administrator automatically ?__
_Only works if admin panel is installed and private._
If `Yes`, an admin account will be automatically created when you first visit your Grav instance, and you will be redirected to the admin panel. Your authentication will be handled by your YunoHost connection.
If `No`, on your first visit to your Grav instance Grav will propose you to create a new user.
<hr/>
# [FR] Grav pour YunoHost
* http://getgrav.org/ * http://getgrav.org/
* https://github.com/getgrav/grav * https://github.com/getgrav/grav
Provided version: **1.5.1**
## Installation ## Installation
Depuis le panneau d'administration YunoHost: Use either YunoHost's admin panel or command line:
1. Entrez l'url du dépot https://github.com/YunoHost-Apps/grav_ynh
2. Configurez l'application
3. Cliquez sur installer
4. Rendez-vous à l'url que vous avez configuré
Depuis la ligne de commande:
```sh ```sh
sudo yunohost app install -l grav https://github.com/YunoHost-Apps/grav_ynh sudo yunohost app install https://github.com/YunoHost-Apps/grav_ynh
``` ```
Options: For upgrading (replace `grav` by the actual instance ID if more instances are installed):
```sh
sudo yunohost app upgrade grav -u https://github.com/YunoHost-Apps/grav_ynh
```
1. __Choisissez un domaine pour Grav__ # State of this package
Domaine pour votre installation (example.org, grav.example.org).
2. __Choisissez un chemin pour Grav__ * works fine:
Chemin pour votre installation (/grav, /). * [x] install/remove/backup/remove/upgrade with x86_64
3. __Est-ce une page publique ?__ * to be confirmed:
Si cette application est publique, n'importe quelle personne pourra y accéder (example.org/grav). * [x] upgrade from old package to new package
* [ ] impact of upgrade on content
* [ ] ARM
4. __Souhaitez-vous installer le plugin d'administration ?__ * to be added:
Grav possède un plugin d'administration optionnel, répondez `Yes` si vous souhaitez l'utiliser. * [ ] send email to admin
5. __Souhaitez-vous rendre l'administration privée ?__ ## Links
_Valide uniquement si le plugin d'administration est installé._
Protège l'administration derrière l'authentification Yunohost.
6. __Souhaitez-vous créer un administrateur automatiquement ?__
_Valide uniquement si le plugin d'administration est installé et privé._
Si `Yes`, un compte administrateur sera automatiquement créé à votre première visite de votre instance Grav, et vous serez redirigé vers l'administration.
Votre connexion à l'administration sera associée à votre connexion YunoHost.
Si `No`, à votre première visite de votre instance Grav, il vous sera proposé la création d'un nouvel utilisateur.
## Versionning
### Version 1.3.1 (22/07/17)
- Update version
### Version 1.1.1 (13/03/17)
- Fix package_check [source](https://github.com/YunoHost/package_check)
### Version 1.1.0 (02/03/17)
- Fix Packaging [Source](https://forum.yunohost.org/t/news-about-app-management-and-packaging-in-yunohost-2-4/1379/1)
### Version 1.0.0 (11/11/15)
- First version
### Configuration
1. Start url https://domaine.tld/grav
* Report a bug about this package: https://github.com/YunoHost-Apps/grav_ynh
* Report a bug about Grav itself: https://github.com/getgrav/grav/issues
* Documentation: https://learn.getgrav.org/
* Grav website: https://www.getgrav.org/
* YunoHost website: https://yunohost.org/

View file

@ -1,12 +1,13 @@
;; Test complet sans multisite # See here for more information
auto_remove=1 # https://github.com/YunoHost/package_check#syntax-check_process-file
;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
admin="john" (USER) admin="john" (USER)
language="fr_FR" language="fr_FR"
multisite="No" is_public="Yes" (PUBLIC|public=1|private=0)
is_public="Yes" (PUBLIC|public=Yes|private=No)
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -15,23 +16,29 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=ec151614e4c41f2012bb983d08faf6eda233d5be
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
wrong_user=1
wrong_path=1
incorrect_path=1 incorrect_path=1
corrupt_source=0
fail_download_source=0
port_already_use=0 port_already_use=0
final_path_already_use=0 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=0 # doable, but there is no group in YunoHost's LDAP
# https://github.com/trilbymedia/grav-plugin-login-ldap
Level 4=1
Level 5=auto 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=jean-baptiste@holcroft.fr
Notification=all
;;; Upgrade options
; commit=ec151614e4c41f2012bb983d08faf6eda233d5be
name=Version 1.3.1
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=PUBLIC&

6
conf/app.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/getgrav/grav/releases/download/1.5.1/grav-admin-v1.5.1.zip
SOURCE_SUM=34f48f984ef734e66ccc1c9fc30f5d5f512ee0febc4576c63b657bf4c5461160
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,10 +1,11 @@
location __PATHTOCHANGE__ { #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
alias __FINALPATH__/; alias __FINALPATH__/;
index index.php; index index.php;
if (!-e $request_filename) if (!-e $request_filename)
{ {
rewrite ^(.+)$ __PATHTOCHANGE__/index.php?q=$1 last; rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
} }
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
@ -30,9 +31,11 @@ location __PATHTOCHANGE__ {
} }
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-__NAMETOCHANGE__.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;
# https://learn.getgrav.org/webservers-hosting/servers/nginx#fix-against-httpoxy-vulnerability
fastcgi_param HTTP_PROXY "";
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;

View file

@ -19,8 +19,8 @@
; 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:
@ -30,7 +30,7 @@ group = www-data
; specific port; ; 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: 128 (-1 on FreeBSD and OpenBSD)

View file

@ -6,20 +6,33 @@
"en": "Grav - Grav is a modern open source flat-file CMS", "en": "Grav - Grav is a modern open source flat-file CMS",
"fr": "Grav - Grav is a modern open source flat-file CMS" "fr": "Grav - Grav is a modern open source flat-file CMS"
}, },
"version": "1.3.1", "version": "1.5.1~ynh2",
"url": "https://www.getgrav.org/", "url": "https://www.getgrav.org/",
"license": "free", "license": "MIT-0",
"maintainer": { "maintainer": [
"name": "cyp, lithrel", {
"email": "cyp@rouquin.me, lithrel@randomdomainname.net" "name": "jibec",
"email": "jean-baptiste@holcroft.fr"
}, },
{
"name": "tituspijean",
"email": "tituspijean@outlook.com"
}],
"previous_maintainers": [
{
"name": "cyp",
"email": "cyp@rouquin.me"
},{
"name": "lithrel",
"email": "lithrel@randomdomainname.net"
}],
"requirements": { "requirements": {
"yunohost": ">> 2.4.0" "yunohost": ">= 3.1.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx", "nginx",
"php5-fpm" "php7.0-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [
@ -53,12 +66,12 @@
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean",
"ask": { "ask": {
"en": "Is it a public Grav site ?", "en": "Is it a public Grav site ?",
"fr": "Est-ce un site public ?" "fr": "Est-ce un site public ?"
}, },
"choices": ["Yes", "No"], "default": true
"default": "Yes"
}, },
{ {
"name": "language", "name": "language",

View file

@ -1,204 +0,0 @@
#!/bin/bash
ynh_version="2.4"
YNH_VERSION () { # Returns the version number of the Yunohost moulinette
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
}
CHECK_VAR () { # Verifies that the variable is not empty.
# $1 = Variable to be checked
# $2 = Display text on error
test -n "$1" || (echo "$2" >&2 && false)
}
EXIT_PROPERLY () { # Causes the script to stop in the event of an error. And clean the residue.
trap '' ERR
echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
if type -t CLEAN_SETUP > /dev/null; then # Checks the existence of the function before executing it.
CLEAN_SETUP # Call the specific cleanup function of the install script.
fi
# Compensates the ssowat bug that does not remove the app's input in case of installation error.
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
if [ "$ynh_version" = "2.2" ]; then
/bin/bash $script_dir/remove
fi
ynh_die
}
TRAP_ON () { # Activate signal capture
trap EXIT_PROPERLY ERR # Capturing exit signals on error
}
TRAP_OFF () { # Ignoring signal capture until TRAP_ON
trap '' ERR # Ignoring exit signals
}
CHECK_USER () { # Check the validity of the user admin
# $1 = User admin variable
ynh_user_exists "$1" || (echo "Wrong admin" >&2 && false)
}
CHECK_PATH () { # Checks / at the beginning of the path. And his absence at the end.
if [ "${path:0:1}" != "/" ]; then # If the first character is not /
path="/$path" # Add / at the beginning of path
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # If the last character is a / and it is not the only character.
path="${path:0:${#path}-1}" # Delete last character
fi
}
CHECK_DOMAINPATH () { # Checks the availability of the path and domain.
sudo yunohost app checkurl $domain$path -a $app
}
CHECK_FINALPATH () { # Checks that the destination folder is not already in use.
final_path=/var/www/$app
if [ -e "$final_path" ]
then
echo "This path already contains a folder" >&2
false
fi
}
GENERATE_DB () { # Create a database and a dedicated user in the name of the app
# $1 = Database name
# Generates a random password.
db_user=$1
db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
CHECK_VAR "$db_pwd" "db_pwd empty"
# Uses '$ app' as user name and database
# Initializes the database and stores the mysql password.
ynh_mysql_create_db "$db_user" "$db_user" $db_pwd
ynh_app_setting_set $app mysqlpwd $db_pwd
}
SETUP_SOURCE () { # Download source, decompress and copu into $final_path
src=$(cat ../sources/source_md5 | awk -F' ' {'print $2'})
sudo wget -nv -i ../sources/source_url -O $src
# Checks the checksum of the downloaded source.
# md5sum -c ../sources/source_md5 --status || ynh_die "Corrupt source"
# Decompress source
if [ "$(echo ${src##*.})" == "tgz" ]; then
tar -x -f $src
elif [ "$(echo ${src##*.})" == "zip" ]; then
unzip -q $src
else
false # Unsupported archive format.
fi
# Copy file source
sudo cp -a $(cat ../sources/source_dir)/. "$final_path"
# Copy additional file and modified
if test -e "../sources/ajouts"; then
sudo cp -a ../sources/ajouts/. "$final_path"
fi
}
POOL_FPM () { # Create the php-fpm pool configuration file and configure it.
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@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 systemctl reload php5-fpm
}
STORE_MD5_CONFIG () { # Saves the checksum of the config file
# $1 = Name of the conf file for storage in settings.yml
# $2 = Full name and path of the conf file.
ynh_app_setting_set $app $1_file_md5 $(sudo md5sum "$2" | cut -d' ' -f1)
}
CHECK_MD5_CONFIG () { # Created a backup of the config file if it was changed.
# $1 = Name of the conf file for storage in settings.yml
# $2 = Full name and path of the conf file.onf.
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
}
FIND_PORT () { # Search free port
# $1 = Port number to start the search.
port=$1
while ! sudo yunohost app checkport $port ; do
port=$((port+1))
done
CHECK_VAR "$port" "port empty"
}
### REMOVE SCRIPT
REMOVE_NGINX_CONF () { # Delete nginx configuration
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 systemctl reload nginx
fi
}
REMOVE_FPM_CONF () { # Delete pool php-fpm configuration
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 systemctl reload php5-fpm
}
REMOVE_LOGROTATE_CONF () { # Delete logrotate configuration
if [ -e "/etc/logrotate.d/$app" ]; then
echo "Delete logrotate config"
sudo rm "/etc/logrotate.d/$app"
fi
}
SECURE_REMOVE () { # Deleting a folder with variable verification
chaine="$1" # The argument must be given between simple quotes '', to avoid interpreting the variables.
no_var=0
while (echo "$chaine" | grep -q '\$') # Loop as long as there are $ in the string
do
no_var=1
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole the first variable found.
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole completely the variable by adding the $ at the beginning and keeping only the name of the variable. Mostly gets rid of / and a possible path behind.
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` Allows to interpret a variable contained in a variable.
if test -z "$real_var" || [ "$real_var" = "/" ]; then
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
return 1
fi
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # Replaces variable with its value in the string.
done
if [ "$no_var" -eq 1 ]
then
if [ -e "$chaine" ]; then
echo "Delete directory $chaine"
sudo rm -r "$chaine"
fi
return 0
else
echo "No detected variable." >&2
return 1
fi
}
REMOVE_BDD () { # Delete database and users
# $1 = Database name
# Uses '$app' as user name and database
db_user=$1
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
echo "Delete db"
ynh_mysql_drop_db $db_user
ynh_mysql_drop_user $db_user
fi
}

1
scripts/_common.sh Normal file
View file

@ -0,0 +1 @@
#!/bin/bash

View file

@ -1,23 +1,48 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source app helpers source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Get multi-instances specific variables #=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings 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)
# Copy the app files #=================================================
final_path="/var/www/${app}" # STANDARD BACKUP STEPS
ynh_backup "$final_path" "sources" 1 #=================================================
# BACKUP THE APP MAIN DIR
#=================================================
# Copy the nginx conf files ynh_backup "$final_path"
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
# Copy the php-fpm conf files #=================================================
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" # BACKUP THE NGINX CONFIGURATION
ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini" #=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_backup "/etc/php/7.0/fpm/conf.d/20-$app.ini"

98
scripts/change_url Normal file
View file

@ -0,0 +1,98 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get "$app" final_path)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
test -n "$old_path" || old_path="/"
test -n "$new_path" || new_path="/"
new_path=$(ynh_normalize_url_path "$new_path")
old_path=$(ynh_normalize_url_path "$old_path")
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ "$change_path" -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -1,86 +1,120 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions # Loads the generic functions usually used in the script source _common.sh
source /usr/share/yunohost/helpers # Source app helpers source /usr/share/yunohost/helpers
CLEAN_SETUP () { #=================================================
# Clean installation residues that are not supported by the remove script. # MANAGE SCRIPT FAILURE
# Clean hosts #=================================================
sudo sed -i '/#GRAV/d' /etc/hosts
} # Exit if an error occurs during the execution of the script
TRAP_ON # Active trap to stop the script if an error is detected. ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin_grav=$YNH_APP_ARG_ADMIN admin_grav=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
CHECK_VAR "$app" "app name not set" #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
CHECK_USER "$admin_grav" ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
CHECK_PATH # Normalize the url path syntax
path_url=$(ynh_normalize_url_path "$path_url")
CHECK_DOMAINPATH # Check web path availability
ynh_webpath_available "$domain" "$path_url"
# Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url"
CHECK_FINALPATH #=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app domain $domain ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set $app path $path ynh_app_setting_set "$app" path "$path_url"
ynh_app_setting_set $app admin $admin_grav ynh_app_setting_set "$app" admin "$admin_grav"
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app language $language
# Creates the destination directory and stores its location.
sudo mkdir "$final_path"
ynh_app_setting_set $app final_path $final_path
# Get source
SETUP_SOURCE
# Grav install
sudo $final_path/bin/grav
# Set permissions
sudo chown -R www-data: $final_path
echo -e "127.0.0.1 $domain #GRAV" | sudo tee -a /etc/hosts
# Copy nginx config
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Modif the variables in the nginx configuration file
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
if [ "$is_public" = "Yes" ];
then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
fi
# Create the php-fpm pool config
POOL_FPM
# Setup SSOwat
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" is_public "$is_public"
if [ "$is_public" = "Yes" ]; ynh_app_setting_set "$app" language "$language"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies php7.0-zip
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_app_setting_set "$app" final_path "$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create "$app"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R "$app": "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
# Make app public if necessary
if [ $is_public -eq "1" ]
then then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set "$app" unprotected_uris "/"
else
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi fi
# Reload SSOwat configuration #=================================================
sudo yunohost app ssowatconf # RELOAD NGINX
#=================================================
# Reload Nginx and regenerate SSOwat conf systemctl reload nginx
sudo systemctl reload php5-fpm
sudo systemctl reload nginx
# Nettoyer hosts
sudo sed -i '/#GRAV/d' /etc/hosts

View file

@ -1,25 +1,60 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -u # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Loads the generic functions usually used in the script source _common.sh
source .fonctions
# Source app helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
# Get multi-instances specific variables # Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
final_path=$(ynh_app_setting_get "$app" final_path)
# Delete app directory and configurations #=================================================
SECURE_REMOVE '/var/www/$app' # Delete directory application # STANDARD REMOVE
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf" #=================================================
sudo rm -f "/etc/php5/fpm/conf.d/20-${app}.ini" # REMOVE DEPENDENCIES
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf" #=================================================
# Reload services # Remove metapackage and its dependencies
sudo systemctl reload php5-fpm ynh_remove_app_dependencies
sudo systemctl reload nginx
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
# Delete a system user
ynh_system_user_delete "$app"

View file

@ -1,66 +1,95 @@
#!/bin/bash #!/bin/bash
# This restore script is adapted to Yunohost >=2.4
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source app helpers source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# The parameter $app is the id of the app instance ex: ynhexample__2 #=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Get old parameter of the app
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path)
# Check domain/path availability #=================================================
sudo yunohost app checkurl "${domain}${path}" -a "${app}" \ # CHECK IF THE APP CAN BE RESTORED
|| ynh_die "Path not available: ${domain}${path}" #=================================================
# Check $final_path ynh_webpath_available $domain $path_url \
final_path="/var/www/${app}" || ynh_die "Path not available: ${domain}${path_url}"
if [ -d "${final_path}" ]; then test ! -d $final_path \
ynh_die "There is already a directory: ${final_path}" || ynh_die "There is already a directory: $final_path "
fi
# Check configuration files nginx
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
if [ -f "${nginx_conf}" ]; then
ynh_die "The NGINX configuration already exists at '${nginx_conf}'. You should safely delete it before restoring this app."
fi
# Check configuration files php-fpm #=================================================
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" # STANDARD RESTORATION STEPS
if [ -f "${phpfpm_conf}" ]; then #=================================================
ynh_die "The PHP FPM configuration already exists at '${phpfpm_conf}'. You should safely delete it before restoring this app." # RESTORE THE NGINX CONFIGURATION
fi #=================================================
phpfpm_ini="/etc/php5/fpm/conf.d/20-${app}.ini" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
if [ -f "${phpfpm_ini}" ]; then
ynh_die "The PHP FPM INI configuration already exists at '${phpfpm_ini}'. You should safely delete it before restoring this app."
fi
# Restore sources & data #=================================================
sudo cp -a ./sources "${final_path}" # RESTORE THE APP MAIN DIR
#=================================================
# Set permissions ynh_restore_file "$final_path"
sudo chown -R www-data: "${final_path}"
# Restore nginx configuration files #=================================================
sudo cp -a ./nginx.conf "${nginx_conf}" # RECREATE THE DEDICATED USER
# Restore php-fpm configuration files #=================================================
sudo cp -a ./php-fpm.conf "${phpfpm_conf}"
sudo cp -a ./php-fpm.ini "${phpfpm_ini}"
# Set ssowat config # Create the dedicated user (if not existing)
if [ "$is_public" = "No" ]; ynh_system_user_create "$app"
then
ynh_app_setting_delete $app skipped_uris #=================================================
fi # RESTORE USER RIGHTS
#=================================================
chown -R "$app": "$final_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies php7.0-zip
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
# Reload services # Reload services
sudo systemctl reload php5-fpm systemctl reload php7.0-fpm
sudo systemctl reload nginx systemctl reload nginx
sudo yunohost app ssowatconf

View file

@ -1,51 +1,134 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions # Loads the generic functions usually used in the script source _common.sh
source /usr/share/yunohost/helpers # Source YunoHost helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
# See comments in install script
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get $app path)
path=$(ynh_app_setting_get "$app" path) admin=$(ynh_app_setting_get $app admin)
admin=$(ynh_app_setting_get "$app" admin) is_public=$(ynh_app_setting_get $app is_public)
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) language=$(ynh_app_setting_get $app language)
CHECK_PATH # Checks and corrects the syntax of the path. #=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
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 final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path
# Get source
SETUP_SOURCE
# Modify Nginx configuration file and copy it to Nginx conf directory
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
if [ "$is_public" = "Yes" ];
then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
fi fi
# Create the php-fpm pool config #=================================================
POOL_FPM # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
sudo chown -R www-data: "${final_path}" # 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
# Setup SSOwat #=================================================
ynh_app_setting_set "$app" is_public "$is_public" # CHECK THE PATH
if [ "$is_public" = "Yes" ]; #=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies php7.0-zip
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a dedicated user (if not existing)
ynh_system_user_create "$app"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config
chown -R "$app": "$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
#=================================================
# SETUP SSOWAT
#=================================================
# Make app public if necessary
if [ $is_public -eq "1" ]
then then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set "$app" unprotected_uris "/"
else
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi fi
# Reload Nginx #=================================================
sudo systemctl reload php5-fpm # RELOAD NGINX
sudo systemctl reload nginx #=================================================
sudo yunohost app ssowatconf
systemctl reload nginx

View file

@ -1 +0,0 @@
grav-admin

View file

@ -1 +0,0 @@
1c325d225c33641262386b4688344344 grav-admin-v1.3.1.zip

View file

@ -1 +0,0 @@
https://github.com/getgrav/grav/releases/download/1.3.1/grav-admin-v1.3.1.zip