mirror of
https://github.com/YunoHost-Apps/limesurvey_ynh.git
synced 2024-09-03 19:36:32 +02:00
Apply last example_ynh
This commit is contained in:
parent
58cac7dfc0
commit
a82b7f0de4
12 changed files with 180 additions and 162 deletions
19
.gitattributes
vendored
19
.gitattributes
vendored
|
@ -1,19 +0,0 @@
|
|||
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# Declare files that will always have LF line endings on checkout.
|
||||
*.php text eol=lf
|
||||
*.css text eol=lf
|
||||
*.js text eol=lf
|
||||
*.pstpl text eol=lf
|
||||
*.html text eol=lf
|
||||
*.sql text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.lss text eol=lf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.jpg binary
|
||||
*.png binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.mo binary
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
admin="john"
|
||||
language="en"
|
||||
admin="john"
|
||||
password="1Strong-Password"
|
||||
is_admin_public=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
|
@ -13,8 +14,10 @@
|
|||
setup_private=0
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
#3.17.1
|
||||
# 3.17.1~ynh1
|
||||
upgrade=1 from_commit=da4959616e67f89ef907a223f7c84607dc4771e5
|
||||
# 5.2.6~ynh2
|
||||
upgrade=1 from_commit=58cac7dfc0d0b835898d56238e550c775be7255b
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
|
|
|
@ -1,37 +1,32 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/ ;
|
||||
# Path to source
|
||||
alias __FINALPATH__/;
|
||||
|
||||
more_set_headers "X-Frame-Options : ALLOWALL";
|
||||
more_set_headers "X-Frame-Options : ALLOWALL";
|
||||
|
||||
index index.php;
|
||||
index index.php;
|
||||
|
||||
# if (!-e $request_filename)
|
||||
#{
|
||||
# rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
|
||||
#}
|
||||
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
|
||||
client_max_body_size 50M;
|
||||
|
||||
client_max_body_size 50m;
|
||||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
|
||||
try_files $uri $uri/ index.php;
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
location ~ ^__PATH__/(data|config|\.ht|db_structure\.xml|README) {
|
||||
deny all;
|
||||
deny all;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Create and distribute surveys",
|
||||
"fr": "Outil de création et diffusion de sondage"
|
||||
},
|
||||
"version": "5.2.6~ynh2",
|
||||
"version": "5.2.6~ynh3",
|
||||
"url": "https://www.limesurvey.org/",
|
||||
"upstream": {
|
||||
"license": "GPL-2.0+",
|
||||
|
@ -42,10 +42,6 @@
|
|||
"example": "/poll",
|
||||
"default": "/poll"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
|
@ -168,6 +164,14 @@
|
|||
],
|
||||
"default": "en"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password"
|
||||
},
|
||||
{
|
||||
"name": "is_admin_public",
|
||||
"type": "boolean",
|
||||
|
@ -176,10 +180,6 @@
|
|||
"fr": "En mode privé, seuls les utilisateurs YunoHost autorisés peuvent créer un sondage. En mode public, il est possible de créer un sondage avec un compte Limesurvey mais sans compte YunoHost."
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ PKG_DIR=$(cd ../; pwd)
|
|||
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-imap python3-pip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -25,10 +28,10 @@ ynh_print_info --message="Loading installation settings..."
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -41,6 +44,12 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$datadir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -60,13 +69,6 @@ ynh_print_info --message="Backing up the MySQL database..."
|
|||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up data directory..."
|
||||
|
||||
ynh_backup --src_path="$datadir" --is_big
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -67,6 +67,8 @@ then
|
|||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
@ -96,6 +98,8 @@ then
|
|||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
|
@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -22,10 +25,10 @@ ynh_abort_if_errors
|
|||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
is_admin_public=$YNH_APP_ARG_IS_ADMIN_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -47,8 +50,8 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
|
|||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -93,6 +96,15 @@ chmod 750 "$final_path/tmp"
|
|||
chmod 750 "$final_path/upload"
|
||||
chmod 750 "$final_path/application/config/"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -101,23 +113,16 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CREATE THE DATA DIRECTORY
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --weight=1
|
||||
|
||||
datadir=/home/yunohost.app/limesurvey/upload
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
mkdir -p $datadir
|
||||
# Remove upload if empty
|
||||
rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true
|
||||
|
@ -126,23 +131,27 @@ chmod -R o-rwx "$datadir"
|
|||
ln -s $datadir $final_path/upload 2> /dev/null || true
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Limesurvey..." --weight=1
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/config.php" --destination="$final_path/application/config/config.php"
|
||||
|
||||
chmod 400 "$final_path/application/config/config.php"
|
||||
chown $app:$app "$final_path/application/config/config.php"
|
||||
|
||||
#=================================================
|
||||
# INSTALL
|
||||
# INSTALL APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing app..."
|
||||
|
||||
ls_cli=$final_path/application/commands/console.php
|
||||
|
||||
fullname=$(ynh_user_get_info "$admin" "fullname")
|
||||
mail=$(ynh_user_get_info "$admin" "mail")
|
||||
fullname=$(ynh_user_get_info --username="$admin" --key="fullname")
|
||||
mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
||||
|
||||
# Permission should be correctly set before to do this
|
||||
ynh_exec_as "$app" php $ls_cli install "$admin" "$password" "$fullname" "$mail"
|
||||
ynh_exec_as "$app" php$phpversion $ls_cli install "$admin" "$password" "$fullname" "$mail"
|
||||
|
||||
# Permission should be correctly set before to do this
|
||||
#ynh_exec_as "$app" php $ls_cli install "$admin" "$(ynh_string_random 24)" "$fullname" "$mail"
|
||||
|
@ -150,6 +159,8 @@ ynh_exec_as "$app" php $ls_cli install "$admin" "$password" "$fullname" "$mail"
|
|||
#=================================================
|
||||
# LOAD SQL SPECIFIC CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading SQL specific config..."
|
||||
|
||||
ynh_add_config --template="../conf/data.sql" --destination="./data.sql"
|
||||
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./data.sql
|
||||
|
@ -157,30 +168,30 @@ ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name
|
|||
ynh_secure_remove --file=./data.sql
|
||||
|
||||
#=================================================
|
||||
# Add nice themes
|
||||
# ADD NICE THEMES
|
||||
#=================================================
|
||||
#ynh_script_progression --message="Adding nice themes..."
|
||||
|
||||
#ynh_setup_source "$datadir/upload/templates/libreform" libreform
|
||||
#ynh_setup_source "$final_path/upload/templates/librepoll" librepoll
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
# No message in logs and the apps contains already a 10 minutes ban policy
|
||||
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
if [ $is_admin_public -eq 1 ]
|
||||
then
|
||||
allowed_groups="visitors $admin"
|
||||
allowed_groups="visitors $admin"
|
||||
else
|
||||
allowed_groups="$admin"
|
||||
allowed_groups="$admin"
|
||||
fi
|
||||
ynh_permission_update --permission="main" --show_tile="false" --add="visitors"
|
||||
|
||||
ynh_permission_create --permission="admin" --url="/admin" --allowed=$allowed_groups --show_tile="true"
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -24,14 +24,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
@ -41,7 +33,7 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1
|
|||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MAIN DIR OF THE APP
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
|
@ -56,11 +48,11 @@ ynh_secure_remove --file="$final_path"
|
|||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE NGINX CONFIGURATION
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
|
@ -75,6 +67,16 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
|||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
|
|
|
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -27,11 +30,11 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -43,13 +46,6 @@ test ! -d $final_path \
|
|||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -72,11 +68,17 @@ chmod 755 "$final_path/tmp"
|
|||
chmod 755 "$final_path/application/config/"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring data directory..." --weight=2
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
ln -s $datadir $final_path/upload 2> /dev/null || true
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -88,6 +90,20 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
|||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
@ -97,19 +113,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring data directory..." --weight=2
|
||||
|
||||
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
ln -s $datadir $final_path/upload 2> /dev/null || true
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -20,16 +20,18 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
prefix=$(ynh_app_setting_get $app prefix)
|
||||
prefix=$(ynh_app_setting_get --app=$app --key=prefix)
|
||||
is_admin_public=$(ynh_app_setting_get --app=$app --key=is_admin_public)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
|
@ -41,12 +43,14 @@ ynh_script_progression --message="Backing up $app before upgrading (may take a w
|
|||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -54,43 +58,50 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# If datadir doesn't exist, create it
|
||||
if [ -z "$datadir" ]; then
|
||||
datadir=/home/yunohost.app/$app/upload
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
mkdir -p $datadir
|
||||
# Remove upload if empty
|
||||
rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true
|
||||
chown -R $app:www-data "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
ln -s $datadir $final_path/upload
|
||||
datadir=/home/yunohost.app/$app/upload
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
mkdir -p $datadir
|
||||
# Remove upload if empty
|
||||
rmdir $datadir 2> /dev/null && mv "$final_path/upload" $datadir || true
|
||||
chown -R $app:www-data "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
ln -s $datadir $final_path/upload
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_admin_public
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
if ! ynh_permission_exists --permission="admin"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
|
||||
# Create the required permissions
|
||||
if [ $is_admin_public -eq 1 ]
|
||||
then
|
||||
allowed_groups="visitors $admin"
|
||||
else
|
||||
allowed_groups="$admin"
|
||||
fi
|
||||
ynh_permission_create --permission="admin" --url="/admin" --allowed=$allowed_groups --show_tile="true"
|
||||
|
||||
fi
|
||||
|
||||
# Create a permission if needed
|
||||
if ! ynh_permission_exists --permission="api"; then
|
||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -101,18 +112,16 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
|
|||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --keep="$(echo $final_path/plugins/*) $final_path/application/config/config.php $final_path/upload"
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --keep="$(echo $final_path/plugins/*) $final_path/application/config/config.php $final_path/upload"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
|
@ -124,14 +133,6 @@ chown -R $app:www-data "$datadir"
|
|||
chmod 750 $datadir
|
||||
ln -s $datadir $final_path/upload 2> /dev/null || true
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
@ -148,19 +149,35 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
|||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Limesurvey..." --weight=1
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/config.php" --destination="$final_path/application/config/config.php"
|
||||
|
||||
chmod 400 "$final_path/application/config/config.php"
|
||||
chown $app:$app "$final_path/application/config/config.php"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DB
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading DB..."
|
||||
|
||||
# Migrate DB
|
||||
ynh_exec_as "$app" php $final_path/application/commands/console.php updatedb
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue