forked from ungleich-public/cdist
Rm due to new patch from Dmitry.
This commit is contained in:
parent
d3b3fef63b
commit
574688c6e1
4 changed files with 0 additions and 107 deletions
|
@ -1,55 +0,0 @@
|
||||||
cdist-type__hosts(7)
|
|
||||||
====================
|
|
||||||
|
|
||||||
NAME
|
|
||||||
----
|
|
||||||
|
|
||||||
cdist-type__hosts - manage entries in /etc/hosts
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Add or remove entries from */etc/hosts* file.
|
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
state
|
|
||||||
|
|
||||||
If state is ``present``, make *object_id* resolve to *ip*. If
|
|
||||||
state is ``absent``, *object_id* will no longer resolve to
|
|
||||||
anything via */etc/hosts*.
|
|
||||||
|
|
||||||
ip
|
|
||||||
|
|
||||||
IP address, to which hostname (=\ *object_id*) must resolve. If
|
|
||||||
state is ``present``, this parameter is mandatory, if state is
|
|
||||||
``absent``, this parameter is silently ignored.
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
# Now `funny' resolves to 192.168.1.76,
|
|
||||||
__hosts funny --ip 192.168.1.76
|
|
||||||
# and `happy' does not resolve (at least via /etc/hosts)
|
|
||||||
__hosts happy --state absent
|
|
||||||
|
|
||||||
SEE ALSO
|
|
||||||
--------
|
|
||||||
|
|
||||||
:strong:`hosts`\ (5)
|
|
||||||
|
|
||||||
AUTHORS
|
|
||||||
-------
|
|
||||||
|
|
||||||
Dmitry Bogatov <KAction@gnu.org>
|
|
||||||
|
|
||||||
|
|
||||||
COPYING
|
|
||||||
-------
|
|
||||||
|
|
||||||
Copyright (C) 2015,2016 Dmitry Bogatov. Free use of this software is granted
|
|
||||||
under the terms of the GNU General Public License version 3 or later
|
|
||||||
(GPLv3+).
|
|
|
@ -1,49 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Copyright (C) 2015 Bogatov Dmitry <KAction@gnu.org>
|
|
||||||
#
|
|
||||||
# This program 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.
|
|
||||||
#
|
|
||||||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
hostname="$__object_id"
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
|
||||||
|
|
||||||
# First remove all lines for given hostname and then insert again.
|
|
||||||
# Otherwise, we risk having multiple entries for same hostname.
|
|
||||||
#
|
|
||||||
# There is a corner case, which we do not handle. Namely, /etc/hosts
|
|
||||||
# format allows several host names on single line, like following:
|
|
||||||
#
|
|
||||||
# 192.168.15.16 foo bar
|
|
||||||
#
|
|
||||||
# If this type manages hostname `foo', then hostname bar will get erased.
|
|
||||||
|
|
||||||
__line "__hosts/delete/${hostname}" \
|
|
||||||
--state absent \
|
|
||||||
--regex " ${hostname}[ ]*$" \
|
|
||||||
--file /etc/hosts
|
|
||||||
export require="__line/__hosts/delete/${hostname}"
|
|
||||||
|
|
||||||
case "$state" in
|
|
||||||
absent)
|
|
||||||
: # Nothing to do
|
|
||||||
;;
|
|
||||||
present)
|
|
||||||
ip="$(cat "$__object/parameter/ip")"
|
|
||||||
__line "__hosts/insert/${hostname}" \
|
|
||||||
--line "${ip} ${hostname}" \
|
|
||||||
--file /etc/hosts
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "ERROR: type (${__type##*/}) does not support state \`$state'"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
|
@ -1 +0,0 @@
|
||||||
present
|
|
|
@ -1,2 +0,0 @@
|
||||||
state
|
|
||||||
ip
|
|
Loading…
Reference in a new issue