Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created June 29, 2019 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Psycojoker/c9ea335e596c4684b042812b7b0804c3 to your computer and use it in GitHub Desktop.
Save Psycojoker/c9ea335e596c4684b042812b7b0804c3 to your computer and use it in GitHub Desktop.
variables="\
YNH_CONFIG_FIRST_TAB_SECOND_SECTION_FIRST_OPTION
YNH_CONFIG_SECOND_TAB_POUET_FIRST_OPTION
YNH_CONFIG_SECOND_TAB_PASSWOWORD_FIRST_OPTION
YNH_CONFIG_SECOND_TAB_POUET_SECOND_OPTION
YNH_CONFIG_FIRST_TAB_FIRST_SECTION_FIRST_OPTION
YNH_CONFIG_FIRST_TAB_FIRST_SECTION_SECOND_OPTION\
"
config_path=/etc/yunohost/apps/${YNH_APP_ID}/stupid_config/
mkdir -p "$config_path"
show_config(){
for i in $variables
do
if [ -e "$config_path"/"$i" ]
then
echo "$i=$(cat "$config_path"/"$i")"
fi
done
}
apply_config() {
for i in $variables
do
echo "${!i}" > "$config_path"/"$i"
done
}
case $1 in
show) show_config;;
apply) apply_config;;
esac
version = "0.1"
name = "Example config panel"
[first_tab]
name = "First tab configuration"
[first_tab.first_section]
name = "First section of first tab with only booleans"
[first_tab.first_section.first_option]
ask = "This is the first option, a boolean one"
type = "boolean"
default = true
help="some help"
[first_tab.first_section.second_option]
ask = "This is the second option, a boolean one"
type = "boolean"
default = false
[first_tab.second_section]
name = "Second section of first tab, with choices"
[first_tab.second_section.first_option]
ask = "This is the first option, a choice one"
default = "pouet"
choices = ["pouet", "plip", "plop"]
[second_tab]
name = "Second tab configuration"
[second_tab.pouet]
name = "First section of second tab, with text fields"
[second_tab.pouet.first_option]
ask = "This is the first option, a text one"
default = "some default"
[second_tab.pouet.second_option]
ask = "This is the second option, a text one"
optional = true
[second_tab.passwoword]
name = "Second tab with password"
[second_tab.passwoword.first_option]
ask = "This is the first option, a password"
type = "password"
[second_tab.passwoword.second_option]
ask = "This is the first option, a password"
type = "domain"
[second_tab.passwoword.user]
ask = "This is a user choice"
type = "user"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment