1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00

Panel-config + actions fully tested

This commit is contained in:
Maniack Crudelis 2018-09-30 11:52:12 +02:00
parent 9d213db608
commit 6cf6b63311
12 changed files with 642 additions and 17 deletions

64
actions.json Normal file
View file

@ -0,0 +1,64 @@
[{
"id": "clean_ip",
"name": "Clean old ip from database",
"command": "/bin/bash scripts/actions/clean_ip",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Remove obsolete IP from the database.",
"fr": "Supprime les IP obsolètes de la base de donnée."
}
},
{
"id": "clean_images",
"name": "Clean old images",
"command": "/bin/bash scripts/actions/clean_images",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Remove expired images.",
"fr": "Supprime les images dont le délai a expiré."
}
},
{
"id": "check_quota",
"name": "Check disk quota",
"command": "/bin/bash scripts/actions/check_quota",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Check the disk quota for images stored by Lutim.",
"fr": "Vérifie l'occupation de l'espace du dossier des images."
}
},
{
"id": "reset_default_config",
"name": "Reset the config file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"lutim.conf\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the config file lutim.conf.",
"fr": "Réinitialise le fichier de configuration lutim.conf."
}
},
{
"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
}
]
}]

View file

@ -1,11 +1,11 @@
# Génération des statistiques. Tous les jours, à 5h. # Génération des statistiques. Tous les jours, à 5h.
0 5 * * * www-data cd "__FINALPATH__" && /usr/local/bin/carton exec script/lutim cron stats 0 5 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron stats
# Suppression des adresses IP obsolètes. Tous les jours, à 6h. # Suppression des adresses IP obsolètes. Tous les jours, à 6h.
0 6 * * * www-data cd "__FINALPATH__" && /usr/local/bin/carton exec script/lutim cron cleanbdd 0 6 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanbdd
# Suppression des images dont le délai a expiré. Tous les jours, à 6h. # Suppression des images dont le délai a expiré. Tous les jours, à 6h.
0 6 * * * www-data cd "__FINALPATH__" && /usr/local/bin/carton exec script/lutim cron cleanfiles 0 6 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanfiles
# Vérification de l'occupation du dossier des images. Tous les jours, à 7h. # Vérification de l'occupation du dossier des images. Tous les jours, à 7h.
0 7 * * * www-data cd "__FINALPATH__" && /usr/local/bin/carton exec script/lutim cron watch 0 7 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron watch

69
config_panel.json Normal file
View file

@ -0,0 +1,69 @@
{
"name": "Lutim configuration panel",
"version": "0.1",
"panel": [{
"name": "Lutim configuration",
"id": "main",
"sections": [{
"name": "Lutim configuration",
"id": "configuration",
"options": [{
"name": "Force the encryption of images ?",
"id": "always_encrypt",
"type": "bool",
"default": true
},
{
"name": "Anti-flood protection delay (seconds)",
"help": "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds.",
"id": "antiflood",
"type": "number",
"default": 0
},
{
"name": "Default time limit for files",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>None, Day, Week, Month, Year.",
"id": "delay",
"type": "text",
"//": "\"choices\" : [\"None\", \"Day\", \"Week\", \"Month\", \"Year\"]",
"default" : "Year"
}]
},
{
"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 config file lutim.conf ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_settings",
"type": "bool",
"default": true
},
{
"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 systemd config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_systemd",
"type": "bool",
"default": true
}]
}]
}
]
}

View file

@ -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
#================================================= #=================================================
@ -517,7 +535,7 @@ EOF
ynh_store_file_checksum "$finalfail2banjailconf" ynh_store_file_checksum "$finalfail2banjailconf"
ynh_store_file_checksum "$finalfail2banfilterconf" ynh_store_file_checksum "$finalfail2banfilterconf"
systemctl reload fail2ban systemctl restart fail2ban
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")" local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
if [ -n "$fail2ban_error" ] if [ -n "$fail2ban_error" ]
then then
@ -532,7 +550,7 @@ EOF
ynh_remove_fail2ban_config () { ynh_remove_fail2ban_config () {
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
systemctl reload fail2ban systemctl restart fail2ban
} }
#================================================= #=================================================

34
scripts/actions/check_quota Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_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)
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
#=================================================
# SPECIFIC ACTION
#=================================================
# CHECK THE DISK QUOTA FOR IMAGES STORED BY LUTIM
#=================================================
(cd "$final_path" && $(which carton) exec script/lutim cron watch)

34
scripts/actions/clean_images Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_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)
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
#=================================================
# SPECIFIC ACTION
#=================================================
# REMOVE EXPIRED IMAGES
#=================================================
(cd "$final_path" && $(which carton) exec script/lutim cron cleanfiles)

34
scripts/actions/clean_ip Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_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)
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
#=================================================
# SPECIFIC ACTION
#=================================================
# REMOVE OBSOLETE IP FROM THE DATABASE
#=================================================
(cd "$final_path" && $(which carton) exec script/lutim cron cleanbdd)

66
scripts/actions/public_private Executable file
View file

@ -0,0 +1,66 @@
#!/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}
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
#=================================================
# 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
# Si l'app est privée, seul le visionnage des images reste public
if [ "$path_url" == "/" ]; then
path_url="" # Si path correspond à la racine, supprime le / pour éviter une erreur de la regex.
fi
# Modifie le domaine pour qu'il passe dans une regex
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$"
else
ynh_app_setting_delete $app protected_regex
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

View file

@ -0,0 +1,60 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_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)
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port)
always_encrypt=$(ynh_app_setting_get $app always_encrypt)
secret=$(ynh_app_setting_get $app secret)
#=================================================
# SORT OUT THE CONFIG FILE TO HANDLE
#=================================================
file="$1"
if [ "$file" = "lutim.conf" ]; then
config_file="$final_path/lutim.conf"
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# RESET THE CONFIG FILE
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config_file"
if [ "$file" = "lutim.conf" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
# Recreate the default config
ynh_replace_string "__DOMAIN__" "$domain" "$config_file"
ynh_replace_string "__PATH__" "$path_url" "$config_file"
ynh_replace_string "__PORT__" "$port" "$config_file"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$config_file"
ynh_replace_string "__SECRET__" "$secret" "$config_file"
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file"
# Wait for lutim to be fully started
ynh_check_starting --line_to_match="Manager.*started" --app_log="/var/log/$app/production.log" --timeout="120"

185
scripts/config Normal file
View file

@ -0,0 +1,185 @@
#!/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)
#=================================================
# SPECIFIC CODE
#=================================================
# DECLARE GENERIC FUNCTION
#=================================================
config_file="$final_path/lutim.conf"
get_config_value() {
option_name="$1"
# Get the value of this option in the config file
grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1
}
#=================================================
# 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.
# always_encrypt
old_always_encrypt="$(get_config_value always_encrypt)"
old_always_encrypt=$(bool_to_true_false $old_always_encrypt)
always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}"
# antiflood
old_antiflood="$(get_config_value anti_flood_delay)"
antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
# delay
old_delay="$(get_config_value default_delay)"
if [ $old_delay -eq 0 ]; then
old_delay=None
elif [ $old_delay -eq 1 ]; then
old_delay=Day
elif [ $old_delay -eq 7 ]; then
old_delay=Week
elif [ $old_delay -eq 30 ]; then
old_delay=Month
else
old_delay=Year
fi
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
# 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 settings.json file
old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)"
old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings)
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
# 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 systemd configuration
old_overwrite_systemd="$(ynh_app_setting_get $app overwrite_systemd)"
old_overwrite_systemd=$(bool_to_true_false $old_overwrite_systemd)
overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}"
#=================================================
# 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_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt"
echo "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
echo "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
}
#=================================================
# MODIFY THE CONFIGURATION
#=================================================
apply_config() {
restart_lutim=0
# Change configuration if needed
# always_encrypt
if [ "$always_encrypt" != "$old_always_encrypt" ]
then
always_encrypt=$(bool_to_01 $always_encrypt)
ynh_replace_string ".*always_encrypt *=>.*" " always_encrypt => $always_encrypt," "$config_file"
restart_lutim=1
fi
# antiflood
if [ "$antiflood" != "$old_antiflood" ]
then
ynh_replace_string ".*anti_flood_delay *=>.*" " anti_flood_delay => $antiflood," "$config_file"
# Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then
ynh_replace_string "\(anti_flood_delay *=>.*\)" "#\1" "$config_file"
fi
ynh_app_setting_set $app antiflood "$antiflood"
restart_lutim=1
fi
# delay
if [ "$delay" != "$old_delay" ]
then
if [ $delay = None ]; then
delay=0
elif [ $delay = Day ]; then
delay=1
elif [ $delay = Week ]; then
delay=7
elif [ $delay = Month ]; then
delay=30
else
delay=360
fi
ynh_replace_string ".*default_delay *=>.*" " default_delay => $delay," "$config_file"
ynh_app_setting_set $app delay "$delay"
restart_lutim=1
fi
if [ $restart_lutim -eq 1 ]
then
# Wait for lutim to be fully started
ynh_check_starting --line_to_match="Manager.*started" --app_log="/var/log/$app/production.log" --timeout="120"
fi
# 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_settings
overwrite_settings=$(bool_to_01 $overwrite_settings)
ynh_app_setting_set $app overwrite_settings "$overwrite_settings"
# Set overwrite_nginx
overwrite_nginx=$(bool_to_01 $overwrite_nginx)
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
# Set overwrite_systemd
overwrite_systemd=$(bool_to_01 $overwrite_systemd)
ynh_app_setting_set $app overwrite_systemd "$overwrite_systemd"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
#=================================================
case $1 in
show) show_config;;
apply) apply_config;;
esac

View file

@ -54,6 +54,9 @@ ynh_webpath_register $app $domain $path_url
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app always_encrypt $always_encrypt ynh_app_setting_set $app always_encrypt $always_encrypt
ynh_app_setting_set $app overwrite_settings "1"
ynh_app_setting_set $app overwrite_nginx "1"
ynh_app_setting_set $app overwrite_systemd "1"
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
@ -111,6 +114,7 @@ ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf"
secret=$(ynh_string_random) secret=$(ynh_string_random)
ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf" ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf"
ynh_app_setting_set $app secret "$secret"
ynh_store_file_checksum "$final_path/lutim.conf" # Enregistre la somme de contrôle du fichier de config ynh_store_file_checksum "$final_path/lutim.conf" # Enregistre la somme de contrôle du fichier de config
#================================================= #=================================================

View file

@ -23,6 +23,14 @@ is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
always_encrypt=$(ynh_app_setting_get $app always_encrypt) always_encrypt=$(ynh_app_setting_get $app always_encrypt)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
secret=$(ynh_app_setting_get $app secret)
overwrite_settings=$(ynh_app_setting_get $app overwrite_settings)
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
overwrite_systemd=$(ynh_app_setting_get $app overwrite_systemd)
# Optional parameters from config-panel feature
antiflood=$(ynh_app_setting_get $app antiflood)
delay=$(ynh_app_setting_get $app delay)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -31,7 +39,7 @@ final_path=$(ynh_app_setting_get $app final_path)
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# FIX OLD THINGS # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
@ -56,6 +64,30 @@ elif [ "$always_encrypt" = "No" ]; then
always_encrypt=0 always_encrypt=0
fi fi
# If overwrite_settings doesn't exist, create it
if [ -z "$overwrite_settings" ]; then
overwrite_settings=1
ynh_app_setting_set $app overwrite_settings $overwrite_settings
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_systemd doesn't exist, create it
if [ -z "$overwrite_systemd" ]; then
overwrite_systemd=1
ynh_app_setting_set $app overwrite_systemd $overwrite_systemd
fi
# If secret doesn't exist, create it
if [ -z "$secret" ]; then
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
ynh_app_setting_set $app secret $secret
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -104,7 +136,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
@ -118,20 +154,41 @@ ynh_system_user_create $app # Create the dedicated user, if not exist
# SETUP LUTIM # SETUP LUTIM
#================================================= #=================================================
## Copie et configuration du fichier de conf. # Overwrite the settings config file only if it's allowed
ynh_backup_if_checksum_is_different "$final_path/lutim.conf" # Créé un backup du fichier de config si il a été modifié. if [ $overwrite_settings -eq 1 ]
cp ../conf/lutim.conf.template "$final_path/lutim.conf" then
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf" ## Copie et configuration du fichier de conf.
ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf" ynh_backup_if_checksum_is_different "$final_path/lutim.conf" # Créé un backup du fichier de config si il a été modifié.
ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf" cp ../conf/lutim.conf.template "$final_path/lutim.conf"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf"
ynh_store_file_checksum "$final_path/lutim.conf" # Réenregistre la somme de contrôle du fichier de config ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf"
ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf"
ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf"
ynh_store_file_checksum "$final_path/lutim.conf" # Réenregistre la somme de contrôle du fichier de config
# Optional parameters from config-panel feature
if [ -n "$antiflood" ]; then
ynh_replace_string ".*anti_flood_delay *=>.*" " anti_flood_delay => $antiflood," "$final_path/lutim.conf"
# Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then
ynh_replace_string "\(anti_flood_delay *=>.*\)" "#\1" "$final_path/lutim.conf"
fi
fi
if [ -n "$delay" ]; then
ynh_replace_string ".*default_delay *=>.*" " default_delay => $delay," "$final_path/lutim.conf"
fi
fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_add_systemd_config # Overwrite the systemd configuration only if it's allowed
if [ $overwrite_systemd -eq 1 ]
then
ynh_add_systemd_config
fi
#================================================= #=================================================
# SETUP CRON # SETUP CRON