#!/bin/bash
### BEGIN INIT INFO
# Provides: NetworkManager
# Required-Start: $network dbus
# Required-Stop: $network dbus
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
### END INIT INFO
. /lib/lsb/init-functions

[ -e /etc/default/NetworkManager ] && source /etc/default/NetworkManager
[ $(/usr/bin/tty -s; echo $?) -gt 0 -o  "$(/usr/bin/tty)" == "/dev/console" ] && [ "$START_NETWORK_MANAGER" != "TRUE" ] && exit 0

prefix=/usr
exec_prefix=/usr
sbindir=${exec_prefix}/sbin

case "$1" in
	start)
		echo -n "Starting NetworkManager..."
		if start_daemon $sbindir/NetworkManager
		then
			log_success_msg
		else
			log_failure_msg
		fi
		;;
	stop)
		echo -n "Stopping NetworkManager..."
		if killproc $sbindir/NetworkManager
		then
			log_success_msg "."
		else
			log_failure_msg
		fi
		;;
	restart|force-reload)
		$0 stop
		sleep 1
		$0 start
		;;
	try-restart)
		if pidofproc $sbindir/NetworkManager
		then
			$0 restart
		fi
		;;
	status)
		pidofproc $sbindir/NetworkManager
		exit $?
		;;
	*)
		echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
		exit 1
		;;
esac
