mirror of
https://github.com/YunoHost-Apps/leed_ynh.git
synced 2024-09-03 19:26:32 +02:00
Merge pull request #15 from YunoHost-Apps/testing
Panel-config + actions fully tested
This commit is contained in:
commit
e7ae8393cd
7 changed files with 252 additions and 4 deletions
20
actions.json
Normal file
20
actions.json
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
[{
|
||||||
|
"id": "public_private",
|
||||||
|
"name": "Move to public or private",
|
||||||
|
"command": "/bin/bash scripts/actions/public_private",
|
||||||
|
"user": "root",
|
||||||
|
"accepted_return_codes": [0],
|
||||||
|
"description": {
|
||||||
|
"en": "Change the public access of the app."
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"name": "is_public",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "Is it a public app ?"
|
||||||
|
},
|
||||||
|
"default": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
37
config_panel.json
Normal file
37
config_panel.json
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "Leed configuration panel",
|
||||||
|
"version": "0.1",
|
||||||
|
"panel": [{
|
||||||
|
"name": "Leed configuration",
|
||||||
|
"id": "main",
|
||||||
|
"sections": [{
|
||||||
|
"name": "Public access",
|
||||||
|
"id": "is_public",
|
||||||
|
"options": [{
|
||||||
|
"name": "Is it a public app ?",
|
||||||
|
"id": "is_public",
|
||||||
|
"type": "bool",
|
||||||
|
"default": true
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Overwriting config files",
|
||||||
|
"id": "overwrite_files",
|
||||||
|
"options": [{
|
||||||
|
"name": "Overwrite the nginx config file ?",
|
||||||
|
"help": "If the file is overwritten, a backup will be created.",
|
||||||
|
"id": "overwrite_nginx",
|
||||||
|
"type": "bool",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Overwrite the php-fpm config file ?",
|
||||||
|
"help": "If the file is overwritten, a backup will be created.",
|
||||||
|
"id": "overwrite_phpfpm",
|
||||||
|
"type": "bool",
|
||||||
|
"default": true
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -30,6 +30,24 @@ IS_PACKAGE_CHECK () {
|
||||||
return $(env | grep -c container=lxc)
|
return $(env | grep -c container=lxc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BOOLEAN CONVERTER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
bool_to_01 () {
|
||||||
|
local var="$1"
|
||||||
|
[ "$var" = "true" ] && var=1
|
||||||
|
[ "$var" = "false" ] && var=0
|
||||||
|
echo "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_to_true_false () {
|
||||||
|
local var="$1"
|
||||||
|
[ "$var" = "1" ] && var=true
|
||||||
|
[ "$var" = "0" ] && var=false
|
||||||
|
echo "$var"
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
61
scripts/actions/public_private
Executable file
61
scripts/actions/public_private
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Get is_public
|
||||||
|
is_public=${YNH_ACTION_IS_PUBLIC}
|
||||||
|
|
||||||
|
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF ARGUMENTS ARE CORRECT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF AN ACTION HAS TO BE DONE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
is_public_old=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
|
if [ $is_public -eq $is_public_old ]
|
||||||
|
then
|
||||||
|
ynh_die "is_public is already set as $is_public." 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC ACTION
|
||||||
|
#=================================================
|
||||||
|
# MOVE TO PUBLIC OR PRIVATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ $is_public -eq 0 ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_delete $app unprotected_uris
|
||||||
|
# Rend la page d'actualisation accessible pour le script cron.
|
||||||
|
ynh_app_setting_set $app skipped_uris "/action.php"
|
||||||
|
else
|
||||||
|
ynh_app_setting_delete $app skipped_uris
|
||||||
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Regen ssowat configuration
|
||||||
|
yunohost app ssowatconf
|
||||||
|
|
||||||
|
# Update the config of the app
|
||||||
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload nginx
|
88
scripts/config
Normal file
88
scripts/config
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD VALUES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Load the real value from the app config or elsewhere.
|
||||||
|
# Then get the value from the form.
|
||||||
|
# If the form has a value for a variable, take the value from the form,
|
||||||
|
# Otherwise, keep the value from the app config.
|
||||||
|
|
||||||
|
# is_public
|
||||||
|
old_is_public="$(ynh_app_setting_get $app is_public)"
|
||||||
|
old_is_public=$(bool_to_true_false $old_is_public)
|
||||||
|
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
||||||
|
|
||||||
|
# Overwrite nginx configuration
|
||||||
|
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
|
||||||
|
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
|
||||||
|
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
|
||||||
|
|
||||||
|
# Overwrite php-fpm configuration
|
||||||
|
old_overwrite_phpfpm="$(ynh_app_setting_get $app overwrite_phpfpm)"
|
||||||
|
old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
|
||||||
|
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
show_config() {
|
||||||
|
# here you are supposed to read some config file/database/other then print the values
|
||||||
|
# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||||
|
|
||||||
|
echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
|
||||||
|
|
||||||
|
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||||
|
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY THE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
apply_config() {
|
||||||
|
# Change public accessibility
|
||||||
|
if [ "$is_public" = "true" ]
|
||||||
|
then
|
||||||
|
yunohost app action run $app public_private --args is_public=1
|
||||||
|
else
|
||||||
|
yunohost app action run $app public_private --args is_public=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set overwrite_nginx
|
||||||
|
overwrite_nginx=$(bool_to_01 $overwrite_nginx)
|
||||||
|
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
|
||||||
|
# Set overwrite_phpfpm
|
||||||
|
overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
|
||||||
|
ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
show) show_config;;
|
||||||
|
apply) apply_config;;
|
||||||
|
esac
|
|
@ -50,6 +50,8 @@ ynh_webpath_register $app $domain $path_url
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set $app admin $admin
|
||||||
ynh_app_setting_set $app language $language
|
ynh_app_setting_set $app language $language
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set $app domain $domain
|
||||||
|
ynh_app_setting_set $app overwrite_nginx "1"
|
||||||
|
ynh_app_setting_set $app overwrite_phpfpm "1"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
|
|
@ -22,6 +22,8 @@ is_public=$(ynh_app_setting_get $app is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
|
||||||
|
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -34,12 +36,12 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
# FIX OLD THINGS
|
# FIX OLD THINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ -z $final_path ]; then # Si final_path n'est pas renseigné dans app setting
|
if [ -z "$final_path" ]; then # Si final_path n'est pas renseigné dans app setting
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting
|
if [ -z "$db_name" ]; then # Si db_name n'est pas renseigné dans app setting
|
||||||
db_name=$(ynh_make_valid_dbid $app)
|
db_name=$(ynh_make_valid_dbid $app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set $app db_name $db_name
|
||||||
fi
|
fi
|
||||||
|
@ -62,6 +64,18 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If overwrite_nginx doesn't exist, create it
|
||||||
|
if [ -z "$overwrite_nginx" ]; then
|
||||||
|
overwrite_nginx=1
|
||||||
|
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If overwrite_phpfpm doesn't exist, create it
|
||||||
|
if [ -z "$overwrite_phpfpm" ]; then
|
||||||
|
overwrite_phpfpm=1
|
||||||
|
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -102,7 +116,11 @@ fi
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_nginx_config
|
# Overwrite the nginx configuration only if it's allowed
|
||||||
|
if [ $overwrite_nginx -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_add_nginx_config
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -114,7 +132,11 @@ ynh_system_user_create $app # Create the dedicated user, if not exist
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
|
# Overwrite the php-fpm configuration only if it's allowed
|
||||||
|
if [ $overwrite_phpfpm -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
|
Loading…
Add table
Reference in a new issue