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

67 lines
1.9 KiB
Bash

#!/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() {
echo ""
}
get__enable_proposed_api() {
echo "$(awk '/enable-proposed-api:/ {print $2}' $final_path/config.yaml)"
}
# TODO: Write some getters and setters for __EXTENSIONS_GALLERY__ to go back to json directly
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__password() {
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
}
set__enable_proposed_api() {
sed -i "/enable-proposed-api:.*/d" "$final_path/config.yaml"
echo "enable-proposed-api: $enable_proposed_api" >> "$final_path/config.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml"
ynh_app_setting_set $app enable_proposed_api "$enable_proposed_api"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1