From 2acce10497d83dcd7f49d94081bf1f13bda1b548 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Jun 2013 23:45:22 +0200 Subject: [PATCH] change __start_on_boot to use systemd on archlinux Signed-off-by: Nico Schottelius --- .../conf/type/__start_on_boot/explorer/state | 20 +++++++------------ .../conf/type/__start_on_boot/gencode-remote | 10 +++------- docs/changelog | 1 + 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 6fd0ea92..b156fc82 100755 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -29,19 +29,13 @@ name="$__object_id" case "$os" in archlinux) # convert bash array to shell - daemons=$(grep ^DAEMONS /etc/rc.conf | sed -e 's/^.*=(//' -e 's/)$//') + systemctl is-enabled "$name" >/dev/null 2>&1; ret=$? - # 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 + if [ "$ret" = 0 ]; then + state="present" + else + state="absent" + fi ;; debian|ubuntu|openwrt) diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 7724e8c7..58ff6a4a 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -32,8 +32,7 @@ case "$state_should" in present) case "$os" in archlinux) - echo "sed 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf > /etc/rc.conf.cdist-tmp" - echo "mv /etc/rc.conf.cdist-tmp /etc/rc.conf" + echo "systemctl enable \"$name\"" ;; debian|ubuntu) echo "update-rc.d \"$name\" defaults >/dev/null" @@ -65,10 +64,7 @@ case "$state_should" in absent) case "$os" in archlinux) - # Replace a) at the beginning b) in the middle c) end d) only - # Support @name as well...makes it more ugly, but well... - echo "sed /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/' > /etc/rc.conf.cdist-tmp" - echo "mv /etc/rc.conf.cdist-tmp /etc/rc.conf" + echo "systemctl disable \"$name\"" ;; debian|ubuntu) echo update-rc.d -f \"$name\" remove diff --git a/docs/changelog b/docs/changelog index 3b92bd56..ec59b937 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ next: * Build: Change clean-dist target to "distclean" * Change execution order to run object as one unit * Type __apt_ppa: Fix comparison operator (Tyler Akins) + * Type __start_on_boot: Archlinux changed to use systemd - adapt 2.1.1: 2013-04-08 * Core: Use dynamic dependency resolver to allow indirect self dependencies