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:
parent
5a144d1e1d
commit
48580d3df0
11 changed files with 266 additions and 272 deletions
74
README.md
74
README.md
|
@ -1,19 +1,69 @@
|
|||
opensondage_ynh
|
||||
===============
|
||||
# OpenSondage for YunoHost
|
||||
|
||||
OpenSondage for YunoHost
|
||||
[](https://dash.yunohost.org/appci/app/opensondage)
|
||||
[](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
|
||||
This package contains a custom version of Framadate (fork of OpenSondage and Studs), the sources are here: https://git.framasoft.org/framasoft/framadate/.
|
||||
## Overview
|
||||
|
||||
## 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
|
||||
2. There is no way to use SSOWAT to identify current user. See https://framagit.org/framasoft/framadate/issues/177
|
||||
**Shipped version:** 1.0.3
|
||||
|
||||
## Screenshot
|
||||
## Screenshots
|
||||
|
||||
<img src="/sources/images/date.png" style="max-width:100%;" alt="Screen containing a meeting poll"/>
|
||||
<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 - [](https://ci-apps.yunohost.org/ci/apps/opensondage/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/opensondage/)
|
||||
* Jessie x86-64b - [](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
|
||||
```
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
;; Test complet
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
|
@ -19,6 +18,7 @@
|
|||
multi_instance=1
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
|
|
|
@ -2,3 +2,5 @@ SOURCE_URL=https://git.framasoft.org/framasoft/framadate/framadate/repository/1.
|
|||
SOURCE_SUM=aa372ac8b7f0f7b0ad4ab973a5cfb7db5aa3b95a1ea584e3c57c8929d3766169
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.bz2
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
index index.php;
|
||||
try_files $uri $uri/ /index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
|
@ -16,6 +20,7 @@ location __PATH__/ {
|
|||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_param HTTPS on;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
"name": "OpenSondage",
|
||||
"id": "opensondage",
|
||||
"packaging_format": 1,
|
||||
"url": "https://git.framasoft.org/framasoft/framadate",
|
||||
"version": "1.0.3",
|
||||
"license": "CECILL-B",
|
||||
"description": {
|
||||
"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.",
|
||||
"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": {
|
||||
"name": "ljf",
|
||||
"email": "ljf+yunohost@grimaud.me"
|
||||
|
@ -58,6 +58,7 @@
|
|||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the default language of this OpenSondage",
|
||||
"fr": "Choisissez la langue par défault d'OpenSondage",
|
||||
|
@ -76,8 +77,6 @@
|
|||
},
|
||||
"default": true
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Execute a command as another user
|
||||
# usage: exec_as USER COMMAND [ARG ...]
|
||||
exec_as() {
|
||||
local USER=$1
|
||||
shift 1
|
||||
|
||||
if [[ $USER = $(whoami) ]]
|
||||
then
|
||||
eval $@
|
||||
if [[ $USER = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
sudo -u "$USER" $@
|
||||
sudo -u "$USER" "$@"
|
||||
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"
|
||||
}
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -25,12 +20,11 @@ ynh_abort_if_errors
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -38,8 +32,7 @@ domain=$(ynh_app_setting_get "$app" domain)
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
# Backup sources & data
|
||||
ynh_backup "/var/www/$app"
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
134
scripts/install
134
scripts/install
|
@ -20,15 +20,14 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
# 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
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" path_url "$path_url"
|
||||
ynh_app_setting_set "$app" admin "$admin"
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app admin $admin
|
||||
ynh_app_setting_set $app language $language
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -60,25 +57,21 @@ ynh_app_setting_set "$app" is_public "$is_public"
|
|||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies php-fpdf
|
||||
ynh_install_app_dependencies php-fpdf php-cli
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Generate MySQL password and create database
|
||||
dbuser=$app
|
||||
db_name=$app
|
||||
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"
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
ynh_setup_source "$final_path"
|
||||
|
||||
|
@ -86,15 +79,6 @@ ynh_setup_source "$final_path"
|
|||
# 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
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
@ -103,7 +87,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -115,78 +99,79 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# Create config.php
|
||||
# CREATE 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"
|
||||
|
||||
# Change variables in configuration
|
||||
ynh_replace_string "__DBUSER__" "$dbuser" "$config"
|
||||
ynh_replace_string "__DBPWD__" "$dbpass" "$config"
|
||||
ynh_replace_string "__DBNAME__" "$db_name" "$config"
|
||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$config"
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$config"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$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
|
||||
#=================================================
|
||||
ynh_replace_string "__DBUSER__" $db_name "$config"
|
||||
ynh_replace_string "__DBPWD__" $db_pwd "$config"
|
||||
ynh_replace_string "__DBNAME__" $db_name "$config"
|
||||
ynh_replace_string "__ADMINMAIL__" $admin_mail "$config"
|
||||
ynh_replace_string "__LANGUAGE__" $language "$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"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
||||
chown -R root: "$final_path"
|
||||
chown -R "$app": "$final_path/tpl_c"
|
||||
chown -R "$app": "$final_path/admin/stdout.log"
|
||||
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
|
||||
if [ $is_public -eq 0 ];
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set "$app" protected_uris "/"
|
||||
else
|
||||
ynh_app_setting_set "$app" protected_uris "/admin"
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
# Keep /admin private
|
||||
ynh_app_setting_set $app protected_uris "/admin"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -194,3 +179,4 @@ fi
|
|||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
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
|
||||
|
@ -32,15 +33,14 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
db_name=$app
|
||||
dbuser=$app
|
||||
ynh_mysql_remove_db "$db_name" "$dbuser"
|
||||
ynh_mysql_remove_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/var/www/$app"
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -63,4 +63,5 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete "$app"
|
||||
ynh_system_user_delete $app
|
||||
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -29,22 +24,19 @@ ynh_abort_if_errors
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
admin=$(ynh_app_setting_get "$app" admin)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
dbuser=$app
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# 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}"
|
||||
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
|
||||
|
@ -61,19 +53,18 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Set permissions
|
||||
chown -R "$app": "$final_path/tpl_c"
|
||||
chown -R "$app": "$final_path/admin/stdout.log"
|
||||
# Restore permissions on app files
|
||||
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -85,9 +76,9 @@ ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
|||
# RESTORE 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
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -95,7 +86,7 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql
|
|||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Dependences
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies php-fpdf
|
||||
|
||||
#=================================================
|
||||
|
@ -104,6 +95,6 @@ ynh_install_app_dependencies php-fpdf
|
|||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
# Reload Nginx
|
||||
service php5-fpm restart
|
||||
service nginx reload
|
||||
systemctl reload php7.0-fpm
|
||||
systemctl reload nginx
|
||||
|
||||
|
|
174
scripts/upgrade
174
scripts/upgrade
|
@ -10,28 +10,18 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
admin=$(ynh_app_setting_get "$app" admin)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
language=$(ynh_app_setting_get "$app" language)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
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
|
||||
|
@ -39,38 +29,46 @@ language=$(ynh_app_setting_get "$app" language)
|
|||
|
||||
if [ -z "$is_public" ];
|
||||
then
|
||||
is_public=$(ynh_app_setting_get "$app" public_site)
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
ynh_app_setting_delete "$app" public_site
|
||||
is_public=$(ynh_app_setting_get $app public_site)
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_delete $app public_site
|
||||
fi
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" is_public 1
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set "$app" is_public 0
|
||||
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"
|
||||
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
|
||||
if [ -z $final_path ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
|
||||
# make sure default language is set
|
||||
if [ -z "$language" ];
|
||||
# Make sure default language is set
|
||||
if [ -z "$language" ]
|
||||
then
|
||||
language=$(grep LANGUE "/var/www/$app/variables.php" | grep -Po "'.*?'" | cut -d"'" -f2)
|
||||
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
|
||||
#=================================================
|
||||
|
@ -89,10 +87,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -107,24 +102,21 @@ ynh_setup_source "$final_path"
|
|||
# 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
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies php-fpdf php-cli
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -136,85 +128,84 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE CONFIG.PHP
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
config="$final_path/app/inc/config.php"
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
|
||||
#=================================================
|
||||
# Create config.php
|
||||
#=================================================
|
||||
admin_mail=$(ynh_user_get_info $admin mail)
|
||||
|
||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||
cp ../conf/config.php "$config"
|
||||
|
||||
# Change variables in configuration
|
||||
ynh_replace_string "__DBUSER__" "$dbuser" "$config"
|
||||
ynh_replace_string "__DBPWD__" "$dbpass" "$config"
|
||||
ynh_replace_string "__DBNAME__" "$db_name" "$config"
|
||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$config"
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$config"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$config"
|
||||
ynh_replace_string "__PATH__" "$path_url" "$config"
|
||||
ynh_replace_string "__DBUSER__" $db_name "$config"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_replace_string "__DBPWD__" $db_pwd "$config"
|
||||
ynh_replace_string "__DBNAME__" $db_name "$config"
|
||||
ynh_replace_string "__ADMINMAIL__" $admin_mail "$config"
|
||||
ynh_replace_string "__LANGUAGE__" $language "$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"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
||||
chown -R root: "$final_path"
|
||||
chown -R "$app": "$final_path/tpl_c"
|
||||
chown -R "$app": "$final_path/admin/stdout.log"
|
||||
chown -R $app: "$final_path/"{tpl_c,admin/stdout.log}
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
|
||||
if [ $is_public -eq 0 ];
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set "$app" protected_uris "/"
|
||||
else
|
||||
ynh_app_setting_set "$app" protected_uris "/admin"
|
||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
# Keep /admin private
|
||||
ynh_app_setting_set $app protected_uris "/admin"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -222,3 +213,4 @@ fi
|
|||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue