#!/bin/bash set -e force=$1 function safe_copy () { if [ $force ]; then sudo yunohost service safecopy \ -s nginx \ $1 $2 \ --force else sudo yunohost service safecopy \ -s nginx \ $1 $2 fi } cd /usr/share/yunohost/templates/nginx # Copy plain single configuration files files="ssowat.conf yunohost_admin.conf yunohost_admin.conf.inc yunohost_api.conf.inc yunohost_panel.conf.inc" 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=$(cat /etc/yunohost/current_host) safe_copy yunohost_local.conf \ /etc/nginx/conf.d/$main_domain.d/yunohost_local.conf need_restart=1 # Copy a configuration file for each YunoHost domain for domain in $(sudo yunohost domain list --raw); do 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) == "True" ]]; then need_restart=0 fi done # Restart if need be if [ $need_restart ]; then sudo service nginx restart else sudo service nginx reload fi