mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-26 10:03:37 +03:00
92 lines
1.4 KiB
Bash
Executable File
92 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# /etc/rc.d/init.d/oned
|
|
#
|
|
# Starts the OpenNebula daemon
|
|
#
|
|
# chkconfig: 345 26 74
|
|
# description: Starts the OpenNebula daemon
|
|
# processname: oned
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: oned
|
|
# Required-Start: $local_fs $remote_fs
|
|
# Required-Stop: $local_fs $remote_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: start and stop oned
|
|
# Description: start and stop oned
|
|
### END INIT INFO
|
|
|
|
ONE_BIN=/usr/bin/one
|
|
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
RETVAL=0
|
|
|
|
check() {
|
|
# Check that we're a privileged user
|
|
[ `id -u` = 0 ] || exit 4
|
|
|
|
# Check if oned is executable
|
|
test -x $ONE_BIN || exit 5
|
|
}
|
|
|
|
start() {
|
|
|
|
check
|
|
|
|
ONE_AUTH_FILE=/var/lib/one/auth
|
|
if [ ! -f $ONE_AUTH_FILE ]; then
|
|
PASSWORD=$(cat /dev/urandom|tr -dc 'a-zA-Z0-9'|fold -w 10|head -n1)
|
|
su oneadmin -s /bin/sh -c "echo oneadmin:$PASSWORD > $ONE_AUTH_FILE"
|
|
fi
|
|
|
|
echo -n $"Starting OpenNebula daemon: "
|
|
|
|
|
|
daemon --user oneadmin ONE_AUTH=$ONE_AUTH_FILE $ONE_BIN start
|
|
RETVAL=$?
|
|
echo
|
|
return $RETVAL
|
|
}
|
|
|
|
stop() {
|
|
|
|
check
|
|
|
|
echo -n $"Stopping OpenNebula daemon: "
|
|
su oneadmin -s /bin/sh -c "$ONE_BIN stop"
|
|
RETVAL=$?
|
|
echo
|
|
return $RETVAL
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
status)
|
|
status oned
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|status|restart}"
|
|
RETVAL=2
|
|
esac
|
|
|
|
exit $RETVAL
|