1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00
This commit is contained in:
Éric Gaspar 2023-02-04 21:08:46 +01:00
parent c2a3f0ec5b
commit 54d609c124
9 changed files with 231 additions and 155 deletions

View file

@ -2,7 +2,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/www/; alias __INSTALL_DIR__/www/;
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
#client_max_body_size 1G; #client_max_body_size 1G;

View file

@ -2,7 +2,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/www/; alias __INSTALL_DIR__/www/;
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
#client_max_body_size 1G; #client_max_body_size 1G;

76
manifest.toml Normal file
View file

@ -0,0 +1,76 @@
packaging_format = 2
id = "my_webapp"
name = "My Webapp"
description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files"
description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP"
version = "1.0~ynh12"
maintainers = []
[upstream]
license = "GPL-3.0-only"
code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
website = "https://github.com/YunoHost-Apps/my_webapp_ynh"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 11.0.9"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = true
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/site"
[install.with_sftp]
ask.en = "Do you need a SFTP access?"
ask.fr = "Avez-vous besoin d'un accès SFTP ?"
type = "boolean"
default = true
[install.password]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "password"
optional = true
[install.init_main_permission]
type = "group"
default = "visitors"
[install.phpversion]
ask.en = "Choose a PHP version you want to use for your app"
ask.fr = "Choisissez une version PHP que vous souhaitez utiliser pour votre application"
type = "string"
choices = ["none", "7.3", "7.4", "8.0", "8.1", "8.2"]
default = "7.4"
[install.with_mysql]
ask.en = "Do you need a MySQL database?"
ask.fr = "Avez-vous besoin d'une base de données MySQL ?"
type = "boolean"
default = false
[resources]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.database]
type = "mysql"

View file

@ -31,7 +31,7 @@ ynh_send_readme_to_admin() {
type="${type:-install}" type="${type:-install}"
# Get the value of admin_mail_html # Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) #REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}" admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users # Retrieve the email of users
@ -150,12 +150,12 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
#================================================= #=================================================
ynh_maintenance_mode_ON () { ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) #REMOVEME? path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) #REMOVEME? domain=$(ynh_app_setting_get $app domain)
fi fi
mkdir -p /var/www/html/ mkdir -p /var/www/html/
@ -182,10 +182,10 @@ ynh_maintenance_mode_ON () {
</html>" > "/var/www/html/maintenance.$app.html" </html>" > "/var/www/html/maintenance.$app.html"
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead. # Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file # Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ { location ${path}_maintenance/ {
alias /var/www/html/ ; alias /var/www/html/ ;
try_files maintenance.$app.html =503; try_files maintenance.$app.html =503;
@ -196,7 +196,7 @@ include conf.d/yunohost_panel.conf.inc;
# The current config file will redirect all requests to the root of the app. # The current config file will redirect all requests to the root of the app.
# To keep the full path, we can use the following rewrite rule: # To keep the full path, we can use the following rewrite rule:
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries. # The difference will be in the $1 at the end, which keep the following queries.
# But, if it works perfectly for a html request, there's an issue with any php files. # But, if it works perfectly for a html request, there's an issue with any php files.
# This files are treated as simple files, and will be downloaded by the browser. # This files are treated as simple files, and will be downloaded by the browser.
@ -206,16 +206,16 @@ include conf.d/yunohost_panel.conf.inc;
} }
ynh_maintenance_mode_OFF () { ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) #REMOVEME? path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) #REMOVEME? domain=$(ynh_app_setting_get $app domain)
fi fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
@ -265,7 +265,7 @@ ynh_app_changelog () {
return 0 return 0
fi fi
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") #REMOVEME? local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
# Get the line of the version to update to into the changelog # Get the line of the version to update to into the changelog

View file

@ -14,21 +14,21 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) #REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) #REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -39,7 +39,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -14,51 +14,51 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH #REMOVEME? path=$YNH_APP_ARG_PATH
with_sftp=$YNH_APP_ARG_WITH_SFTP #REMOVEME? with_sftp=$YNH_APP_ARG_WITH_SFTP
password=$YNH_APP_ARG_PASSWORD #REMOVEME? password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
phpversion=$YNH_APP_ARG_PHPVERSION #REMOVEME? phpversion=$YNH_APP_ARG_PHPVERSION
with_mysql=$YNH_APP_ARG_WITH_MYSQL #REMOVEME? with_mysql=$YNH_APP_ARG_WITH_MYSQL
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER app_nb=$YNH_APP_INSTANCE_NUMBER
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2 #REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
[ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP" [ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." #REMOVEME? ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=with_mysql --value=$with_mysql ynh_app_setting_set --app=$app --key=with_mysql --value=$with_mysql
ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
ynh_app_setting_set --app=$app --key=password --value="$password" #REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -68,9 +68,9 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
if [ $phpversion != "none" ] if [ $phpversion != "none" ]
then then
ynh_script_progression --message="Installing dependencies..." --weight=2 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2
ynh_install_app_dependencies "php${phpversion}-fpm" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
fi fi
#================================================= #=================================================
@ -79,13 +79,13 @@ fi
if [ $with_mysql -eq 1 ] if [ $with_mysql -eq 1 ]
then then
ynh_script_progression --message="Creating a MySQL database..." --weight=2 #REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2
ynh_install_app_dependencies "php${phpversion}-mysql" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name #REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
fi fi
#================================================= #=================================================
@ -108,7 +108,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." #REMOVEME? ynh_script_progression --message="Configuring system user..."
if [ $with_sftp -eq 1 ] if [ $with_sftp -eq 1 ]
then then
@ -117,7 +117,7 @@ else
groups="" groups=""
fi fi
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ $with_sftp -eq 1 ] if [ $with_sftp -eq 1 ]
then then
@ -131,16 +131,16 @@ fi
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
mkdir -p "$final_path/www" mkdir -p "$install_dir/www"
if [ $with_sftp -eq 1 ] if [ $with_sftp -eq 1 ]
then then
ynh_add_config --template="../sources/www/index.html" --destination="$final_path/www/index.html" ynh_add_config --template="../sources/www/index.html" --destination="$install_dir/www/index.html"
else else
# Copy files to the right place # Copy files to the right place
cp "../sources/www/index_no_sftp.html" "$final_path/www/index.html" cp "../sources/www/index_no_sftp.html" "$install_dir/www/index.html"
fi fi
if [ $with_mysql -eq 1 ]; then if [ $with_mysql -eq 1 ]; then
@ -149,16 +149,16 @@ if [ $with_mysql -eq 1 ]; then
name: ${db_name}\nuser: ${db_name}\npass: ${db_pwd}" > ../sources/db_access.txt name: ${db_name}\nuser: ${db_name}\npass: ${db_pwd}" > ../sources/db_access.txt
# Copy files to the right place # Copy files to the right place
cp -r "../sources/db_access.txt" "$final_path/db_access.txt" cp -r "../sources/db_access.txt" "$install_dir/db_access.txt"
fi fi
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow # Home directory of the user needs to be owned by root to allow
# SFTP connections # SFTP connections
chown root:root "$final_path" chown root:root "$install_dir"
setfacl -m g:$app:r-x "$final_path" setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$final_path" setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -190,20 +190,20 @@ fi
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." #REMOVEME? ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] #REMOVEME? if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission="main" --add="visitors" #REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
@ -216,7 +216,7 @@ if [ $with_mysql -eq 1 ]
then then
sql_infos=" sql_infos="
You've asked for a database, please find here the information about this SQL database. You've asked for a database, please find here the information about this SQL database.
$(cat "$final_path/db_access.txt") $(cat "$install_dir/db_access.txt")
" "
else else
sql_infos="" sql_infos=""
@ -235,7 +235,7 @@ fi
echo "This app is simply a blank web app container. You have to put your own app inside. echo "This app is simply a blank web app container. You have to put your own app inside.
$sql_infos $sql_infos
Please put your files into this directory: $final_path/www/ Please put your files into this directory: $install_dir/www/
$sftp_infos $sftp_infos
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.

View file

@ -12,17 +12,17 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) #REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) #REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -31,19 +31,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
if [ $with_mysql -eq 1 ]; then if [ $with_mysql -eq 1 ]; then
ynh_script_progression --message="Removing the MySQL database..." --weight=2 #REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=2
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
fi fi
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." #REMOVEME? ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -70,10 +70,10 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." #REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app #REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -14,31 +14,31 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=2 ynh_script_progression --message="Loading settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) #REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) #REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
password=$(ynh_app_setting_get --app=$app --key=password) #REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2 #REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -48,9 +48,9 @@ test ! -d $final_path \
if [ $phpversion != "none" ] if [ $phpversion != "none" ]
then then
ynh_script_progression --message="Reinstalling dependencies..." --weight=2 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=2
ynh_install_app_dependencies "php${phpversion}-fpm" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
fi fi
#================================================= #=================================================
@ -64,19 +64,19 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
if [ $with_mysql -eq 1 ]; then if [ $with_mysql -eq 1 ]; then
ynh_script_progression --message="Restoring the MySQL database..." #REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
ynh_install_app_dependencies "php${phpversion}-mysql" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd #REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
fi fi
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
if [ $with_sftp -eq 1 ] if [ $with_sftp -eq 1 ]
then then
@ -85,7 +85,7 @@ else
groups="" groups=""
fi fi
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ -n "$password" ] if [ -n "$password" ]
then then
@ -98,16 +98,16 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
# Restore permissions on app files # Restore permissions on app files
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow # Home directory of the user needs to be owned by root to allow
# SFTP connections # SFTP connections
chown root:root "$final_path" chown root:root "$install_dir"
setfacl -m g:$app:r-x "$final_path" setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$final_path" setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION

View file

@ -12,24 +12,24 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) #REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) #REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
password=$(ynh_app_setting_get --app=$app --key=password) #REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) #REMOVEME? admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) #REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) #REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -40,16 +40,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
# restore it if the upgrade fails # restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -59,19 +59,19 @@ ynh_script_progression --message="Ensuring downward compatibility..."
# 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 --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi fi
# If final_path doesn't exist, create it # If install_dir doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z "$install_dir" ]; then
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi fi
# If admin_mail_html doesn't exist, create it # If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then if [ -z "$admin_mail_html" ]; then
admin_mail_html=1 admin_mail_html=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html #REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
fi fi
# If fpm_footprint doesn't exist, create it # If fpm_footprint doesn't exist, create it
@ -105,22 +105,22 @@ if [ -z "$phpversion" ]; then
fi fi
# Delete old user # Delete old user
if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] #REMOVEME? if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ]
then then
ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop
ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" #REMOVEME? #REMOVEME? ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)"
ynh_app_setting_delete --app=$app --key=user ynh_app_setting_delete --app=$app --key=user
fi fi
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then #REMOVEME? if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all #REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
# Ensure password is a setting even if empty, for the config panel # Ensure password is a setting even if empty, for the config panel
ynh_app_setting_set --app=$app --key=password --value="$password" #REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password"
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
@ -137,14 +137,14 @@ ynh_maintenance_mode_ON
if [ $phpversion != "none" ] if [ $phpversion != "none" ]
then then
ynh_script_progression --message="Installing dependencies..." --weight=2 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2
ynh_install_app_dependencies "php${phpversion}-fpm" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
fi fi
if [ $with_mysql -eq 1 ] if [ $with_mysql -eq 1 ]
then then
ynh_install_app_dependencies "php${phpversion}-mysql" #REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
fi fi
#================================================= #=================================================
@ -168,7 +168,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
if [ $with_sftp -eq 1 ] if [ $with_sftp -eq 1 ]
then then
@ -177,7 +177,7 @@ else
groups="" groups=""
fi fi
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ -n "$password" ] if [ -n "$password" ]
then then
@ -211,20 +211,20 @@ fi
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow # Home directory of the user needs to be owned by root to allow
# SFTP connections # SFTP connections
chown root:root "$final_path" chown root:root "$install_dir"
setfacl -m g:$app:r-x "$final_path" setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$final_path" setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
@ -242,7 +242,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
# Build the changelog # Build the changelog
# Get the value of admin_mail_html # Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) #REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}" admin_mail_html="${admin_mail_html:-0}"
# If a html email is required. Apply html to the changelog. # If a html email is required. Apply html to the changelog.
if [ "$admin_mail_html" -eq 1 ]; then if [ "$admin_mail_html" -eq 1 ]; then