1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snserver_ynh.git synced 2024-09-03 20:26:22 +02:00
snserver_ynh/scripts/config

101 lines
3.6 KiB
Text
Raw Normal View History

#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__disable_user_registration(){
2024-01-15 22:37:42 +01:00
disabled=$(ynh_read_var_in_file --file="$install_dir/live/auth.env" --key="DISABLE_USER_REGISTRATION")
echo "$disabled"
}
get__files_limit(){
2024-01-15 22:37:42 +01:00
limit=$(ynh_read_var_in_file --file="$install_dir/cron.env" --key="FILES_SIZE")
echo "$limit"
}
get__info(){
2024-01-15 22:37:42 +01:00
domain="$(cat /etc/yunohost/current_host)"
limit=$(ynh_read_var_in_file --file="$install_dir/cron.env" --key="FILES_SIZE")
link="https://$domain/yunohost/admin/#/apps/$app/actions"
cat << EOF
ask: "Add subscriptions:\nAdd a subscription and $limit MB of file space to all users without a subscription.\n$link"
EOF
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__disable_user_registration(){
2024-01-15 22:37:42 +01:00
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
if [ "$disable_user_registration" = "1" ]; then
disabled="true"
fi
if [ "$disable_user_registration" = "0" ]; then
disabled="false"
fi
config_auth="$install_dir/live/auth.env"
config_auth_worker="$install_dir/live/auth-worker.env"
ynh_write_var_in_file --file="$config_auth" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
ynh_write_var_in_file --file="$config_auth_worker" --key="DISABLE_USER_REGISTRATION" --value="$disabled"
ynh_store_file_checksum --file="$config_auth"
ynh_store_file_checksum --file="$config_auth_worker"
ynh_systemd_action \
--service_name="$app-auth" \
--action="restart" \
--log_path="/var/log/$app/auth.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
ynh_systemd_action \
--service_name="$app-auth-worker" \
--action="restart" \
--log_path="/var/log/$app/auth-worker.log" \
--line_match='^.*Server started on port.*$|^.*Starting worker.*$'
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set --app="$app" --key="disable_user_registration" --value="$disabled"
}
set__files_limit(){
2024-01-15 22:37:42 +01:00
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
config_cron="$install_dir/cron.env"
2024-01-15 22:37:42 +01:00
ynh_write_var_in_file --file="$config_cron" --key="FILES_SIZE" --value="$files_limit"
2024-01-15 22:37:42 +01:00
ynh_store_file_checksum --file="$config_cron"
2024-01-15 22:37:42 +01:00
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set --app="$app" --key="files_size" --value="$files_limit"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1