mirror of
https://github.com/YunoHost/test_apps.git
synced 2024-09-03 20:06:29 +02:00
[enh] New config panel test
This commit is contained in:
parent
2403d99912
commit
9e5167bf05
3 changed files with 124 additions and 65 deletions
|
@ -1,11 +1,10 @@
|
||||||
version = "0.1"
|
version = "1.0"
|
||||||
name = "Configuration panel"
|
|
||||||
|
|
||||||
[main]
|
[main]
|
||||||
name = "Main panel"
|
name = "Main panel"
|
||||||
|
services = ["nginx"]
|
||||||
[main.components]
|
[main.components]
|
||||||
name = "Components"
|
name = ""
|
||||||
|
|
||||||
[main.components.boolean]
|
[main.components.boolean]
|
||||||
ask = "Put a boolean"
|
ask = "Put a boolean"
|
||||||
|
@ -20,13 +19,13 @@ name = "Main panel"
|
||||||
[main.components.range]
|
[main.components.range]
|
||||||
ask = "Put a range"
|
ask = "Put a range"
|
||||||
type = "range"
|
type = "range"
|
||||||
min = 1
|
min = 0
|
||||||
max = 100
|
max = 100
|
||||||
|
step = 10
|
||||||
|
|
||||||
[main.components.str]
|
[main.components.str]
|
||||||
ask = "Put a string with yunohost word"
|
ask = "Put a string"
|
||||||
type = "string"
|
type = "string"
|
||||||
pattern = "yunohost"
|
|
||||||
|
|
||||||
[main.components.text]
|
[main.components.text]
|
||||||
ask = "Put a text"
|
ask = "Put a text"
|
||||||
|
@ -63,8 +62,9 @@ name = "Main panel"
|
||||||
[main.components.select]
|
[main.components.select]
|
||||||
ask = "Choose an option"
|
ask = "Choose an option"
|
||||||
type = "select"
|
type = "select"
|
||||||
choices = ["option1", "option2", "option3"]
|
choices.option1 = "Plop1"
|
||||||
default = "option1"
|
choices.option2 = "Plop2"
|
||||||
|
choices.option3 = "Plop3"
|
||||||
|
|
||||||
[main.components.domain]
|
[main.components.domain]
|
||||||
ask = "Put a domain"
|
ask = "Put a domain"
|
||||||
|
@ -75,32 +75,47 @@ name = "Main panel"
|
||||||
type = "user"
|
type = "user"
|
||||||
|
|
||||||
[main.components.tags]
|
[main.components.tags]
|
||||||
ask = "Put some tags"
|
ask = "Put some emails"
|
||||||
type = "tags"
|
type = "tags"
|
||||||
|
placeholder = "Enter some emails separated by commas"
|
||||||
|
limit = 3
|
||||||
|
pattern.regexp = '^.+@.+$'
|
||||||
|
pattern.error = 'An email is required for this field'
|
||||||
|
|
||||||
# [main.components.file]
|
[main.components.tags2]
|
||||||
# ask = "Put a file"
|
ask = "Put some tags from a list"
|
||||||
# type = "file"
|
type = "tags"
|
||||||
# accept = ".cube"
|
choices = ['table', 'chair', 'bed', 'desk']
|
||||||
|
placeholder = "Add some tags"
|
||||||
|
icon = "bed"
|
||||||
|
|
||||||
|
[main.components.file]
|
||||||
|
ask = "Put a file"
|
||||||
|
type = "file"
|
||||||
|
|
||||||
[main.messages]
|
[main.messages]
|
||||||
name = "Read only components"
|
name = "Read only components"
|
||||||
|
|
||||||
[main.messages.success]
|
[main.messages.success]
|
||||||
ask = "This is a success message"
|
ask = "This is a success message"
|
||||||
type = "success"
|
type = "alert"
|
||||||
|
style = "success"
|
||||||
|
icon = "beer"
|
||||||
|
|
||||||
[main.messages.info]
|
[main.messages.info]
|
||||||
ask = "This is an info message"
|
ask = "This is an info message"
|
||||||
type = "info"
|
type = "alert"
|
||||||
|
style = "info"
|
||||||
|
|
||||||
[main.messages.warning]
|
[main.messages.warning]
|
||||||
ask = "This is an warning message"
|
ask = "This is an warning message"
|
||||||
type = "warning"
|
type = "alert"
|
||||||
|
style = "warning"
|
||||||
|
|
||||||
[main.messages.danger]
|
[main.messages.danger]
|
||||||
ask = "This is a danger message"
|
ask = "This is a danger message"
|
||||||
type = "danger"
|
type = "alert"
|
||||||
|
style = "danger"
|
||||||
|
|
||||||
[main.messages.display_text]
|
[main.messages.display_text]
|
||||||
ask = "This is a simple text"
|
ask = "This is a simple text"
|
||||||
|
@ -113,10 +128,11 @@ name = "Main panel"
|
||||||
[main.generic]
|
[main.generic]
|
||||||
name = "Generic options"
|
name = "Generic options"
|
||||||
|
|
||||||
[main.generic.default]
|
[main.generic.pattern]
|
||||||
ask = "This is a question with a default value"
|
ask = "This is a question with a pattern validation"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "Camille"
|
pattern.regexp = '^[A-F]\d\d$'
|
||||||
|
pattern.error = "Provide a room like F12 : one uppercase and 2 numbers"
|
||||||
|
|
||||||
[main.generic.example]
|
[main.generic.example]
|
||||||
ask = "This is a question with an example value"
|
ask = "This is a question with an example value"
|
||||||
|
@ -133,16 +149,26 @@ name = "Main panel"
|
||||||
type = "string"
|
type = "string"
|
||||||
help = "You can feel this question with your keyboard (yes i know it's very useful)"
|
help = "You can feel this question with your keyboard (yes i know it's very useful)"
|
||||||
|
|
||||||
[main.generic.helpLink]
|
[main.generic.helplink]
|
||||||
ask = "Here we add an help link"
|
ask = "Here we add an help link"
|
||||||
type = "string"
|
type = "select"
|
||||||
|
choices.question = "Display next question"
|
||||||
|
choices.section = "Display next section"
|
||||||
helpLink.href = "https://yunohost.org/doc"
|
helpLink.href = "https://yunohost.org/doc"
|
||||||
helpLink.text = "Yunohost Doc"
|
helpLink.text = "Yunohost Doc"
|
||||||
|
|
||||||
[main.generic.visibleIf]
|
[main.generic.visibleif]
|
||||||
|
ask = "Display if helpLink question is filled"
|
||||||
|
type = "string"
|
||||||
|
visibleIf = "helplink == 'question'"
|
||||||
|
|
||||||
|
[main.ifsection]
|
||||||
|
name = "Section displayed only if helplink is filled"
|
||||||
|
visibleIf = "helplink == 'section'"
|
||||||
|
|
||||||
|
[main.ifsection.sub]
|
||||||
ask = "Display if helpLink question is filled"
|
ask = "Display if helpLink question is filled"
|
||||||
type = "string"
|
type = "string"
|
||||||
visibleIf = "helpLink == 'plop'"
|
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
name = "Source section"
|
name = "Source section"
|
||||||
|
@ -154,58 +180,63 @@ name = "Source section"
|
||||||
ask = "Save app settings arg1"
|
ask = "Save app settings arg1"
|
||||||
type = "string"
|
type = "string"
|
||||||
|
|
||||||
[source.yml]
|
[source.variable]
|
||||||
name = "YAML"
|
name = "YAML"
|
||||||
|
|
||||||
[source.yml.arg2]
|
[source.variable.arg2]
|
||||||
ask = "Save arg2 in YAML"
|
ask = "Save arg2 in YAML"
|
||||||
type = "string"
|
type = "string"
|
||||||
source = "__FINALPATH__/test.yml"
|
source = ":__FINALPATH__/test.yml"
|
||||||
|
|
||||||
[source.json]
|
[source.variable.arg3]
|
||||||
name = "JSON"
|
|
||||||
|
|
||||||
[source.json.arg3]
|
|
||||||
ask = "Save arg3 in JSON"
|
ask = "Save arg3 in JSON"
|
||||||
type = "string"
|
type = "string"
|
||||||
source = "__FINALPATH__/test.json"
|
source = ":__FINALPATH__/test.json"
|
||||||
|
|
||||||
[source.ini]
|
[source.variable.arg4]
|
||||||
name = "INI"
|
|
||||||
|
|
||||||
[source.ini.arg4]
|
|
||||||
ask = "Save arg4 in INI"
|
ask = "Save arg4 in INI"
|
||||||
type = "string"
|
type = "string"
|
||||||
source = "__FINALPATH__/test.ini"
|
source = ":__FINALPATH__/test.ini"
|
||||||
|
|
||||||
[source.php]
|
[source.variable.arg5]
|
||||||
name = "PHP"
|
|
||||||
|
|
||||||
[source.php.arg5]
|
|
||||||
ask = "Save arg5 in PHP file"
|
ask = "Save arg5 in PHP file"
|
||||||
type = "string"
|
type = "string"
|
||||||
source = "__FINALPATH__/test.php"
|
source = ":__FINALPATH__/test.php"
|
||||||
|
|
||||||
[source.python]
|
[source.variable.arg6]
|
||||||
name = "Python"
|
|
||||||
|
|
||||||
[source.python.arg6]
|
|
||||||
ask = "Save arg6 in python file"
|
ask = "Save arg6 in python file"
|
||||||
type = "string"
|
type = "string"
|
||||||
source = "__FINALPATH__/test.py"
|
source = ":__FINALPATH__/test.py"
|
||||||
|
|
||||||
# [source.file]
|
[source.file]
|
||||||
# name = "File"
|
name = "File"
|
||||||
#
|
|
||||||
# [source.file.arg7]
|
[source.file.arg7]
|
||||||
# ask = "Save a cube file"
|
ask = "Save a cube file"
|
||||||
# type = "file"
|
type = "file"
|
||||||
# accept = ".cube"
|
accept = ".cube"
|
||||||
# source = "__FINALPATH__/test.cube"
|
source = "__FINALPATH__/test.cube"
|
||||||
|
|
||||||
|
[source.file.arg7b]
|
||||||
|
ask = "Nginx file"
|
||||||
|
type = "text"
|
||||||
|
source = "__FINALPATH__/nginx.conf"
|
||||||
|
|
||||||
[source.function]
|
[source.function]
|
||||||
name = "Save with a bash function"
|
name = "Bash function"
|
||||||
|
|
||||||
[source.function.arg8]
|
[source.function.arg8]
|
||||||
ask = "Custom validate and save arg8 password"
|
ask = "Custom validator and setter for arg8 password"
|
||||||
type = "password"
|
type = "password"
|
||||||
|
source = ""
|
||||||
|
|
||||||
|
[source.function.arg9]
|
||||||
|
ask = "Custom getter arg9"
|
||||||
|
type = "markdown"
|
||||||
|
source = ""
|
||||||
|
|
||||||
|
[source.function.alert]
|
||||||
|
ask = "Custom getter alert"
|
||||||
|
type = "alert"
|
||||||
|
style = "info"
|
||||||
|
source = ""
|
||||||
|
|
|
@ -20,16 +20,42 @@ final_path=$(ynh_app_setting_get $app final_path)
|
||||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
get__arg8() {
|
get__arg9() {
|
||||||
echo ""
|
cat << EOF
|
||||||
|
ask:
|
||||||
|
en: |
|
||||||
|
### Files in $final_path
|
||||||
|
|
||||||
|
| Name | weight |
|
||||||
|
| ---- | ------ |
|
||||||
|
EOF
|
||||||
|
for file in $final_path/* ; 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
|
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||||
#=================================================
|
#=================================================
|
||||||
validate__arg8() {
|
validate__arg8() {
|
||||||
[[ "${#arg8}" -lt 8 ]] &&
|
if [[ "${#arg8}" -lt 8 ]]; then echo 'Too short password'; fi
|
||||||
echo 'Too short password'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -39,6 +65,7 @@ set__arg8() {
|
||||||
if [ -z "${arg8}" ]
|
if [ -z "${arg8}" ]
|
||||||
then
|
then
|
||||||
python -c "import crypt; print(crypt.crypt(\"${arg8}\", \"\$6\$saltsalt\$\"))" > $final_path/password
|
python -c "import crypt; print(crypt.crypt(\"${arg8}\", \"\$6\$saltsalt\$\"))" > $final_path/password
|
||||||
|
ynh_print_info "The hash of your password has been registered in $final_path/password"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +74,7 @@ set__arg8() {
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_panel_apply() {
|
ynh_panel_apply() {
|
||||||
_ynh_panel_apply
|
_ynh_panel_apply
|
||||||
systemctl restart nginx
|
systemctl reload nginx
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -4,7 +4,8 @@ set -eux
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
final_path=/var/www/$app
|
||||||
mkdir -p /var/www/$app
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
|
mkdir -p $final_path
|
||||||
|
|
||||||
cp ../conf/* /var/www/$app/
|
cp ../conf/* /var/www/$app/
|
||||||
|
|
Loading…
Add table
Reference in a new issue