wok-current rev 15712

connman: use pidof string if no .pid file
author Richard Dunbar <mojo@slitaz.org>
date Mon Dec 23 22:28:27 2013 +0000 (2013-12-23)
parents 7d6af743d21a
children 9d9921e751e8
files connman/stuff/etc/init.d/connman
line diff
     1.1 --- a/connman/stuff/etc/init.d/connman	Mon Dec 23 16:58:02 2013 +0000
     1.2 +++ b/connman/stuff/etc/init.d/connman	Mon Dec 23 22:28:27 2013 +0000
     1.3 @@ -1,8 +1,8 @@
     1.4  #!/bin/sh
     1.5 -# /etc/init.d/connman : Start, stop and restart the connexion manager
     1.6 +# /etc/init.d/connman : Start, stop and restart the connection manager
     1.7  # on SliTaz, at boot time or with the command line.
     1.8  #
     1.9 -# To start the connexion manager at boot time, just put connman in the
    1.10 +# To start the connection manager at boot time, just put connman in the
    1.11  # $RUN_DAEMONS variable of /etc/rcS.conf and configure options with
    1.12  # /etc/daemons.conf
    1.13  #
    1.14 @@ -10,46 +10,53 @@
    1.15  . /etc/daemons.conf
    1.16  
    1.17  NAME=Connman
    1.18 -DESC="Connexion Manager"
    1.19 -DAEMON=/usr/sbin/connmand
    1.20 +DESC="Connection Manager"
    1.21 +DAEMON=connmand
    1.22  OPTIONS=$CONNMAN_OPTIONS
    1.23 -PIDFILE=/run/connman
    1.24 +PIDFILE="$(pidof $DAEMON)"
    1.25  
    1.26  case "$1" in
    1.27    start)
    1.28 -    if active_pidfile $PIDFILE connmand ; then
    1.29 -      echo "$NAME already running."
    1.30 +    if [ -n "$PIDFILE" ] ; then
    1.31 +      echo "$NAME is already running."
    1.32        exit 1
    1.33      fi
    1.34 -    killall udhcpc 2>/dev/null
    1.35 +    pkill udhcpc 2>/dev/null
    1.36      echo -n "Starting $DESC: $NAME... "
    1.37      $DAEMON $OPTIONS
    1.38      status
    1.39      ;;
    1.40    stop)
    1.41 -    if ! active_pidfile $PIDFILE connmand ; then
    1.42 +    if [ -z "$PIDFILE" ] ; then
    1.43        echo "$NAME is not running."
    1.44        exit 1
    1.45      fi
    1.46      echo -n "Stopping $DESC: $NAME... "
    1.47 -    rm -rf $PIDFILE
    1.48 -    kill $(pidof connmand)
    1.49 +    pkill $DAEMON
    1.50 +    pkill wpa_supplicant
    1.51      status
    1.52      ;;
    1.53    restart)
    1.54 -    if ! active_pidfile $PIDFILE connmand ; then
    1.55 +    if [ -z "$PIDFILE" ] ; then
    1.56        echo "$NAME is not running."
    1.57        exit 1
    1.58      fi
    1.59      echo -n "Restarting $DESC: $NAME... "
    1.60 -    rm -rf $PIDFILE
    1.61 -    kill $(pidof connmand) &&
    1.62 +    pkill $DAEMON &&
    1.63 +    pkill wpa_supplicant &&
    1.64      sleep 2 &&
    1.65      $DAEMON $OPTIONS
    1.66      status
    1.67      ;;
    1.68 +  status)
    1.69 +    if [ -n "$PIDFILE" ] ; then
    1.70 +      echo "$NAME is running."  
    1.71 +    else
    1.72 +      echo "$NAME is not running."
    1.73 +    fi  
    1.74 +    ;;
    1.75    *)
    1.76 -	printf "\n\033[1mUsage:\033[0m /etc/init.d/%b [start|stop|restart]\n" \
    1.77 +	printf "\n\033[1mUsage:\033[0m /etc/init.d/%b [start|stop|restart|status]\n" \
    1.78  		"$(basename $0)"
    1.79      exit 1
    1.80      ;;