2022-08-09 09:59:02 +02:00
|
|
|
#!/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"
|
2022-08-09 09:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2022-08-09 09:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2022-08-09 09:59:02 +02:00
|
|
|
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"
|
2022-08-09 09:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2022-08-09 09:59:02 +02:00
|
|
|
|
2024-01-15 22:37:42 +01:00
|
|
|
ynh_write_var_in_file --file="$config_cron" --key="FILES_SIZE" --value="$files_limit"
|
2022-08-09 09:59:02 +02:00
|
|
|
|
2024-01-15 22:37:42 +01:00
|
|
|
ynh_store_file_checksum --file="$config_cron"
|
2022-08-09 09:59:02 +02:00
|
|
|
|
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"
|
2022-08-09 09:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
ynh_app_config_run $1
|