[fix] Make Nginx configuration generation to work

This commit is contained in:
kload 2015-09-28 16:31:19 -04:00
parent b6c77c9e43
commit cfc661e612
5 changed files with 29 additions and 19 deletions

View file

@ -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

Binary file not shown.

View file

@ -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

View file

@ -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