forked from ungleich-public/cdist
Add new type __firewalld_start.
This commit is contained in:
parent
7329b528f6
commit
f7381e261a
7 changed files with 164 additions and 0 deletions
84
cdist/conf/type/__firewalld_start/gencode-remote
Normal file
84
cdist/conf/type/__firewalld_start/gencode-remote
Normal file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2016 Darko Poljak(darko.poljak at ungleich.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist 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
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist 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 cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
startstate="$(cat "$__object/parameter/startstate")"
|
||||
init=$(cat "$__global/explorer/init")
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
os_version=$(cat "$__global/explorer/os_version")
|
||||
name="firewalld"
|
||||
|
||||
case "${startstate}" in
|
||||
present)
|
||||
cmd="start"
|
||||
;;
|
||||
absent)
|
||||
cmd="stop"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown startstate: ${startstate}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$init" = 'systemd' ]; then
|
||||
# this handles ALL linux distros with systemd
|
||||
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
|
||||
echo "systemctl \"$cmd\" \"$name\""
|
||||
else
|
||||
case "$os" in
|
||||
debian)
|
||||
case "$os_version" in
|
||||
[1-7]*)
|
||||
echo "service \"$name\" \"$cmd\""
|
||||
;;
|
||||
8*)
|
||||
echo "systemctl \"$cmd\" \"$name\""
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported version $os_version of $os" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
gentoo)
|
||||
echo service \"$name\" \"$cmd\"
|
||||
;;
|
||||
|
||||
amazon|scientific|centos|fedora|owl|redhat|suse)
|
||||
echo service \"$name\" \"$cmd\"
|
||||
;;
|
||||
|
||||
openwrt)
|
||||
echo "/etc/init.d/\"$name\" \"$cmd\""
|
||||
;;
|
||||
|
||||
ubuntu)
|
||||
echo "service \"$name\" \"$cmd\""
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unsupported os: $os" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
53
cdist/conf/type/__firewalld_start/man.rst
Normal file
53
cdist/conf/type/__firewalld_start/man.rst
Normal file
|
@ -0,0 +1,53 @@
|
|||
cdist-type__firewalld_start(7)
|
||||
=============================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__firewalld_start - start and enable firewalld
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to start and enable firewalld.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
startstate
|
||||
'present' or 'absent', start/stop firewalld. Default is 'present'.
|
||||
bootstate
|
||||
'present' or 'absent', enable/disable firewalld on boot. Default is 'present'.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# start and enable firewalld
|
||||
__firewalld_start
|
||||
|
||||
# only enable firewalld to start on boot
|
||||
__firewalld_start --startstate present --bootstate absent
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`firewalld`\ (8)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Darko Poljak <darko.poljak--@--ungleich.ch>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2016 Darko Poljak. 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 (at your option) any later version.
|
23
cdist/conf/type/__firewalld_start/manifest
Normal file
23
cdist/conf/type/__firewalld_start/manifest
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2016 Darko Poljak (darko.poljak at ungleich.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist 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
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist 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 cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
bootstate="$(cat "$__object/parameter/bootstate")"
|
||||
|
||||
__package firewalld
|
||||
require="__package/firewalld" __start_on_boot firewalld --state "${bootstate}"
|
|
@ -0,0 +1 @@
|
|||
present
|
|
@ -0,0 +1 @@
|
|||
present
|
2
cdist/conf/type/__firewalld_start/parameter/optional
Normal file
2
cdist/conf/type/__firewalld_start/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
bootstate
|
||||
startstate
|
0
cdist/conf/type/__firewalld_start/singleton
Normal file
0
cdist/conf/type/__firewalld_start/singleton
Normal file
Loading…
Reference in a new issue