2012-01-18 12:31:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2013-06-09 21:45:22 +00:00
|
|
|
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
2013-12-19 12:54:16 +00:00
|
|
|
# 2013 Daniel Heule (hda at sfs.biz)
|
2012-01-18 12:31:22 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2013-12-18 17:09:57 +00:00
|
|
|
state_should="$(cat "$__object/parameter/state")"
|
2012-01-18 15:07:33 +00:00
|
|
|
state_is=$(cat "$__object/explorer/state")
|
2013-12-19 12:54:16 +00:00
|
|
|
target_runlevel="$(cat "$__object/parameter/target_runlevel")"
|
2012-01-18 15:07:33 +00:00
|
|
|
|
2012-06-15 08:03:26 +00:00
|
|
|
# Short circuit if nothing is to be done
|
2012-01-18 15:07:33 +00:00
|
|
|
[ "$state_should" = "$state_is" ] && exit 0
|
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
os=$(cat "$__global/explorer/os")
|
2015-05-11 23:13:20 +00:00
|
|
|
os_version=$(cat "$__global/explorer/os_version")
|
2012-01-18 14:54:32 +00:00
|
|
|
name="$__object_id"
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
case "$state_should" in
|
|
|
|
present)
|
|
|
|
case "$os" in
|
2012-01-20 13:57:25 +00:00
|
|
|
archlinux)
|
2013-06-09 21:45:22 +00:00
|
|
|
echo "systemctl enable \"$name\""
|
2012-01-20 13:57:25 +00:00
|
|
|
;;
|
2015-05-11 23:13:20 +00:00
|
|
|
debian)
|
|
|
|
case "$os_version" in
|
|
|
|
[1-7]*)
|
|
|
|
echo "update-rc.d \"$name\" defaults >/dev/null"
|
|
|
|
;;
|
|
|
|
8*)
|
|
|
|
echo "systemctl enable \"$name\""
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported version $os_version of $os" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2012-01-18 14:54:32 +00:00
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2013-12-19 12:54:16 +00:00
|
|
|
gentoo)
|
|
|
|
echo rc-update add \"$name\" \"$target_runlevel\"
|
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-06-15 08:23:19 +00:00
|
|
|
amazon|centos|fedora|owl|redhat|suse)
|
2012-01-18 15:07:33 +00:00
|
|
|
echo chkconfig \"$name\" on
|
2012-01-18 14:54:32 +00:00
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-02-21 14:48:39 +00:00
|
|
|
openwrt)
|
|
|
|
# 'enable' can be successful and still return a non-zero exit
|
|
|
|
# code, deal with it by checking for success ourselves in that
|
|
|
|
# case (the || ... part).
|
|
|
|
echo "/etc/init.d/\"$name\" enable || [ -f /etc/rc.d/S??\"$name\" ]"
|
|
|
|
;;
|
|
|
|
|
2015-05-11 23:13:20 +00:00
|
|
|
ubuntu)
|
|
|
|
echo "update-rc.d \"$name\" defaults >/dev/null"
|
|
|
|
;;
|
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
*)
|
|
|
|
echo "Unsupported os: $os" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
absent)
|
2012-01-18 15:07:33 +00:00
|
|
|
case "$os" in
|
2012-01-20 14:34:18 +00:00
|
|
|
archlinux)
|
2013-06-09 21:45:22 +00:00
|
|
|
echo "systemctl disable \"$name\""
|
2012-01-20 14:34:18 +00:00
|
|
|
;;
|
2012-01-18 15:07:33 +00:00
|
|
|
debian|ubuntu)
|
|
|
|
echo update-rc.d -f \"$name\" remove
|
|
|
|
;;
|
|
|
|
|
2013-12-19 12:54:16 +00:00
|
|
|
gentoo)
|
|
|
|
echo rc-update del \"$name\" \"$target_runlevel\"
|
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-06-15 08:23:19 +00:00
|
|
|
centos|fedora|owl|redhat|suse)
|
2012-01-18 15:07:33 +00:00
|
|
|
echo chkconfig \"$name\" off
|
|
|
|
;;
|
|
|
|
|
2012-02-21 14:48:39 +00:00
|
|
|
openwrt)
|
|
|
|
echo "\"/etc/init.d/$name\" disable"
|
|
|
|
;;
|
|
|
|
|
2012-01-18 15:07:33 +00:00
|
|
|
*)
|
|
|
|
echo "Unsupported os: $os" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
|
2012-01-18 14:54:32 +00:00
|
|
|
*)
|
|
|
|
echo "Unknown state: $state_should" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2012-01-18 12:31:22 +00:00
|
|
|
esac
|