mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Make Nginx configuration generation to work
This commit is contained in:
parent
b6c77c9e43
commit
cfc661e612
5 changed files with 29 additions and 19 deletions
|
@ -882,6 +882,8 @@ service:
|
||||||
with the existing configuration file.
|
with the existing configuration file.
|
||||||
Prints the differences between files if any.
|
Prints the differences between files if any.
|
||||||
api: PUT /services/regenconf
|
api: PUT /services/regenconf
|
||||||
|
configuration:
|
||||||
|
lock: false
|
||||||
arguments:
|
arguments:
|
||||||
-s:
|
-s:
|
||||||
full: --service
|
full: --service
|
||||||
|
@ -898,12 +900,15 @@ service:
|
||||||
Stores the file hash in the services.yml file
|
Stores the file hash in the services.yml file
|
||||||
api: PUT /services/safecopy
|
api: PUT /services/safecopy
|
||||||
arguments:
|
arguments:
|
||||||
service:
|
|
||||||
help: Service name attached to the conf file
|
|
||||||
new_conf_file:
|
new_conf_file:
|
||||||
help: Path to the desired conf file
|
help: Path to the desired conf file
|
||||||
conf_file:
|
conf_file:
|
||||||
help: Path to the targeted conf file
|
help: Path to the targeted conf file
|
||||||
|
-s:
|
||||||
|
full: --service
|
||||||
|
help: Service name attached to the conf file
|
||||||
|
extra:
|
||||||
|
required: True
|
||||||
-f:
|
-f:
|
||||||
full: --force
|
full: --force
|
||||||
help: Override the current configuration with the newly generated one, even if it has been modified
|
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
|
Backup the file in /home/yunohost.backup
|
||||||
api: PUT /services/safecopy
|
api: PUT /services/safecopy
|
||||||
arguments:
|
arguments:
|
||||||
service:
|
|
||||||
help: Service name attached to the conf file
|
|
||||||
conf_file:
|
conf_file:
|
||||||
help: Path to the targeted conf file
|
help: Path to the targeted conf file
|
||||||
|
-s:
|
||||||
|
full: --service
|
||||||
|
help: Service name attached to the conf file
|
||||||
|
extra:
|
||||||
|
required: True
|
||||||
-f:
|
-f:
|
||||||
full: --force
|
full: --force
|
||||||
help: Force file deletion
|
help: Force file deletion
|
||||||
|
|
BIN
data/hooks/conf_regen/.15-nginx.swn
Normal file
BIN
data/hooks/conf_regen/.15-nginx.swn
Normal file
Binary file not shown.
|
@ -4,11 +4,11 @@ set -e
|
||||||
force=$1
|
force=$1
|
||||||
|
|
||||||
function safe_copy () {
|
function safe_copy () {
|
||||||
if $force; then
|
if [ $force ]; then
|
||||||
sudo yunohost service safecopy \
|
sudo yunohost service safecopy \
|
||||||
-s nginx \
|
-s nginx \
|
||||||
--force \
|
$1 $2 \
|
||||||
$1 $2
|
--force
|
||||||
else
|
else
|
||||||
sudo yunohost service safecopy \
|
sudo yunohost service safecopy \
|
||||||
-s nginx \
|
-s nginx \
|
||||||
|
@ -19,39 +19,39 @@ function safe_copy () {
|
||||||
cd /usr/share/yunohost/templates/nginx
|
cd /usr/share/yunohost/templates/nginx
|
||||||
|
|
||||||
# Copy plain single configuration files
|
# Copy plain single configuration files
|
||||||
$files="ssowat.conf
|
files="ssowat.conf
|
||||||
yunohost_admin.conf
|
yunohost_admin.conf
|
||||||
yunohost_admin.conf.inc
|
yunohost_admin.conf.inc
|
||||||
yunohost_api.conf.inc
|
yunohost_api.conf.inc
|
||||||
yunohost_panel.conf.inc"
|
yunohost_panel.conf.inc"
|
||||||
|
|
||||||
for file in files; do
|
for file in $files; do
|
||||||
safe_copy $file /etc/nginx/conf.d/$file
|
safe_copy $file /etc/nginx/conf.d/$file
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Copy 'yunohost.local' to the main domain conf directory
|
# 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 \
|
safe_copy yunohost_local.conf \
|
||||||
/etc/nginx/conf.d/$main_domain.d/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
|
# Copy a configuration file for each YunoHost domain
|
||||||
for domain in $(sudo yunohost domain list --raw); do
|
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 \
|
cat server.conf.sed \
|
||||||
| sed "s/{{ domain }}/$domain/g" \
|
| sed "s/{{ domain }}/$domain/g" \
|
||||||
| sudo tee $domain.conf
|
| sudo tee $domain.conf
|
||||||
if $(safe_copy $domain.conf /etc/nginx/conf.d/$domain.conf); then
|
if [[ $(safe_copy $domain.conf /etc/nginx/conf.d/$domain.conf) == "True" ]]; then
|
||||||
need_restart=1
|
need_restart=0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restart if need be
|
# Restart if need be
|
||||||
if $need_restart; then
|
if [ $need_restart ]; then
|
||||||
service nginx restart
|
sudo service nginx restart
|
||||||
else
|
else
|
||||||
service nginx reload
|
sudo service nginx reload
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -281,10 +281,12 @@ def service_regenconf(service=None, force=False):
|
||||||
one, even if it has been modified
|
one, even if it has been modified
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from yunohost.hook import hook_callback
|
||||||
|
|
||||||
if force:
|
if force:
|
||||||
arg_force = 1
|
|
||||||
else:
|
|
||||||
arg_force = 0
|
arg_force = 0
|
||||||
|
else:
|
||||||
|
arg_force = 1
|
||||||
|
|
||||||
if service is None:
|
if service is None:
|
||||||
# Regen ALL THE CONFIGURATIONS
|
# Regen ALL THE CONFIGURATIONS
|
||||||
|
|
Loading…
Add table
Reference in a new issue