From c790014cd59d65181d83a42d5f7b45ef2d2264c8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 10:11:23 +0100 Subject: [PATCH 1/9] add scaled version of the cdist logo Signed-off-by: Nico Schottelius --- docs/gfx/cdist-logo-1024-scaled.png | Bin 0 -> 2509 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/gfx/cdist-logo-1024-scaled.png diff --git a/docs/gfx/cdist-logo-1024-scaled.png b/docs/gfx/cdist-logo-1024-scaled.png new file mode 100644 index 0000000000000000000000000000000000000000..4be8d4c96a9e6ff645fe08ceef4df9afb3f218c4 GIT binary patch literal 2509 zcmYLLc{tQ-8-9K>%vjEhB}oR2WNT6!A|n|gWN8jUB~6kz31#2slcaD=*_YAaSVESL zl6_8eWC>qnI~o%@(Lwet@{PZ~>w4bnzOVOs{&=4Ey|4Ru9#E}KaYE8U0Dv<$GqwTX z<5846g66^3rHdXsz)&siOnA7nvr{nq`j}nt1rXk|dl1OXmf~Gv{miXQup9(0 zfEACcHn8BOT{Jf~vR`0@|1S*bA;SU zEUC~CIZ*jd!RoBdk4T>ag7T-*J2Ol3aT)?q#Q#TK;%M2HGC%wDxwT==yMxZ2!oKw_ zJ+M9j-Kw9%*aF+31bJ|DOhDVSg<;Mc{hTm@{VD-Hd|Zu}f7Hz35_`5buPn z$VPEJ;Ps#L276|oWQ-*)3Nk|dPKDX>^Melml&K}3ifgcw;}Qnqi}+5C--U|jg!g$# zMQI?c=AAx@a}Xg$PUNnxMW*0R)T)xG!Eat@1N{rax;tCAQ=WcVUjj{&VfEg3QKLT) zhEWmXwTqOzK(ZRK_Nva-61@KJJq3=9aOZLFDOZErZQv-)J@tM|5q2M_w8Em3%oLVQ^9zO5Kc&4bEkc zF2-EewT_3@sHM$T*Uw<3%Ms!hUJuns<@f9(-2%u5^9%ADG)*3j6k^FdY#VsGLsP*3 zGLJcUa7pyhquAIV2m!hhuqBGjidr$B8}A5tn(e|W(BoD&;g9Z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3WSl6IrrYmESN+s}(M$^X-hH#3cTs-3Q7An=* u1T=dD5#pH`1I1ghC=c<5qI`zE;+rD*j_v!NkL&F&ZeVU=ZCrku7WF^fT1X!N literal 0 HcmV?d00001 From 13001924c083f5a61a1060d0ac392edbdb750eff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 10:52:28 +0100 Subject: [PATCH 2/9] do not touch a visible file during release process Signed-off-by: Nico Schottelius --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 # From 5279b7239ce0d34c6d0a504e2ae9dd84c354df29 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 13:47:45 +0100 Subject: [PATCH 3/9] import __hostname - Thanks, Steven! Signed-off-by: Nico Schottelius --- cdist/conf/type/__hostname/gencode-remote | 33 +++++++++++++ cdist/conf/type/__hostname/man.text | 47 +++++++++++++++++++ cdist/conf/type/__hostname/manifest | 42 +++++++++++++++++ cdist/conf/type/__hostname/parameter/optional | 1 + cdist/conf/type/__hostname/singleton | 0 5 files changed, 123 insertions(+) create mode 100755 cdist/conf/type/__hostname/gencode-remote create mode 100644 cdist/conf/type/__hostname/man.text create mode 100755 cdist/conf/type/__hostname/manifest create mode 100644 cdist/conf/type/__hostname/parameter/optional create mode 100644 cdist/conf/type/__hostname/singleton diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote new file mode 100755 index 00000000..88ee069a --- /dev/null +++ b/cdist/conf/type/__hostname/gencode-remote @@ -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 . +# + +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 diff --git a/cdist/conf/type/__hostname/man.text b/cdist/conf/type/__hostname/man.text new file mode 100644 index 00000000..07ec1083 --- /dev/null +++ b/cdist/conf/type/__hostname/man.text @@ -0,0 +1,47 @@ +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%%.*}) + + +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..3aa6de45 --- /dev/null +++ b/cdist/conf/type/__hostname/manifest @@ -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 . +# + +# 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 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 From 29d4f910bcc61c9e16aa11d879fc3471bf93dffc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 13:50:42 +0100 Subject: [PATCH 4/9] do not change parameters Signed-off-by: Nico Schottelius --- cdist/conf/type/__hostname/gencode-remote | 8 +++++++- cdist/conf/type/__hostname/manifest | 6 +----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 88ee069a..ef8eda51 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,7 +19,12 @@ # along with cdist. If not, see . # -name="$(cat "$__object/parameter/name")" +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__target_host" +fi + os=$(cat "$__global/explorer/os") echo "printf '%s\n' '$name' > /etc/hostname" diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 3aa6de45..0544a6f9 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -1,6 +1,7 @@ #!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,10 +19,6 @@ # along with cdist. If not, see . # -# set defaults -name="$(cat "$__object/parameter/name" 2>/dev/null \ - || echo "${__target_host%%.*}" | tee "$__object/parameter/name")" - os=$(cat "$__global/explorer/os") not_supported() { @@ -33,7 +30,6 @@ not_supported() { case "$os" in archlinux|debian|ubuntu) # handled in gencode-remote - # FIXED: hostname setup in archlinuz via rc.local ist outdated : ;; *) From 9123940255d2dd0ceb908e47c63a0fdbcf439fc4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 13:51:48 +0100 Subject: [PATCH 5/9] port selection of first part into gencode-remote Signed-off-by: Nico Schottelius --- cdist/conf/type/__hostname/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index ef8eda51..6760507f 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -22,7 +22,7 @@ if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" else - name="$__target_host" + name="$(echo "${__target_host%%.*}")" fi os=$(cat "$__global/explorer/os") From cd6abf379ac10588a0e21949545d60c3d2a2b021 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 13:52:49 +0100 Subject: [PATCH 6/9] allow hostname -f to fail and return empty output Signed-off-by: Nico Schottelius --- cdist/conf/explorer/hostname | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/explorer/hostname b/cdist/conf/explorer/hostname index 881c910a..e1017227 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. @@ -21,5 +21,5 @@ # if command -v hostname >/dev/null; then - hostname -f + hostname -f 2>/dev/null || true fi From 8d5357107bda2b34b1ef55725bc0666d56ce6231 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 14:07:31 +0100 Subject: [PATCH 7/9] use uname -n in hostname explorer Signed-off-by: Nico Schottelius --- cdist/conf/explorer/hostname | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/explorer/hostname b/cdist/conf/explorer/hostname index e1017227..7715c6b0 100755 --- a/cdist/conf/explorer/hostname +++ b/cdist/conf/explorer/hostname @@ -20,6 +20,6 @@ # # -if command -v hostname >/dev/null; then - hostname -f 2>/dev/null || true +if command -v uname >/dev/null; then + uname -n fi From b6bae508a8641ee6a6bba0751bf57b2d8113b4bf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 14:26:22 +0100 Subject: [PATCH 8/9] use hostnamectl, if available, else use /etc/hostname and hostname Signed-off-by: Nico Schottelius --- .../type/__hostname/explorer/has_hostnamectl | 24 ++++++++++++++ .../type/__hostname/explorer/hostname_file | 26 +++++++++++++++ cdist/conf/type/__hostname/gencode-remote | 33 ++++++++++++------- cdist/conf/type/__hostname/man.text | 5 +++ 4 files changed, 77 insertions(+), 11 deletions(-) create mode 100755 cdist/conf/type/__hostname/explorer/has_hostnamectl create mode 100755 cdist/conf/type/__hostname/explorer/hostname_file 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 index 6760507f..3d208cbe 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -20,20 +20,31 @@ # if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" + name_should="$(cat "$__object/parameter/name")" else - name="$(echo "${__target_host%%.*}")" + 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") -echo "printf '%s\n' '$name' > /etc/hostname" +################################################################################ +# If everything is ok -> exit +# +if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then + exit 0 +fi -case "$os" in - debian|ubuntu) - echo "hostname \"$name\"" - ;; - archlinux) - echo "hostnamectl set-hostname \"$name\"" - ;; -esac +################################################################################ +# 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 index 07ec1083..ac44d426 100644 --- a/cdist/conf/type/__hostname/man.text +++ b/cdist/conf/type/__hostname/man.text @@ -24,6 +24,11 @@ name:: (${__target_host%%.*}) +MESSAGES +-------- +changed:: + Changed the hostname + EXAMPLES -------- From f7c44378732ff98954ae94a8c8fe74cf632f91ed Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Jan 2014 14:27:26 +0100 Subject: [PATCH 9/9] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) 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)