util-linux/uuidd.init

118 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# uuidd uuidd daemon for unique time-based UUID generation
#
# Author: Eric Sandeen <sandeen@redhat.com>
#
# chkconfig: - 60 99
#
# description: uuidd is a helper daemon to guarantee uniqueness of \
# time-based UUIDs when using libuuid.
# processname: uuidd
# pidfile: /var/lib/libuuid/uuidd.pid
#
### BEGIN INIT INFO
# Provides: uuidd
# Required-Start: $time $local_fs
# Required-Stop: $time $local_fs
# Default-Stop: 0 1 6
# Short-Description: UUID daemon
# Description: Daemon which guarantees uniqueness of time-based UUIDS
# when using libuuid.
### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
[ -e /etc/sysconfig/uuidd ] && . /etc/sysconfig/uuidd
DAEMON=uuidd
exec=/usr/sbin/uuidd
prog=uuidd
user=uuidd
lockfile=/var/lock/subsys/$DAEMON
pidfile=/var/run/uuidd/uuidd.pid
check() {
# Check that we're a privileged user
[ $(id -u) -eq 0 ] || exit 4
# Check if daemon binary is executable
[ -x $exec ] || exit 5
}
start () {
check
echo -n $"Starting $prog: "
daemon --user $user --pidfile $pidfile $DAEMON
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop () {
check
echo -n $"Stopping $prog: "
killproc $DAEMON
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $DAEMON
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?