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 000000000..72192c866 Binary files /dev/null and b/data/hooks/conf_regen/.15-nginx.swn differ 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