1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00

Fix regression about lock issues by removing the need to call yunohost commands from inside the service script

This commit is contained in:
Alexandre Aubin 2020-07-07 17:06:58 +02:00
parent d5cfd9c107
commit 79f1e5a2a1
4 changed files with 21 additions and 7 deletions

View file

@ -256,11 +256,25 @@ ynh_setting_get() {
} }
ynh_setting_set() { ynh_setting_set() {
app=${1}
setting=${2}
value=${3}
yunohost app setting "${app}" "${setting}" -v "${value}" # This is a partial copypasta of the official ynh_app_setting internal helper
# In particular, we do this instead of relying on 'yunohost app setting' for
# performance reasons (it takes a few second to run every yunohost commands)
# and to remove the need for the infamous '--need-lock' option/issue.
app="$1" key="$2" value="${3:-}" python2.7 - <<EOF
import os, yaml, sys
app = os.environ['app']
key, value = os.environ['key'], os.environ.get('value', None)
setting_file = "/etc/yunohost/apps/%s/settings.yml" % app
assert os.path.exists(setting_file), "Setting file %s does not exists ?" % setting_file
with open(setting_file) as f:
settings = yaml.load(f)
settings[key] = value
with open(setting_file, "w") as f:
yaml.safe_dump(settings, f, default_flow_style=False)
EOF
} }
devfromid() { devfromid() {

View file

@ -309,7 +309,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $service_name --description "Creates a Wi-Fi access point" --need_lock yunohost service add $service_name --description "Creates a Wi-Fi access point"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -136,7 +136,7 @@ systemctl enable $service_name.service
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $service_name --description "Creates a Wi-Fi access point" --need_lock yunohost service add $service_name --description "Creates a Wi-Fi access point"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -199,7 +199,7 @@ find ${final_path}/ -type d -exec chmod +x {} \;
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $service_name --description "Creates a Wi-Fi access point" --need_lock yunohost service add $service_name --description "Creates a Wi-Fi access point"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE