mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
Remove dummy files or super legacy/unused/misleading stuff...
This commit is contained in:
parent
31bf003d40
commit
3abcce2fad
12 changed files with 0 additions and 718 deletions
52
actions.toml
52
actions.toml
|
@ -1,52 +0,0 @@
|
|||
[clean_ip]
|
||||
name = "Clean old ip from database"
|
||||
command = "/bin/bash scripts/actions/clean_ip"
|
||||
accepted_return_codes = [0]
|
||||
description = "Remove obsolete IP from the database."
|
||||
|
||||
[clean_images]
|
||||
name = "Clean old images"
|
||||
command = "/bin/bash scripts/actions/clean_images"
|
||||
accepted_return_codes = [0]
|
||||
description = "Remove expired images."
|
||||
|
||||
[check_quota]
|
||||
name = "Check disk quota"
|
||||
command = "/bin/bash scripts/actions/check_quota"
|
||||
accepted_return_codes = [0]
|
||||
description = "Check the disk quota for images stored by Lutim."
|
||||
|
||||
[reset_default_config]
|
||||
name = "Reset the config file and restore a default one."
|
||||
command = "/bin/bash scripts/actions/reset_default_config \"lutim.conf\""
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the config file lutim.conf."
|
||||
|
||||
|
||||
[reset_default_nginx]
|
||||
name = "Reset the nginx config for this app."
|
||||
command = "/bin/bash scripts/actions/reset_default_system nginx"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the nginx config for this app."
|
||||
|
||||
[reset_default_systemd]
|
||||
name = "Reset the systemd config for this app."
|
||||
command = "/bin/bash scripts/actions/reset_default_system systemd"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the systemd config for this app."
|
||||
|
||||
|
||||
[reset_default_app]
|
||||
name = "Reset the app with a default configuration."
|
||||
command = "/bin/bash scripts/actions/reset_default_app"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the app to its default configuration to try to fix potential issues.<br>This action won't remove any data added to the app.<br>However, if you have modified any configuration, it will be overwritten."
|
|
@ -1,26 +0,0 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
always_encrypt=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
name=22 May 2020 ec8858ed0d054049a0c8f46c6126ee8ae0798e8f
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1&
|
|
@ -1,55 +0,0 @@
|
|||
version = "0.1"
|
||||
name = "Lutim configuration panel"
|
||||
|
||||
[main]
|
||||
name = "Lutim configuration"
|
||||
|
||||
[main.configuration]
|
||||
name = "Lutim configuration"
|
||||
|
||||
[main.configuration.always_encrypt]
|
||||
ask = "Force the encryption of images?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[main.configuration.antiflood]
|
||||
ask = "Anti-flood protection delay (seconds)"
|
||||
type = "number"
|
||||
default = 0
|
||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||
|
||||
[main.configuration.delay]
|
||||
ask = "Default time limit for files"
|
||||
choices = ["None", "Day", "Week", "Month", "Year"]
|
||||
default = "Year"
|
||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||
|
||||
[main.overwrite_files]
|
||||
name = "Overwriting config files"
|
||||
|
||||
[main.overwrite_files.overwrite_settings]
|
||||
ask = "Overwrite the config file lutim.conf?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.overwrite_files.overwrite_nginx]
|
||||
ask = "Overwrite the nginx config file?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.overwrite_files.overwrite_systemd]
|
||||
ask = "Overwrite the systemd config file?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.global_config]
|
||||
name = "Global configuration"
|
||||
|
||||
[main.global_config.email_type]
|
||||
ask = "Send HTML email to admin?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "Allow app scripts to send HTML mails instead of plain text."
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$1
|
||||
added_users=$2
|
||||
permission=$3
|
||||
added_groups=$4
|
||||
|
||||
if [ "$app" == __APP__ ]; then
|
||||
if [ "$permission" = "upload images" ]; then # The fake permission "upload images" is modifed.
|
||||
if [ "$added_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group.
|
||||
|
||||
# We remove the regex, no more protection is needed.
|
||||
ynh_app_setting_delete --app=$app --key=protected_regex
|
||||
|
||||
# Sync the is_public variable according to the permission
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
|
||||
yunohost app ssowatconf
|
||||
else
|
||||
ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group."
|
||||
fi
|
||||
fi
|
||||
fi
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$1
|
||||
removed_users=$2
|
||||
permission=$3
|
||||
removed_groups=$4
|
||||
|
||||
if [ "$app" == __APP__ ]; then
|
||||
if [ "$permission" = "upload images" ]; then # The fake permission "upload images" is modifed.
|
||||
if [ "$removed_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group.
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$path_url" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
path_url=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
||||
|
||||
# Sync the is_public variable according to the permission
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
|
||||
yunohost app ssowatconf
|
||||
else
|
||||
ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group."
|
||||
fi
|
||||
fi
|
||||
fi
|
|
@ -92,75 +92,3 @@ ynh_maintenance_mode_OFF () {
|
|||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
|
||||
# Check the amount of available RAM
|
||||
#
|
||||
# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
|
||||
# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise.
|
||||
# If --required isn't set, the helper will print the amount of RAM, in Mb.
|
||||
# | arg: -s, --no_swap - Ignore swap
|
||||
# | arg: -o, --only_swap - Ignore real RAM, consider only swap.
|
||||
# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available.
|
||||
ynh_check_ram () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram )
|
||||
local required
|
||||
local no_swap
|
||||
local only_swap
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
required=${required:-}
|
||||
no_swap=${no_swap:-0}
|
||||
only_swap=${only_swap:-0}
|
||||
|
||||
local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}')
|
||||
local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}')
|
||||
local total_ram_swap=$(( total_ram + total_swap ))
|
||||
|
||||
local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}')
|
||||
local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}')
|
||||
local free_ram_swap=$(( free_ram + free_swap ))
|
||||
|
||||
# Use the total amount of ram
|
||||
local ram=$total_ram_swap
|
||||
if [ $free_ram -eq 1 ]
|
||||
then
|
||||
# Use the total amount of free ram
|
||||
ram=$free_ram_swap
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$free_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$free_swap
|
||||
fi
|
||||
else
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$total_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$total_swap
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$required" ]
|
||||
then
|
||||
# Return 1 if the amount of ram isn't enough.
|
||||
if [ $ram -lt $required ]
|
||||
then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If no RAM is required, return the amount of available ram.
|
||||
else
|
||||
echo $ram
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking the disk quota for images stored by lutim..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron watch)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# REMOVE EXPIRED IMAGES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing expired images..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron cleanfiles)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# REMOVE OBSOLETE IP FROM THE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing obsolete ip from the database..." --weight=9
|
||||
|
||||
(cd "$final_path" && ynh_exec_as $app $(which carton) exec script/lutim cron cleanbdd)
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,158 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Load common variables for all scripts.
|
||||
source scripts/_variables
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Activating maintenance mode..."
|
||||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STOP LUTIM
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=stop
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Resetting source files..." --weight=2
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
(cd scripts; YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path")
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Resetting nginx web server configuration..." --weight=4
|
||||
|
||||
# Create a dedicated nginx config
|
||||
yunohost app action run $app reset_default_nginx
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE APP
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Reconfiguring Lutim..." --weight=2
|
||||
|
||||
# Configure Lutim
|
||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
|
||||
(cd scripts; cp ../conf/lutim.conf.template "$final_path/lutim.conf")
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
|
||||
# Set the number of process for Lutim to twice the number of CPU core.
|
||||
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
||||
|
||||
#=================================================
|
||||
# SETUP CRON
|
||||
#=================================================
|
||||
|
||||
(cd scripts; cp ../conf/cron_lutim /etc/cron.d/$app)
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file=/etc/cron.d/$app
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# SECURING FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Resetting systemd configuration..."
|
||||
yunohost app action run $app reset_default_systemd
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Resetting logrotate configuration..."
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
chown $app -R /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Disabling maintenance mode..."
|
||||
|
||||
ynh_maintenance_mode_OFF
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,84 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
|
||||
secret=$(ynh_app_setting_get --app=$app --key=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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different --file="$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 --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
|
||||
# Set the number of process for Lutim to twice the number of CPU core.
|
||||
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
ynh_script_progression --message="Restarting Lutim..." --weight=5
|
||||
|
||||
# Wait for lutim to be fully started
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
type=$1
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# RESET THE CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
if [ $type == nginx ]; then
|
||||
name=Nginx
|
||||
elif [ $type == systemd ]; then
|
||||
name=systemd
|
||||
else
|
||||
ynh_die --message="The type $type is not recognized"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Resetting the specific configuration of $name for the app $app..." --weight=3
|
||||
|
||||
if [ $type == nginx ]
|
||||
then
|
||||
(cd scripts; ynh_add_nginx_config)
|
||||
|
||||
elif [ $type == systemd ]
|
||||
then
|
||||
ynh_systemd_action --action=stop
|
||||
(cd scripts; ynh_add_systemd_config)
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="300"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
Loading…
Add table
Reference in a new issue