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:20:44 +01:00
parent 54d609c124
commit ff58e1d00c
8 changed files with 67 additions and 221 deletions

View file

@ -17,22 +17,20 @@ cpe = "???" # FIXME: optional but recommended if relevant, this is meant to cont
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"]
yunohost = ">= 11.1.5"
architectures = "all"
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, ...
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[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"
@ -43,7 +41,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
default = true
[install.password]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "password"
optional = true

View file

@ -31,7 +31,7 @@ ynh_send_readme_to_admin() {
type="${type:-install}"
# Get the value of admin_mail_html
#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
@ -152,10 +152,10 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
ynh_maintenance_mode_ON () {
# Load value of $path and $domain from the config if their not set
if [ -z $path ]; then
#REMOVEME? path=$(ynh_app_setting_get $app path)
path=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get $app domain)
fi
mkdir -p /var/www/html/
@ -208,10 +208,10 @@ include conf.d/yunohost_panel.conf.inc;
ynh_maintenance_mode_OFF () {
# Load value of $path and $domain from the config if their not set
if [ -z $path ]; then
#REMOVEME? path=$(ynh_app_setting_get $app path)
path=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get $app domain)
fi
# Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.

View file

@ -9,26 +9,13 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_print_info --message="Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP

View file

@ -9,56 +9,28 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
#REMOVEME? path=$YNH_APP_ARG_PATH
#REMOVEME? with_sftp=$YNH_APP_ARG_WITH_SFTP
#REMOVEME? password=$YNH_APP_ARG_PASSWORD
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
#REMOVEME? phpversion=$YNH_APP_ARG_PHPVERSION
#REMOVEME? with_mysql=$YNH_APP_ARG_WITH_MYSQL
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
app_nb=$YNH_APP_INSTANCE_NUMBER
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2
[ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP"
# Register (book) web path
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
ynh_script_progression --message="Storing installation settings..."
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#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_sftp --value=$with_sftp
#REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password"
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
# STANDARD MODIFICATIONS
@ -68,9 +40,9 @@ ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
if [ $phpversion != "none" ]
then
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2
ynh_script_progression --message="Installing dependencies..." --weight=2
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
ynh_install_app_dependencies "php${phpversion}-fpm"
fi
#=================================================
@ -79,13 +51,13 @@ fi
if [ $with_mysql -eq 1 ]
then
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2
ynh_script_progression --message="Creating a MySQL database..." --weight=2
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
ynh_install_app_dependencies "php${phpversion}-mysql"
db_name=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
fi
#=================================================
@ -117,7 +89,7 @@ else
groups=""
fi
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ $with_sftp -eq 1 ]
then
@ -185,26 +157,6 @@ else
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=0
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================
#REMOVEME? ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
#REMOVEME? if [ $is_public -eq 1 ]
then
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================

View file

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

View file

@ -21,24 +21,8 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_script_progression --message="Loading settings..." --weight=2
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=2
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#=================================================
# STANDARD RESTORATION STEPS
@ -48,9 +32,9 @@ ynh_script_progression --message="Loading settings..." --weight=2
if [ $phpversion != "none" ]
then
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=2
ynh_script_progression --message="Reinstalling dependencies..." --weight=2
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
ynh_install_app_dependencies "php${phpversion}-fpm"
fi
#=================================================
@ -64,19 +48,19 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
if [ $with_mysql -eq 1 ]; then
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
ynh_script_progression --message="Restoring the MySQL database..."
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
ynh_install_app_dependencies "php${phpversion}-mysql"
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
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
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
if [ $with_sftp -eq 1 ]
then
@ -85,7 +69,7 @@ else
groups=""
fi
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ -n "$password" ]
then
@ -118,10 +102,6 @@ then
ynh_restore_file --origin_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf"
fi
#=================================================
# SPECIFIC RESTORATION
#=================================================
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -12,24 +12,16 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
ynh_script_progression --message="Loading installation settings..." --weight=2
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password)
#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)
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK VERSION
@ -37,37 +29,11 @@ source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi
# If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then
admin_mail_html=1
@ -105,22 +71,15 @@ if [ -z "$phpversion" ]; then
fi
# Delete old user
#REMOVEME? if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ]
if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ]
then
ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop
#REMOVEME? #REMOVEME? ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)"
ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)"
ynh_app_setting_delete --app=$app --key=user
fi
# Cleaning legacy permissions
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Ensure password is a setting even if empty, for the config panel
#REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password"
ynh_app_setting_set --app=$app --key=password --value="$password"
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -137,14 +96,14 @@ ynh_maintenance_mode_ON
if [ $phpversion != "none" ]
then
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2
ynh_script_progression --message="Installing dependencies..." --weight=2
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm"
ynh_install_app_dependencies "php${phpversion}-fpm"
fi
if [ $with_mysql -eq 1 ]
then
#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql"
ynh_install_app_dependencies "php${phpversion}-mysql"
fi
#=================================================
@ -177,7 +136,7 @@ else
groups=""
fi
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
if [ -n "$password" ]
then
@ -201,10 +160,6 @@ then
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -219,13 +174,6 @@ setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$install_dir"
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
@ -242,7 +190,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
# Build the changelog
# Get the value of admin_mail_html
#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# If a html email is required. Apply html to the changelog.
if [ "$admin_mail_html" -eq 1 ]; then

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
test_format = 1.0
[default]
# -------------------------------
# Default args to use for install
# -------------------------------
args.with_sftp = "1"
args.phpversion="7.4"
args.with_mysql=1