diff --git a/build b/build index b994ce00..2d98e862 100755 --- a/build +++ b/build @@ -113,8 +113,8 @@ case "$1" in # cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches # git describe > ${WEBDIR}/${WEBBASE}/man/VERSION - cp ${MAN1DSTDIR}/*.html ${WEBMAN}/man1 - cp ${MAN7DSTDIR}/*.html ${WEBMAN}/man7 + cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${WEBMAN}/man1 + cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${WEBMAN}/man7 cd ${WEBDIR} && git add ${WEBBASE} cd ${WEBDIR} && git commit -m "cdist update" ${WEBBASE} ${WEBPAGE} diff --git a/conf/explorer/runlevel b/conf/explorer/runlevel new file mode 100755 index 00000000..7cdd81ef --- /dev/null +++ b/conf/explorer/runlevel @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2012 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 . +# +# + +set +e +executable=$(which runlevel 2>/dev/null) +if [ -x "$executable" ]; then + "$executable" | awk '{ print $2 }' +fi diff --git a/conf/type/__start_on_boot/explorer/state b/conf/type/__start_on_boot/explorer/state new file mode 100755 index 00000000..ff092a65 --- /dev/null +++ b/conf/type/__start_on_boot/explorer/state @@ -0,0 +1,64 @@ +#!/bin/sh +# +# 2012 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 the given name will be started on boot or not +# + +os=$("$__explorer/os") +runlevel=$("$__explorer/runlevel") +name="$__object_id" + + +case "$os" in + archlinux) + # convert bash array to shell + daemons=$(grep ^DAEMONS /etc/rc.conf | sed -e 's/^.*=(//' -e 's/)$//') + + # absent, as long as not found + state="absent" + + # iterate, last one wins. + for daemon in $daemons; do + if [ "$daemon" = "$name" -o "$daemon" = "@${name}" ]; then + state="present" + elif [ "$daemon" = "!${name}" ]; then + state="absent" + fi + done + ;; + + debian|ubuntu) + state="present" + [ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent" + ;; + + centos|fedora|owl|redhat) + state="present" + state=$(chkconfig --level "$runlevel" \"$name\" || echo absent) + [ "$state" ] || state="present" + ;; + + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; +esac + +echo $state diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote new file mode 100755 index 00000000..f1788d4b --- /dev/null +++ b/conf/type/__start_on_boot/gencode-remote @@ -0,0 +1,88 @@ +#!/bin/sh +# +# 2012 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 . +# +# + +state_should="$(cat "$__object/parameter/state")" +state_is=$(cat "$__object/explorer/state") + +# Nothing todo, go away +[ "$state_should" = "$state_is" ] && exit 0 + +os=$(cat "$__global/explorer/os") +name="$__object_id" + +case "$state_should" in + present) + case "$os" in + archlinux) + echo "sed -i /etc/rc.conf \'s/^\\(DAEMONS=.*\\))/\\1 $name)/\'" + ;; + debian|ubuntu) + echo "update-rc.d \"$name\" defaults >/dev/null" + ;; + +# FIXME: Disabled until the explorer is checked +# gentoo) +# echo rc-update add \"$name\" default +# ;; + + centos|fedora|owl|redhat) + echo chkconfig \"$name\" on + ;; + + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac + ;; + + absent) + case "$os" in + archlinux) + # Replace a) at the beginning b) in the middle c) end d) only + echo "sed -i /etc/rc.conf -e 's/^\\(DAEMONS=(\\)$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) $name)/\\1)/' -e 's/^\\(DAEMONS=(\\)$name)/\\1)/'" + ;; + debian|ubuntu) + echo update-rc.d -f \"$name\" remove + ;; + +# FIXME: Disabled until the explorer is checked +# gentoo) +# echo rc-update del \"$name\" +# ;; + + centos|fedora|owl|redhat) + echo chkconfig \"$name\" off + ;; + + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac + + ;; + + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; +esac diff --git a/conf/type/__start_on_boot/man.text b/conf/type/__start_on_boot/man.text new file mode 100644 index 00000000..0e75c9ab --- /dev/null +++ b/conf/type/__start_on_boot/man.text @@ -0,0 +1,53 @@ +cdist-type__start_on_boot(7) +============================ +Nico Schottelius + + +NAME +---- +cdist-type__start_on_boot - Manage stuff to be started at boot + + +DESCRIPTION +----------- +This cdist type allows you to enable or disable stuff to be started +at boot of your operating system. + +Warning: This type has not been tested intensively and is not fully +supported (i.e. gentoo and *bsd are not implemented). + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure snmpd is started at boot +__start_on_boot snmpd + +# Same, but more explicit +__start_on_boot snmpd --state present + +# Ensure legacy configuration management will not be started +__start_on_boot puppet --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__start_on_boot/manifest b/conf/type/__start_on_boot/manifest new file mode 100755 index 00000000..6b5e1ca7 --- /dev/null +++ b/conf/type/__start_on_boot/manifest @@ -0,0 +1,24 @@ +#!/bin/sh +# +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 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 . +# + +# set default: present, if not setup +statefile="$__object/parameter/state" +[ -f "$statefile" ] || echo present > "$statefile" diff --git a/conf/type/__start_on_boot/parameter/optional b/conf/type/__start_on_boot/parameter/optional new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__start_on_boot/parameter/optional @@ -0,0 +1 @@ +state