diff --git a/Makefile b/Makefile index 5910ab2e..1962c96e 100644 --- a/Makefile +++ b/Makefile @@ -175,10 +175,12 @@ freecode-release: $(FREECODE_FILE) ################################################################################ # pypi # -pypi-release: man $(PYTHON_VERSION) +PYPI_FILE=.pypi-release +$(PYPI_FILE): man $(PYTHON_VERSION) python3 setup.py sdist upload touch $@ +pypi-release: $(PYPI_FILE) ################################################################################ # archlinux # diff --git a/cdist/conf/explorer/hostname b/cdist/conf/explorer/hostname index 881c910a..7715c6b0 100755 --- a/cdist/conf/explorer/hostname +++ b/cdist/conf/explorer/hostname @@ -1,6 +1,6 @@ #!/bin/sh # -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. @@ -20,6 +20,6 @@ # # -if command -v hostname >/dev/null; then - hostname -f +if command -v uname >/dev/null; then + uname -n fi diff --git a/cdist/conf/type/__hostname/explorer/has_hostnamectl b/cdist/conf/type/__hostname/explorer/has_hostnamectl new file mode 100755 index 00000000..9040023d --- /dev/null +++ b/cdist/conf/type/__hostname/explorer/has_hostnamectl @@ -0,0 +1,24 @@ +#!/bin/sh +# +# 2014 Nico Schottelius (nico-cdist at schottelius.org) +# +# 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 . +# +# +# Check whether system has hostnamectl +# + +command -v hostnamectl || true diff --git a/cdist/conf/type/__hostname/explorer/hostname_file b/cdist/conf/type/__hostname/explorer/hostname_file new file mode 100755 index 00000000..ed28c8a8 --- /dev/null +++ b/cdist/conf/type/__hostname/explorer/hostname_file @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2014 Nico Schottelius (nico-cdist at schottelius.org) +# +# 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 . +# +# +# Retrieve the contents of /etc/hostname +# + +if [ -f /etc/hostname ]; then + cat /etc/hostname +fi diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote new file mode 100755 index 00000000..3d208cbe --- /dev/null +++ b/cdist/conf/type/__hostname/gencode-remote @@ -0,0 +1,50 @@ +#!/bin/sh +# +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) +# +# 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 . +# + +if [ -f "$__object/parameter/name" ]; then + name_should="$(cat "$__object/parameter/name")" +else + name_should="$(echo "${__target_host%%.*}")" +fi + +os=$(cat "$__global/explorer/os") +name_running=$(cat "$__global/explorer/hostname") +name_config=$(cat "$__object/explorer/hostname_file") +has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") + +################################################################################ +# If everything is ok -> exit +# +if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then + exit 0 +fi + +################################################################################ +# Setup hostname +# +echo changed >> "$__messages_out" + +if [ "$has_hostnamectl" ]; then + echo "hostnamectl set-hostname '$name_should'" +else + echo "hostname '$name_should'" + echo "printf '%s\n' '$name_should' > /etc/hostname" +fi diff --git a/cdist/conf/type/__hostname/man.text b/cdist/conf/type/__hostname/man.text new file mode 100644 index 00000000..ac44d426 --- /dev/null +++ b/cdist/conf/type/__hostname/man.text @@ -0,0 +1,52 @@ +cdist-type__hostname(7) +======================= +Steven Armstrong + + +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%%.*}) + + +MESSAGES +-------- +changed:: + Changed the hostname + +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). diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest new file mode 100755 index 00000000..0544a6f9 --- /dev/null +++ b/cdist/conf/type/__hostname/manifest @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) +# +# 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 . +# + +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 + : + ;; + *) + not_supported + ;; +esac diff --git a/cdist/conf/type/__hostname/parameter/optional b/cdist/conf/type/__hostname/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/cdist/conf/type/__hostname/parameter/optional @@ -0,0 +1 @@ +name diff --git a/cdist/conf/type/__hostname/singleton b/cdist/conf/type/__hostname/singleton new file mode 100644 index 00000000..e69de29b diff --git a/docs/changelog b/docs/changelog index a3d5c4fd..f43131a1 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,8 @@ Changelog 3.0.3: * Core: Enhance error message when requirement is missing object id + * Explorer hostname: Return host name by using uname -n + * New Type: __hostname (Steven Armstrong) 3.0.2: 2014-01-19 * Documentation: Document all messages sent by types (Daniel Heule) diff --git a/docs/gfx/cdist-logo-1024-scaled.png b/docs/gfx/cdist-logo-1024-scaled.png new file mode 100644 index 00000000..4be8d4c9 Binary files /dev/null and b/docs/gfx/cdist-logo-1024-scaled.png differ