From cfc661e61258dfd68b78c9d0ea38f096fa06fb18 Mon Sep 17 00:00:00 2001 From: kload Date: Mon, 28 Sep 2015 16:31:19 -0400 Subject: [PATCH] [fix] Make Nginx configuration generation to work --- data/actionsmap/yunohost.yml | 16 ++++++++--- data/hooks/conf_regen/.15-nginx.swn | Bin 0 -> 12288 bytes data/hooks/conf_regen/15-nginx | 26 +++++++++--------- .../nginx/{server.conf.j2 => server.conf.sed} | 0 lib/yunohost/service.py | 6 ++-- 5 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 data/hooks/conf_regen/.15-nginx.swn rename data/templates/nginx/{server.conf.j2 => server.conf.sed} (100%) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index a037b7899..371ecf265 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -882,6 +882,8 @@ service: with the existing configuration file. Prints the differences between files if any. api: PUT /services/regenconf + configuration: + lock: false arguments: -s: full: --service @@ -898,12 +900,15 @@ service: Stores the file hash in the services.yml file api: PUT /services/safecopy arguments: - service: - help: Service name attached to the conf file new_conf_file: help: Path to the desired conf file conf_file: help: Path to the targeted conf file + -s: + full: --service + help: Service name attached to the conf file + extra: + required: True -f: full: --force help: Override the current configuration with the newly generated one, even if it has been modified @@ -916,10 +921,13 @@ service: Backup the file in /home/yunohost.backup api: PUT /services/safecopy arguments: - service: - help: Service name attached to the conf file conf_file: help: Path to the targeted conf file + -s: + full: --service + help: Service name attached to the conf file + extra: + required: True -f: full: --force help: Force file deletion diff --git a/data/hooks/conf_regen/.15-nginx.swn b/data/hooks/conf_regen/.15-nginx.swn new file mode 100644 index 0000000000000000000000000000000000000000..72192c866529e1ce91ae554265e8b90c14a73f9c GIT binary patch literal 12288 zcmeI2-)me&6vt1+2eplgKcEzZ)6HrV0B0l&(h~nQM2nwwa7De#EN53=o-ejYx3%)65;KNO3=AN1P%$X%iW_#oM z)mQlW-m`@AFwu86@4vpYaxdM!LR2{yV)e2Tj1RecZ*N(@4`M(yb@NGSO$a92n_D+_ zKBz(mt;Wvnc$GUl98_jxtlE4ov!l|!yDYA>ivcmP#K1fZvr8-V%*D-(*mJdWo*#YW zjU_KhvltKqVn7Ut0Wly3#DEwO1OF!jVRni>#DeZ=7WG2&JoT4n^Q%0>fEW-1Vn7Ut z0Wly3#DEwO17bi7h=Kp00bLM1{Qx+P$>ab3?f3uRA0oN~eg;2+AHcWZOYjl!K!aDo zOW+A`ANb=zqTj%;;1}=>_!@i+Zh&1d09U~VP~a@MvqJO}xD9TB&%puM0#AV_K^Hs@ z9s}Q>A^HsL0}U>LbKoni;|uU9xCuT1H^23E5CdZ1 zE(V4rF^ZoTj=ibgDRaZ=ekxaH;_!#GnRs*eE!BIsZnnqW!cBE)d+|aoD-&{+CYvtU z_6oJwyw3eTcdk`))8ValI&mQ8_v`frV~z!+)EHYa&5l?5`&qyJ4IP>Hv5NJ7BqBKJ49*YLgO~H7l_-IN$CS;S*3T^FQX1hUyLd= zM+xOBfZ`(=0e-tOCw$2;9~x84Aw3o?Kz~HJh&>} z%RbDaqbYThg%c7Z)+gPmLzEqV@JT4OgAZofntGYN(&n9`20bh5T}JgnZ82?fF?K(x zp3*4&j`wa?hgx8>f3rzkn=kDM`}X&(^h9~VYVIrL$GS3yd!d4v;$7TNuX7(?DN{Z! z93|%NCU-BUYEC8d&8e<4G}ax@wf5{smFc9_9S=``6DC7~<@M36YtleX-Zy>z=`oz!JSF$h4zI2AKE<8PO}~pY_6CQ;Fs+_f+oe_8+K=f^uGH2& literal 0 HcmV?d00001 diff --git a/data/hooks/conf_regen/15-nginx b/data/hooks/conf_regen/15-nginx index 2cc5eae36..0eaa4ea19 100644 --- a/data/hooks/conf_regen/15-nginx +++ b/data/hooks/conf_regen/15-nginx @@ -4,11 +4,11 @@ set -e force=$1 function safe_copy () { - if $force; then + if [ $force ]; then sudo yunohost service safecopy \ -s nginx \ - --force \ - $1 $2 + $1 $2 \ + --force else sudo yunohost service safecopy \ -s nginx \ @@ -19,39 +19,39 @@ function safe_copy () { cd /usr/share/yunohost/templates/nginx # Copy plain single configuration files -$files="ssowat.conf +files="ssowat.conf yunohost_admin.conf yunohost_admin.conf.inc yunohost_api.conf.inc yunohost_panel.conf.inc" -for file in files; do +for file in $files; do safe_copy $file /etc/nginx/conf.d/$file done # Copy 'yunohost.local' to the main domain conf directory -main_domain=$(sudo yunohost tools maindomain) +main_domain=$(cat /etc/yunohost/current_host) safe_copy yunohost_local.conf \ /etc/nginx/conf.d/$main_domain.d/yunohost_local.conf -need_restart=0 +need_restart=1 # Copy a configuration file for each YunoHost domain for domain in $(sudo yunohost domain list --raw); do - sudo mkdir /etc/nginx/conf.d/$domain.d + sudo mkdir -p /etc/nginx/conf.d/$domain.d cat server.conf.sed \ | sed "s/{{ domain }}/$domain/g" \ | sudo tee $domain.conf - if $(safe_copy $domain.conf /etc/nginx/conf.d/$domain.conf); then - need_restart=1 + if [[ $(safe_copy $domain.conf /etc/nginx/conf.d/$domain.conf) == "True" ]]; then + need_restart=0 fi done # Restart if need be -if $need_restart; then - service nginx restart +if [ $need_restart ]; then + sudo service nginx restart else - service nginx reload + sudo service nginx reload fi diff --git a/data/templates/nginx/server.conf.j2 b/data/templates/nginx/server.conf.sed similarity index 100% rename from data/templates/nginx/server.conf.j2 rename to data/templates/nginx/server.conf.sed diff --git a/lib/yunohost/service.py b/lib/yunohost/service.py index 26ac27d68..5bed72e95 100644 --- a/lib/yunohost/service.py +++ b/lib/yunohost/service.py @@ -281,10 +281,12 @@ def service_regenconf(service=None, force=False): one, even if it has been modified """ + from yunohost.hook import hook_callback + if force: - arg_force = 1 - else: arg_force = 0 + else: + arg_force = 1 if service is None: # Regen ALL THE CONFIGURATIONS