import __hostname - Thanks, Steven!

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2014-01-20 13:47:45 +01:00
parent 13001924c0
commit 5279b7239c
5 changed files with 123 additions and 0 deletions

View file

@ -0,0 +1,33 @@
#!/bin/sh
#
# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
name="$(cat "$__object/parameter/name")"
os=$(cat "$__global/explorer/os")
echo "printf '%s\n' '$name' > /etc/hostname"
case "$os" in
debian|ubuntu)
echo "hostname \"$name\""
;;
archlinux)
echo "hostnamectl set-hostname \"$name\""
;;
esac

View file

@ -0,0 +1,47 @@
cdist-type__hostname(7)
=======================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__hostname - set the hostname
DESCRIPTION
-----------
Set's the hostname on various operating systems.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
name::
The hostname to set. Defaults to the first segment of __target_host
(${__target_host%%.*})
EXAMPLES
--------
--------------------------------------------------------------------------------
# take hostname from __target_host
__hostname
# set hostname explicitly
__hostname --name some-static-hostname
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2012 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1,42 @@
#!/bin/sh
#
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
# set defaults
name="$(cat "$__object/parameter/name" 2>/dev/null \
|| echo "${__target_host%%.*}" | tee "$__object/parameter/name")"
os=$(cat "$__global/explorer/os")
not_supported() {
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
echo "Please contribute an implementation for it if you can." >&2
exit 1
}
case "$os" in
archlinux|debian|ubuntu)
# handled in gencode-remote
# FIXED: hostname setup in archlinuz via rc.local ist outdated
:
;;
*)
not_supported
;;
esac

View file

@ -0,0 +1 @@
name

View file