test_apps/config_app_ynh/scripts/config

70 lines
1.6 KiB
Text
Raw Normal View History

2021-08-14 12:26:20 +02:00
#!/bin/bash
source /usr/share/yunohost/helpers
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
2021-09-02 02:31:39 +02:00
get__arg9() {
cat << EOF
ask:
en: |
2024-07-04 00:26:37 +02:00
### Files in $install_dir
2021-09-02 02:31:39 +02:00
| Name | weight |
| ---- | ------ |
EOF
2024-07-04 00:26:37 +02:00
for file in $install_dir/* ; do
2021-09-02 02:31:39 +02:00
echo " | $file | $(du -sh $file | cut -f1) |"
done
}
get__alert() {
if [ -f "/sys/class/net/tun0/operstate" ] && [ "$(cat /sys/class/net/tun0/operstate)" == "up" ]
then
cat << EOF
style: success
ask:
en: Your VPN is running :)
EOF
else
cat << EOF
style: danger
ask:
en: Your VPN is down
EOF
fi
2021-08-14 12:26:20 +02:00
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
validate__arg8() {
if [[ "${#arg8}" -lt 12 ]]; then echo 'Too short password'; fi
2021-08-14 12:26:20 +02:00
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__arg8() {
if [ -n "${arg8}" ]
2021-08-14 12:26:20 +02:00
then
2024-07-04 00:26:37 +02:00
python -c "import crypt; print(crypt.crypt(\"${arg8}\", \"\$6\$saltsalt\$\"))" > $install_dir/password
ynh_print_info "The hash of your password has been registered in $install_dir/password"
2021-08-14 12:26:20 +02:00
fi
}
#=================================================
# OVERWRITING APPLY STEP
#=================================================
2021-09-02 17:16:49 +02:00
ynh_app_config_apply() {
_ynh_app_config_apply
2021-09-02 02:31:39 +02:00
systemctl reload nginx
2021-08-14 12:26:20 +02:00
}
#=================================================
# GENERIC FINALIZATION
#=================================================
2021-09-02 17:16:49 +02:00
ynh_app_config_run $1