test_apps/config_app_ynh/scripts/config
Alexandre Aubin d383dcebfb tableflip
2024-07-04 00:26:37 +02:00

69 lines
1.6 KiB
Bash

#!/bin/bash
source /usr/share/yunohost/helpers
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__arg9() {
cat << EOF
ask:
en: |
### Files in $install_dir
| Name | weight |
| ---- | ------ |
EOF
for file in $install_dir/* ; do
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
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
validate__arg8() {
if [[ "${#arg8}" -lt 12 ]]; then echo 'Too short password'; fi
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__arg8() {
if [ -n "${arg8}" ]
then
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"
fi
}
#=================================================
# OVERWRITING APPLY STEP
#=================================================
ynh_app_config_apply() {
_ynh_app_config_apply
systemctl reload nginx
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1