Browse Source

Merge pull request #66 from labriqueinternet/cleanup

Cleanup
Alexandre Aubin 4 years ago
parent
commit
73476e02fa
5 changed files with 22 additions and 22 deletions
  1. 18 10
      conf/ynh-hotspot
  2. 1 1
      manifest.json
  3. 1 9
      scripts/install
  4. 1 1
      scripts/restore
  5. 1 1
      scripts/upgrade

+ 18 - 10
conf/ynh-hotspot

@@ -256,11 +256,25 @@ ynh_setting_get() {
 }
 
 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() {
@@ -275,12 +289,6 @@ devfromid() {
 
 if [ "$1" != restart ]; then
 
-  # Restart php7.0-fpm at the first start (it needs to be restarted after the slapd start)
-  if [ ! -e /tmp/.ynh-hotspot-boot ]; then
-    touch /tmp/.ynh-hotspot-boot
-    systemctl restart php__PHPVERSION__-fpm
-  fi
-
   # Variables
 
   echo -n "Retrieving Yunohost settings... "

+ 1 - 1
manifest.json

@@ -7,7 +7,7 @@
     "fr": "Hotspot Wifi"
   },
   "url": "https://github.com/labriqueinternet/hotspot_ynh",
-  "version": "1.2.0~ynh2",
+  "version": "1.2.0~ynh3",
   "license": "AGPL-3.0",
   "maintainer": {
     "name": "Julien Vaubourg",

+ 1 - 9
scripts/install

@@ -309,7 +309,7 @@ fi
 #=================================================
 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
@@ -324,14 +324,6 @@ else
 fi
 
 #=================================================
-# RELOAD NGINX AND PHP-FPM
-#=================================================
-ynh_script_progression --message="Reloading nginx web server..."
-
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
 # END OF SCRIPT
 #=================================================
 

+ 1 - 1
scripts/restore

@@ -136,7 +136,7 @@ systemctl enable $service_name.service
 #=================================================
 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

+ 1 - 1
scripts/upgrade

@@ -199,7 +199,7 @@ find ${final_path}/ -type d -exec chmod +x {} \;
 #=================================================
 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