1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/code-server_ynh.git synced 2024-09-03 18:16:28 +02:00
code-server_ynh/scripts/config

68 lines
1.9 KiB
Text
Raw Normal View History

2022-01-16 14:01:08 +01:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__password() {
2022-01-16 20:45:31 +01:00
echo ""
}
get__enable_proposed_api() {
echo "$(awk '/enable-proposed-api:/ {print $2}' $final_path/config.yaml)"
2022-01-16 14:01:08 +01:00
}
# TODO: Write some getters and setters for __EXTENSIONS_GALLERY__ to go back to json directly
2022-01-16 14:01:08 +01:00
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__password() {
2022-01-16 20:45:31 +01:00
if [ $password ]
then
hashed_password="$(printf "$password" | sha256sum | cut -d' ' -f1)"
sed -i "/hashed-password:.*/d" "$final_path/config.yaml"
echo "hashed-password: $hashed_password" >> "$final_path/config.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml"
ynh_app_setting_set $app hashed_password "$hashed_password"
fi
}
2022-01-16 14:01:08 +01:00
2022-01-16 20:45:31 +01:00
set__enable_proposed_api() {
sed -i "/enable-proposed-api:.*/d" "$final_path/config.yaml"
2022-01-16 14:01:08 +01:00
2022-01-16 20:45:31 +01:00
echo "enable-proposed-api: $enable_proposed_api" >> "$final_path/config.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml"
2022-01-16 14:01:08 +01:00
2022-01-16 20:45:31 +01:00
ynh_app_setting_set $app enable_proposed_api "$enable_proposed_api"
2022-01-16 14:01:08 +01:00
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1