Merge branch 'feature_init_process'

This commit is contained in:
Nico Schottelius 2012-02-15 09:40:50 +01:00
commit 9ee774c31b
7 changed files with 258 additions and 2 deletions

4
build
View file

@ -113,8 +113,8 @@ case "$1" in
# cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches # cp ${SPEECHESDIR}/*.pdf ${WEBDIR}/${WEBBASE}/speeches
# git describe > ${WEBDIR}/${WEBBASE}/man/VERSION # git describe > ${WEBDIR}/${WEBBASE}/man/VERSION
cp ${MAN1DSTDIR}/*.html ${WEBMAN}/man1 cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${WEBMAN}/man1
cp ${MAN7DSTDIR}/*.html ${WEBMAN}/man7 cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${WEBMAN}/man7
cd ${WEBDIR} && git add ${WEBBASE} cd ${WEBDIR} && git add ${WEBBASE}
cd ${WEBDIR} && git commit -m "cdist update" ${WEBBASE} ${WEBPAGE} cd ${WEBDIR} && git commit -m "cdist update" ${WEBBASE} ${WEBPAGE}

26
conf/explorer/runlevel Executable file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
#
set +e
executable=$(which runlevel 2>/dev/null)
if [ -x "$executable" ]; then
"$executable" | awk '{ print $2 }'
fi

View file

@ -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 <http://www.gnu.org/licenses/>.
#
#
# 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

View file

@ -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 <http://www.gnu.org/licenses/>.
#
#
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

View file

@ -0,0 +1,53 @@
cdist-type__start_on_boot(7)
============================
Nico Schottelius <nico-cdist--@--schottelius.org>
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).

View file

@ -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 <http://www.gnu.org/licenses/>.
#
# set default: present, if not setup
statefile="$__object/parameter/state"
[ -f "$statefile" ] || echo present > "$statefile"

View file

@ -0,0 +1 @@
state