Patchwork [meta-oe,1/7] systemd-systemctl-native: add multiple services support

login
register
mail settings
Submitter Andreas Müller
Date Feb. 11, 2012, 1:59 a.m.
Message ID <1328925603-2967-1-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/21161/
State Accepted
Commit 9d72ff10c51963513f33ce8dbf42822abf42f6b7
Headers show

Comments

Andreas Müller - Feb. 11, 2012, 1:59 a.m.
Thanks to Otavio Salvador for helping hint [1]

[1] http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-February/037856.html

Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 .../systemd/systemd-systemctl-native/systemctl     |   75 +++++++++++---------
 1 files changed, 42 insertions(+), 33 deletions(-)
Otavio Salvador - Feb. 11, 2012, 1:05 p.m.
Acked-by: Otavio Salvador <otavio@ossystems.com.br>

On Fri, Feb 10, 2012 at 23:59, Andreas Müller
<schnitzeltony@googlemail.com>wrote:

> Thanks to Otavio Salvador for helping hint [1]
>
> [1]
> http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-February/037856.html
>
> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> ---
>  .../systemd/systemd-systemctl-native/systemctl     |   75
> +++++++++++---------
>  1 files changed, 42 insertions(+), 33 deletions(-)
>
> diff --git
> a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
> b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
> index 54c1a18..72b9da3 100755
> --- a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
> +++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
> @@ -10,50 +10,59 @@ while [ $# != 0 ]; do
>                enable)
>                        shift
>
> -                       service="$1"
> +                       services="$1"
> +                       in_enable="1"
>                        shift
>                        ;;
>                --root=*)
>                        ROOT=${opt##--root=}
> +                       in_enable="0"
>                        shift
>                        ;;
>                *)
> -                       echo "'$opt' is an unkown option; exiting with
> error"
> -                       exit 1
> +                       if [ "$in_enable" = "1" ]; then
> +                               services="$services $opt"
> +                               shift
> +                       else
> +                               echo "'$opt' is an unkown option; exiting
> with error"
> +                               exit 1
> +                       fi
>                        ;;
>        esac
>  done
>
> -# find service file
> -for p in $ROOT/etc/systemd/system \
> -         $ROOT/lib/systemd/system \
> -         $ROOT/usr/lib/systemd/system; do
> -       if [ -e $p/$service ]; then
> -               service_file=$p/$service
> -               service_file=${service_file##$ROOT}
> +for service in "$services"; do
> +       # find service file
> +       for p in $ROOT/etc/systemd/system \
> +                $ROOT/lib/systemd/system \
> +                $ROOT/usr/lib/systemd/system; do
> +               if [ -e $p/$service ]; then
> +                       service_file=$p/$service
> +                       service_file=${service_file##$ROOT}
> +               fi
> +       done
> +       if [ -z "$service_file" ]; then
> +               echo "'$service' couldn't be found; exiting with error"
> +               exit 1
>        fi
> -done
> -if [ -z "$service_file" ]; then
> -       echo "'$service' couldn't be found; exiting with error"
> -       exit 1
> -fi
> -
> -# create the required symbolic links
> -wanted_by=$(grep WantedBy $ROOT/$service_file \
> -                | sed 's,WantedBy=,,g' \
> -                | tr ',' '\n' \
> -                | grep '\.target$')
> -
> -for r in $wanted_by; do
> -       mkdir -p $ROOT/etc/systemd/system/$r.wants
> -       ln -s $service_file $ROOT/etc/systemd/system/$r.wants
> -       echo "Enabled $service for $wanted_by."
> -done
>
> -# call us for the other required scripts
> -also=$(grep Also $ROOT/$service_file \
> -           | sed 's,Also=,,g' \
> -           | tr ',' '\n')
> -for a in $also; do
> -       $0 --root=$ROOT enable $a
> +       # create the required symbolic links
> +       wanted_by=$(grep WantedBy $ROOT/$service_file \
> +                       | sed 's,WantedBy=,,g' \
> +                       | tr ',' '\n' \
> +                       | grep '\.target$')
> +
> +       for r in $wanted_by; do
> +               mkdir -p $ROOT/etc/systemd/system/$r.wants
> +               ln -s $service_file $ROOT/etc/systemd/system/$r.wants
> +               echo "Enabled $service for $wanted_by."
> +       done
> +
> +       # call us for the other required scripts
> +       also=$(grep Also $ROOT/$service_file \
> +                  | sed 's,Also=,,g' \
> +                  | tr ',' '\n')
> +       for a in $also; do
> +               $0 --root=$ROOT enable $a
> +       done
>  done
> --
> 1.7.4.4
>
>
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
>

Patch

diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
index 54c1a18..72b9da3 100755
--- a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
+++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
@@ -10,50 +10,59 @@  while [ $# != 0 ]; do
 		enable)
 			shift
 
-			service="$1"
+			services="$1"
+			in_enable="1"
 			shift
 			;;
 		--root=*)
 			ROOT=${opt##--root=}
+			in_enable="0"
 			shift
 			;;
 		*)
-			echo "'$opt' is an unkown option; exiting with error"
-			exit 1
+			if [ "$in_enable" = "1" ]; then
+				services="$services $opt" 
+				shift
+			else
+				echo "'$opt' is an unkown option; exiting with error"
+				exit 1
+			fi
 			;;
 	esac
 done
 
-# find service file
-for p in $ROOT/etc/systemd/system \
-         $ROOT/lib/systemd/system \
-         $ROOT/usr/lib/systemd/system; do
-	if [ -e $p/$service ]; then
-		service_file=$p/$service
-		service_file=${service_file##$ROOT}
+for service in "$services"; do
+	# find service file
+	for p in $ROOT/etc/systemd/system \
+		 $ROOT/lib/systemd/system \
+		 $ROOT/usr/lib/systemd/system; do
+		if [ -e $p/$service ]; then
+			service_file=$p/$service
+			service_file=${service_file##$ROOT}
+		fi
+	done
+	if [ -z "$service_file" ]; then
+		echo "'$service' couldn't be found; exiting with error"
+		exit 1
 	fi
-done
-if [ -z "$service_file" ]; then
-	echo "'$service' couldn't be found; exiting with error"
-	exit 1
-fi
-
-# create the required symbolic links
-wanted_by=$(grep WantedBy $ROOT/$service_file \
-                | sed 's,WantedBy=,,g' \
-                | tr ',' '\n' \
-                | grep '\.target$')
-
-for r in $wanted_by; do
-	mkdir -p $ROOT/etc/systemd/system/$r.wants
-	ln -s $service_file $ROOT/etc/systemd/system/$r.wants
-	echo "Enabled $service for $wanted_by."
-done
 
-# call us for the other required scripts
-also=$(grep Also $ROOT/$service_file \
-           | sed 's,Also=,,g' \
-           | tr ',' '\n')
-for a in $also; do
-	$0 --root=$ROOT enable $a
+	# create the required symbolic links
+	wanted_by=$(grep WantedBy $ROOT/$service_file \
+		        | sed 's,WantedBy=,,g' \
+		        | tr ',' '\n' \
+		        | grep '\.target$')
+
+	for r in $wanted_by; do
+		mkdir -p $ROOT/etc/systemd/system/$r.wants
+		ln -s $service_file $ROOT/etc/systemd/system/$r.wants
+		echo "Enabled $service for $wanted_by."
+	done
+
+	# call us for the other required scripts
+	also=$(grep Also $ROOT/$service_file \
+		   | sed 's,Also=,,g' \
+		   | tr ',' '\n')
+	for a in $also; do
+		$0 --root=$ROOT enable $a
+	done
 done