view network/dbus/dbus @ 1216:6710613b88b9

misc: remove build function
author David Demelier <markand@malikania.fr>
date Wed, 29 Sep 2021 13:49:32 +0200
parents f373703bdc0e
children 1a6e1b476561
line wrap: on
line source

#!/bin/busybox sh
#
# /etc/rc.d/dbus -- run control script for dbus
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

: ${DBUS_CMD:=/bin/dbus-daemon}
: ${DBUS_ARGS:=--system}
: ${DBUS_PID:=/var/run/dbus.pid}

dbus_start()
{
	mkdir -p /var/run/dbus

	if [ -s $DBUS_PID ]; then
		echo "dbus is already running with pid: $(cat $DBUS_PID)"
	else
		echo "Starting dbus: $DBUS_CMD $DBUS_ARGS"
		$DBUS_CMD $DBUS_ARGS
	fi
}

dbus_status()
{
	if [ -s $DBUS_PID ]; then
		echo "dbus is running with pid: $(cat $DBUS_PID)"
	else
		echo "dbus is not running"
	fi
}

dbus_stop()
{
	if [ -s $DBUS_PID ]; then
		echo "Stopping dbus."
		kill -QUIT $(cat $DBUS_PID)
		rm -f $DBUS_PID
	fi
}

dbus_restart()
{
	dbus_stop
	sleep 3
	dbus_start
}

case $1 in
start)
	dbus_start
	;;
status)
	dbus_status
	;;
stop)
	dbus_stop
	;;
restart)
	dbus_restart
	;;
*)
	echo "usage: $(basename $0) restart|start|status|stop"
	;;
esac