Skip to content

Commit

Permalink
Merge pull request #133 from votdev/continue_issue_100
Browse files Browse the repository at this point in the history
Continue to use Salt Stack to manage the configuration files.
  • Loading branch information
votdev committed Jul 13, 2018
2 parents 1017195 + 6e6b67b commit 6966d4c
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 83 deletions.
4 changes: 2 additions & 2 deletions deb/openmediavault/debian/openmediavault.postinst
Expand Up @@ -156,7 +156,7 @@ case "$1" in
omv.stage.prepare >/dev/null

########################################################################
# Set the services when the package is installed the first time.
# Deploy various services when the package is installed the first time.
########################################################################
if [ -z "$2" ]; then
# Disable default nginx site.
Expand All @@ -165,7 +165,7 @@ case "$1" in
# Deploy the configurations for the following services.
echo "Deploying service configurations ..."
omv-salt --quiet deploy run mdadm cpufrequtils cronapt watchdog \
monit rrdcached avahi ssh nginx collectd phpfpm issue sysctl \
monit rrdcached avahi ssh phpfpm nginx collectd issue sysctl \
acpid
fi

Expand Down

This file was deleted.

8 changes: 1 addition & 7 deletions deb/openmediavault/srv/salt/omv/deploy/nginx/default.sls
Expand Up @@ -25,21 +25,15 @@ prereq_nginx_service_monit:
- sls: omv.deploy.monit

include:
{% for file in salt['file.readdir'](dirpath) | sort %}
{% if file | regex_match('^(\d+.+).sls$', ignorecase=True) %}
{% for file in salt['file.find'](dirpath, iname='*.sls', print='name') | difference(['init.sls', 'default.sls']) %}
- .{{ file | replace('.sls', '') }}
{% endif %}
{% endfor %}

test_nginx_service_config:
cmd.run:
- name: "nginx -t"

restart_nginx_service:
# Force service.running to always restart the service.
test.succeed_with_changes:
- watch_in:
- service: restart_nginx_service
service.running:
- name: nginx
- enable: True
Expand Down
75 changes: 75 additions & 0 deletions deb/openmediavault/srv/salt/omv/deploy/phpfpm/10webgui.sls
@@ -0,0 +1,75 @@
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2018 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

configure_phpfpm_webgui:
file.managed:
- name: "/etc/php/7.0/fpm/pool.d/openmediavault-webgui.conf"
- contents: |
[openmediavault-webgui]
user = openmediavault-webgui
group = openmediavault-webgui
listen = /var/run/php-fpm-openmediavault-webgui.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0600

pm = ondemand
pm.max_children = 25
pm.process_idle_timeout = 10s

chdir = /

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; openmediavault php.ini settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Paths and Directories
php_value[include_path] = ".:/usr/share/php:/var/www/openmediavault"
; Pam Authentication Support (see /etc/pam.d)
php_value[pam.servicename] = "openmediavault-webgui";

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
php_value[upload_max_filesize] = 25M

; Maximum size of POST data that PHP will accept.
; http://php.net/post-max-size
php_value[post_max_size] = 25M

; Do not expose to the world that PHP is installed on the server.
; http://php.net/expose-php
php_value[expose_php] = Off

; Name of the session (used as cookie name).
; http://php.net/session.name
php_value[session.name] = X-OPENMEDIAVAULT-SESSIONID

; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
php_value[default_socket_timeout] = 90

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
php_value[max_execution_time] = 90
- mode: 644
- watch_in:
- service: restart_phpfpm_service
11 changes: 1 addition & 10 deletions deb/openmediavault/srv/salt/omv/deploy/phpfpm/default.sls
Expand Up @@ -18,31 +18,22 @@
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

{% set dirpath = '/srv/salt' | path_join(slspath) %}
{% set files = salt['file.find'](dirpath, iname='*.sls', print='name') | difference(['init.sls', 'default.sls']) %}

prereq_phpfpm_service_monit:
salt.state:
- tgt: '*'
- sls: omv.deploy.monit

{% if files | length > 0 %}

include:
{% for file in files %}
{% for file in salt['file.find'](dirpath, iname='*.sls', print='name') | difference(['init.sls', 'default.sls']) %}
- .{{ file | replace('.sls', '') }}
{% endfor %}

{% endif %}

test_phpfpm_service_config:
cmd.run:
- name: "php-fpm7.0 --test"

restart_phpfpm_service:
# Force service.running to always restart the service.
test.succeed_with_changes:
- watch_in:
- service: restart_phpfpm_service
service.running:
- name: php7.0-fpm
- enable: True
Expand Down
29 changes: 15 additions & 14 deletions deb/openmediavault/usr/sbin/omv-salt
Expand Up @@ -37,33 +37,32 @@ __stage_scripts_dir = openmediavault.getenv("OMV_SALT_SCRIPTS_STAGE_DIR",
__salt_minion_config_file = openmediavault.getenv(
"OMV_SALT_MINION_CONFIG_FILE", "/etc/salt/minion");

@click.group(name='cxycyx')
@click.option('-q', '--quiet', is_flag=True,
help='Quiet mode, no messages are displayed')
def cli(quiet):
__args['quiet'] = quiet
@click.group()
def cli():
return 0

@cli.group()
def stage():
pass

@stage.command(name='list', help='List available stages and exit')
@stage.command(name='list', help='List available stages and exit.')
def stage_list():
names = [ name for name in os.listdir(__stage_scripts_dir)
if os.path.isdir(os.path.join(__stage_scripts_dir, name)) ]
names.sort()
print('\n'.join(names))
sys.exit(0)

@stage.command(name='run', help='Run the specified stage')
@stage.command(name='run', help='Run the specified stage.')
@click.argument('name', 'The stage name')
def stage_run(name):
@click.option('-q', '--quiet', is_flag=True,
help='Quiet mode, no messages are displayed.')
def stage_run(name, quiet):
mopts = salt.config.minion_config(__salt_minion_config_file)
caller = salt.client.Caller(mopts=mopts)
result = caller.cmd("state.orchestrate", "omv.stage.{}".format(name))
rc = result["retcode"]
if not __args['quiet']:
if not quiet:
if "nested" == __out:
result = {"local": result}
salt.output.display_output(result, out=__out, opts=mopts)
Expand All @@ -73,17 +72,19 @@ def stage_run(name):
def deploy():
pass

@deploy.command(name='list', help='List available states and exit')
@deploy.command(name='list', help='List available states and exit.')
def deploy_list():
names = [ name for name in os.listdir(__deploy_scripts_dir)
if os.path.isdir(os.path.join(__deploy_scripts_dir, name)) ]
names.sort()
print('\n'.join(names))
sys.exit(0)

@deploy.command(name='run', help='Run the specified state(s)')
@click.argument('names', 'The state name(s)', nargs=-1)
def deploy_run(names):
@deploy.command(name='run', help='Run the specified state(s).')
@click.argument('names', 'The state name(s)', nargs=-1, required=True)
@click.option('-q', '--quiet', is_flag=True,
help='Quiet mode, no messages are displayed.')
def deploy_run(names, quiet):
# Check if the states exists.
for name in names:
path = os.path.join(__deploy_scripts_dir, name)
Expand All @@ -98,7 +99,7 @@ def deploy_run(names):
result = caller.cmd("state.orchestrate", names)
rc = result["retcode"]
# Print the output.
if not __args['quiet']:
if not quiet:
if "nested" == __out:
result = {"local": result}
salt.output.display_output(result, out=__out, opts=mopts)
Expand Down
Expand Up @@ -26,7 +26,6 @@
# http://superuser.com/questions/228657/which-linux-filesystem-works-best-with-ssd

set -e
set -x

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions
Expand Down

0 comments on commit 6966d4c

Please sign in to comment.