1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/opensondage_ynh.git synced 2024-09-03 19:46:28 +02:00

Normalization from example_ynh

This commit is contained in:
Maniack Crudelis 2019-02-17 14:46:43 +01:00
parent 5a144d1e1d
commit 48580d3df0
11 changed files with 266 additions and 272 deletions

View file

@ -1,19 +1,69 @@
opensondage_ynh # OpenSondage for YunoHost
===============
OpenSondage for YunoHost [![Integration level](https://dash.yunohost.org/integration/opensondage.svg)](https://dash.yunohost.org/appci/app/opensondage)
[![Install OpenSondage with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=opensondage)
OpenSondage is used to poll people invite for a meeting. > *This package allow you to install OpenSondage 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.*
## Change done from original sources ## Overview
This package contains a custom version of Framadate (fork of OpenSondage and Studs), the sources are here: https://git.framasoft.org/framasoft/framadate/.
## Broken things Framadate is an online service for planning an appointment or making a decision quickly and easily. It's a community free/libre software alternative to Doodle.
1. There is no way to configure mail, either with smtp or with sendmail. See https://framagit.org/framasoft/framadate/merge_requests/184 **Shipped version:** 1.0.3
2. There is no way to use SSOWAT to identify current user. See https://framagit.org/framasoft/framadate/issues/177
## Screenshot ## Screenshots
<img src="/sources/images/date.png" style="max-width:100%;" alt="Screen containing a meeting poll"/> ![](https://framadate.org/images/date.png)
<img src="/sources/images/classic.png" style="max-width:100%;" alt="Screen containing a vote poll to choose a restaurant"/>
## Demo
* [YunoHost demo](https://demo.yunohost.org/date/)
* [Official demo](https://framadate.org/)
## Configuration
## Documentation
* Official documentation: https://framagit.org/framasoft/framadate/framadate/wikis/home
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-users support
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/opensondage%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/opensondage/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/opensondage%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/opensondage/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/opensondage%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/opensondage/)
## Limitations
* There is no way to configure mail, either with smtp or with sendmail. See https://framagit.org/framasoft/framadate/merge_requests/184
* There is no way to use SSOWAT to identify current user. See https://framagit.org/framasoft/framadate/issues/177
## Additional information
* This package contains a custom version of Framadate (fork of OpenSondage and Studs), the sources are here: https://git.framasoft.org/framasoft/framadate/.
## Links
* Report a bug: https://github.com/YunoHost-Apps/opensondage_ynh/issues
* OpenSondage website: https://git.framasoft.org/framasoft/framadate/framadate
* 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/opensondage_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
or
sudo yunohost app upgrade opensondage -u https://github.com/YunoHost-Apps/opensondage_ynh/tree/testing --debug
```

View file

@ -1,5 +1,4 @@
;; Test complet ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
@ -19,6 +18,7 @@
multi_instance=1 multi_instance=1
incorrect_path=1 incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto

View file

@ -2,3 +2,5 @@ SOURCE_URL=https://git.framasoft.org/framasoft/framadate/framadate/repository/1.
SOURCE_SUM=aa372ac8b7f0f7b0ad4ab973a5cfb7db5aa3b95a1ea584e3c57c8929d3766169 SOURCE_SUM=aa372ac8b7f0f7b0ad4ab973a5cfb7db5aa3b95a1ea584e3c57c8929d3766169
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2 SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,10 +1,14 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Path to source
alias __FINALPATH__/; alias __FINALPATH__/;
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
index index.php; index index.php;
try_files $uri $uri/ /index.php; try_files $uri $uri/ /index.php;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
@ -16,6 +20,7 @@ location __PATH__/ {
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTPS on; fastcgi_param HTTPS on;
} }
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -2,14 +2,14 @@
"name": "OpenSondage", "name": "OpenSondage",
"id": "opensondage", "id": "opensondage",
"packaging_format": 1, "packaging_format": 1,
"url": "https://git.framasoft.org/framasoft/framadate",
"version": "1.0.3",
"license": "CECILL-B",
"description": { "description": {
"en": "OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required.", "en": "OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required.",
"fr": "OpenSondage sert à faire des sondages sans authentification pour trouver une date de réunion qui convienne à toutes les personnes concernées.", "fr": "OpenSondage sert à faire des sondages sans authentification pour trouver une date de réunion qui convienne à toutes les personnes concernées.",
"de": "OpenSondage ist ein Online-Dienst, der Ihnen bei der Absprache von Terminen oder der Entscheidungsfindung hilft." "de": "OpenSondage ist ein Online-Dienst, der Ihnen bei der Absprache von Terminen oder der Entscheidungsfindung hilft."
}, },
"version": "1.0.3~ynh1",
"url": "https://git.framasoft.org/framasoft/framadate",
"license": "CECILL-B",
"maintainer": { "maintainer": {
"name": "ljf", "name": "ljf",
"email": "ljf+yunohost@grimaud.me" "email": "ljf+yunohost@grimaud.me"
@ -58,6 +58,7 @@
}, },
{ {
"name": "language", "name": "language",
"type": "string",
"ask": { "ask": {
"en": "Choose the default language of this OpenSondage", "en": "Choose the default language of this OpenSondage",
"fr": "Choisissez la langue par défault d'OpenSondage", "fr": "Choisissez la langue par défault d'OpenSondage",
@ -76,8 +77,6 @@
}, },
"default": true "default": true
} }
] ]
} }
} }

View file

@ -1,43 +1,18 @@
#!/bin/bash #!/bin/bash
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() { exec_as() {
local USER=$1 local USER=$1
shift 1 shift 1
if [[ $USER = $(whoami) ]] if [[ $USER = $(whoami) ]]; then
then eval "$@"
eval $@
else else
sudo -u "$USER" $@ sudo -u "$USER" "$@"
fi fi
} }
# Execute a composer command from a given directory
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
exec_composer() {
local AS_USER=$1
local WORKDIR=$2
shift 2
exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
php "${WORKDIR}/composer.phar" $@ \
-d "${WORKDIR}" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer destdir
init_composer() {
local AS_USER=$1
local WORKDIR=$2
# install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="${WORKDIR}/.composer" \
php -- --quiet --install-dir="$WORKDIR" \
|| ynh_die "Unable to install Composer"
# update dependencies to create composer.lock
exec_composer "$AS_USER" "$WORKDIR" install --no-dev \
|| ynh_die "Unable to update core dependencies with Composer"
}

View file

@ -6,12 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -25,12 +20,11 @@ ynh_abort_if_errors
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
# See comments in install script
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
db_name=$(ynh_app_setting_get "$app" db_name)
dbuser=$app final_path=$(ynh_app_setting_get $app final_path)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get "$app" domain) db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
@ -38,8 +32,7 @@ domain=$(ynh_app_setting_get "$app" domain)
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
# Backup sources & data ynh_backup "$final_path"
ynh_backup "/var/www/$app"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -20,15 +20,14 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$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
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
@ -37,22 +36,20 @@ final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path "$path_url") path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available "$domain" "$path_url"
# Register (book) web path # Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url" ynh_webpath_register $app $domain $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set $app domain $domain
ynh_app_setting_set "$app" path_url "$path_url" ynh_app_setting_set $app path $path_url
ynh_app_setting_set "$app" admin "$admin" ynh_app_setting_set $app admin $admin
ynh_app_setting_set "$app" language "$language" ynh_app_setting_set $app language $language
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set $app is_public $is_public
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -60,25 +57,21 @@ ynh_app_setting_set "$app" is_public "$is_public"
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_install_app_dependencies php-fpdf ynh_install_app_dependencies php-fpdf php-cli
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
# Generate MySQL password and create database db_name=$(ynh_sanitize_dbid $app)
dbuser=$app ynh_app_setting_set $app db_name $db_name
db_name=$app ynh_mysql_setup_db $db_name $db_name
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_app_setting_set "$app" db_name "$db_name"
ynh_mysql_create_db "$db_name" "$dbuser" "$dbpass"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
@ -86,15 +79,6 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
if [ "$path_url" == "/" ]
then
# ynh panel is only for non-root installs
ynh_replace_string " include conf.d/" " #include conf.d/" "../conf/nginx.conf"
else
# add rewrite for alias_traversal protection
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
fi
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -103,7 +87,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# Create a system user # Create a system user
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -115,78 +99,79 @@ ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# Create config.php # CREATE CONFIG.PHP
#================================================= #=================================================
config="$final_path/app/inc/config.php" config="$final_path/app/inc/config.php"
admin_mail=$(ynh_user_get_info "$admin" mail)
admin_mail=$(ynh_user_get_info $admin mail)
cp ../conf/config.php "$config" cp ../conf/config.php "$config"
# Change variables in configuration # Change variables in configuration
ynh_replace_string "__DBUSER__" "$dbuser" "$config" ynh_replace_string "__DBUSER__" $db_name "$config"
ynh_replace_string "__DBPWD__" "$dbpass" "$config" ynh_replace_string "__DBPWD__" $db_pwd "$config"
ynh_replace_string "__DBNAME__" "$db_name" "$config" ynh_replace_string "__DBNAME__" $db_name "$config"
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$config" ynh_replace_string "__ADMINMAIL__" $admin_mail "$config"
ynh_replace_string "__LANGUAGE__" "$language" "$config" ynh_replace_string "__LANGUAGE__" $language "$config"
ynh_replace_string "__DOMAIN__" "$domain" "$config" ynh_replace_string "__DOMAIN__" $domain "$config"
ynh_replace_string "__PATH__" "$path_url" "$config" ynh_replace_string "__PATH__" $path_url "$config"
#=================================================
# Replace logo image (default is FramaDate)
#=================================================
cp ../img/logo.png "$final_path/images"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config" ynh_store_file_checksum "$config"
#================================================= #=================================================
# Create log file # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE)
#=================================================
cp ../img/logo.png "$final_path/images"
#=================================================
# CREATE LOG FILE
#================================================= #=================================================
# Create log file
touch "$final_path/admin/stdout.log" touch "$final_path/admin/stdout.log"
#=================================================
# RUN DATABASE INITILIZATION
#=================================================
# Set permissions for initilization
chown -R $app: "$final_path"
# Install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$final_path/.composer" \
php -- --quiet --install-dir="$final_path" \
|| ynh_die "Unable to install Composer"
# Update dependencies to create composer.lock
exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" install --no-dev \
-d "$final_path" --quiet --no-interaction \
|| ynh_die "Unable to update core dependencies with Composer"
ynh_exec_warn_less exec_as $app php "$final_path/admin/migration.php"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# Run database initilization
#=================================================
# Set initial permissions of initilization
chown -R "$app": "$final_path"
init_composer "$app" "$final_path"
sudo -u "$app" php "$final_path/admin/migration.php"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
chown -R root: "$final_path" chown -R root: "$final_path"
chown -R "$app": "$final_path/tpl_c" chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
chown -R "$app": "$final_path/admin/stdout.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_app_setting_set "$app" skipped_uris "/" # Make app public if necessary
if [ $is_public -eq 1 ]
if [ $is_public -eq 0 ];
then then
ynh_app_setting_set "$app" protected_uris "/" ynh_app_setting_set $app skipped_uris "/"
else # Keep /admin private
ynh_app_setting_set "$app" protected_uris "/admin" ynh_app_setting_set $app protected_uris "/admin"
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
ynh_store_file_checksum "$finalnginxconf"
fi fi
#================================================= #=================================================
@ -194,3 +179,4 @@ fi
#================================================= #=================================================
systemctl reload nginx systemctl reload nginx

View file

@ -15,8 +15,9 @@ source /usr/share/yunohost/helpers
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) db_name=$(ynh_app_setting_get $app db_name)
final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -32,15 +33,14 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
db_name=$app ynh_mysql_remove_db $db_name $db_name
dbuser=$app
ynh_mysql_remove_db "$db_name" "$dbuser"
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_secure_remove "/var/www/$app" # Remove the app directory securely
ynh_secure_remove "$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -63,4 +63,5 @@ ynh_remove_fpm_config
#================================================= #=================================================
# Delete a system user # Delete a system user
ynh_system_user_delete "$app" ynh_system_user_delete $app

View file

@ -6,12 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -29,22 +24,19 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve old app settings # Retrieve old 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_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get "$app" admin) final_path=$(ynh_app_setting_get $app final_path)
is_public=$(ynh_app_setting_get "$app" is_public) db_name=$(ynh_app_setting_get $app db_name)
db_name=$(ynh_app_setting_get "$app" db_name)
dbuser=$app
final_path=$(ynh_app_setting_get "$app" final_path)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================ #================================================
ynh_webpath_available "$domain" "$path_url" \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path" || ynh_die "There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -61,19 +53,18 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#================================================= #=================================================
# CREATE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
# Create a system user # Create the dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
# Set permissions # Restore permissions on app files
chown -R "$app": "$final_path/tpl_c" chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
chown -R "$app": "$final_path/admin/stdout.log"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
@ -85,9 +76,9 @@ ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd) db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db "$db_name" "$db_name" "$db_pwd" ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -95,7 +86,7 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
# Dependences # Define and install dependencies
ynh_install_app_dependencies php-fpdf ynh_install_app_dependencies php-fpdf
#================================================= #=================================================
@ -104,6 +95,6 @@ ynh_install_app_dependencies php-fpdf
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
# Reload Nginx systemctl reload php7.0-fpm
service php5-fpm restart systemctl reload nginx
service nginx reload

View file

@ -10,28 +10,18 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # LOAD SETTINGS
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get $app path)
path_url=$(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)
db_name=$(ynh_app_setting_get "$app" db_name) language=$(ynh_app_setting_get $app language)
dbuser=$app db_name=$(ynh_app_setting_get $app db_name)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
final_path=$(ynh_app_setting_get "$app" final_path)
language=$(ynh_app_setting_get "$app" language)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -39,38 +29,46 @@ language=$(ynh_app_setting_get "$app" language)
if [ -z "$is_public" ]; if [ -z "$is_public" ];
then then
is_public=$(ynh_app_setting_get "$app" public_site) is_public=$(ynh_app_setting_get $app public_site)
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set $app is_public $is_public
ynh_app_setting_delete "$app" public_site ynh_app_setting_delete $app public_site
fi fi
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set "$app" is_public 1 ynh_app_setting_set $app is_public 1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set "$app" is_public 0 ynh_app_setting_set $app is_public 0
is_public=0 is_public=0
fi fi
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid "$app") db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set $app db_name $db_name
fi fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z $final_path ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set $app final_path $final_path
fi fi
# make sure default language is set # Make sure default language is set
if [ -z "$language" ]; if [ -z "$language" ]
then then
language=$(grep LANGUE "/var/www/$app/variables.php" | grep -Po "'.*?'" | cut -d"'" -f2) language=$(grep LANGUE "/var/www/$app/variables.php" | grep -Po "'.*?'" | cut -d"'" -f2)
fi fi
# Use path instead of path_url in settings.yml...
if [ -z "$path_url" ]
then
path_url=$(ynh_app_setting_get $app path_url)
ynh_app_setting_set $app path $path_url
ynh_app_setting_delete $app path_url
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -89,10 +87,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path "$path_url") path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available "$domain" "$path_url"
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -107,24 +102,21 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
if [ "$path_url" == "/" ]
then
# ynh panel is only for non-root installs
ynh_replace_string " include conf.d/" " #include conf.d/" "../conf/nginx.conf"
else
# add rewrite for alias_traversal protection
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
fi
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_install_app_dependencies php-fpdf php-cli
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
# Create a system user # Create a dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -136,85 +128,84 @@ ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# UPGRADE CONFIG.PHP
#=================================================
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
config="$final_path/app/inc/config.php" config="$final_path/app/inc/config.php"
# Verify the checksum and backup the file if it's different # Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config" ynh_backup_if_checksum_is_different "$config"
#================================================= admin_mail=$(ynh_user_get_info $admin mail)
# Create config.php
#=================================================
admin_mail=$(ynh_user_get_info "$admin" mail)
cp ../conf/config.php "$config" cp ../conf/config.php "$config"
# Change variables in configuration # Change variables in configuration
ynh_replace_string "__DBUSER__" "$dbuser" "$config" ynh_replace_string "__DBUSER__" $db_name "$config"
ynh_replace_string "__DBPWD__" "$dbpass" "$config" db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_replace_string "__DBNAME__" "$db_name" "$config" ynh_replace_string "__DBPWD__" $db_pwd "$config"
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$config" ynh_replace_string "__DBNAME__" $db_name "$config"
ynh_replace_string "__LANGUAGE__" "$language" "$config" ynh_replace_string "__ADMINMAIL__" $admin_mail "$config"
ynh_replace_string "__DOMAIN__" "$domain" "$config" ynh_replace_string "__LANGUAGE__" $language "$config"
ynh_replace_string "__PATH__" "$path_url" "$config" ynh_replace_string "__DOMAIN__" $domain "$config"
ynh_replace_string "__PATH__" $path_url "$config"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
#================================================= #=================================================
# Replace logo image (default is FramaDate) # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE)
#================================================= #=================================================
cp ../img/logo.png "$final_path/images" cp ../img/logo.png "$final_path/images"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # CREATE LOG FILE
#================================================= #=================================================
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
#=================================================
# Create log file
#=================================================
# Create log file
touch "$final_path/admin/stdout.log" touch "$final_path/admin/stdout.log"
#=================================================
# RUN DATABASE UPGRADE
#=================================================
#=================================================
# Set permissions for initilization
chown -R $app: "$final_path"
# Install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$final_path/.composer" \
php -- --quiet --install-dir="$final_path" \
|| ynh_die "Unable to install Composer"
# Update dependencies to create composer.lock
exec_as $app COMPOSER_HOME="$final_path/.composer" \
php "$final_path/composer.phar" install --no-dev \
-d "$final_path" --quiet --no-interaction \
|| ynh_die "Unable to update core dependencies with Composer"
ynh_exec_warn_less exec_as $app php "$final_path/admin/migration.php"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# Run database initilization
#=================================================
# Set initial permissions for initilization
chown -R "$app": "$final_path"
init_composer "$app" "$final_path"
sudo -u "$app" php "$final_path/admin/migration.php"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
chown -R root: "$final_path" chown -R root: "$final_path"
chown -R "$app": "$final_path/tpl_c" chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
chown -R "$app": "$final_path/admin/stdout.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_app_setting_set "$app" skipped_uris "/" # Make app public if necessary
if [ $is_public -eq 1 ]
if [ $is_public -eq 0 ];
then then
ynh_app_setting_set "$app" protected_uris "/" ynh_app_setting_set $app skipped_uris "/"
else # Keep /admin private
ynh_app_setting_set "$app" protected_uris "/admin" ynh_app_setting_set $app protected_uris "/admin"
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
ynh_store_file_checksum "$finalnginxconf"
fi fi
#================================================= #=================================================
@ -222,3 +213,4 @@ fi
#================================================= #=================================================
systemctl reload nginx systemctl reload nginx