vboxweb-service.sh.in revision 9cc8595a52cf33777684fe153fdcdff6182c93dc
#
# VirtualBox web service API daemon init script.
#
# Copyright (C) 2006-2012 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# chkconfig: 35 35 65
# description: VirtualBox web service API
#
### BEGIN INIT INFO
# Provides: vboxweb-service
# Required-Start: vboxdrv
# Required-Stop: vboxdrv
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: VirtualBox web service API
### END INIT INFO
if [ -n "$INSTALL_DIR" ]; then
binary="$INSTALL_DIR/vboxwebsrv"
vboxmanage="$INSTALL_DIR/VBoxManage"
else
vboxmanage="/usr/lib/%PACKAGE%/VBoxManage"
fi
# silently exit if the package was uninstalled but not purged,
# applies to Debian packages only
if [ -f /etc/redhat-release ]; then
elif [ -f /etc/SuSE-release ]; then
elif [ -f /etc/debian_version ]; then
elif [ -f /etc/gentoo-release ]; then
elif [ -f /etc/arch-release ]; then
elif [ -f /etc/slackware-version ]; then
elif [ -f /etc/lfs-release ]; then
else
fi
fi
if [ -z "$NOLSB" ]; then
echo ""
log_failure_msg "$1"
}
log_success_msg " done."
}
log_daemon_msg "$@"
}
fi
if [ "$system" = "redhat" ]; then
if [ -n "$NOLSB" ]; then
usr="$1"
shift
}
echo
}
echo
}
echo -n "$1"
}
fi
fi
if [ "$system" = "suse" ]; then
usr="$1"
shift
}
if [ -n "$NOLSB" ]; then
rc_status -v
}
rc_status -v
}
echo -n "$1"
}
fi
fi
if [ "$system" = "debian" ]; then
usr="$1"
shift
bin="$1"
shift
}
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
fi
if [ "$system" = "gentoo" ]; then
. /sbin/functions.sh
usr="$1"
shift
bin="$1"
shift
}
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
shift
fi
fi
fi
if [ "$system" = "arch" ]; then
usr="$1"
shift
test $? -eq 0 && add_daemon rc.`basename $2`
}
killall $@
}
if [ -n "$NOLSB" ]; then
}
}
stat_busy "$1"
}
fi
fi
if [ "$system" = "slackware" ]; then
killall $1
}
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
usr="$1"
shift
}
fi
if [ "$system" = "lfs" ]; then
if [ -n "$NOLSB" ]; then
}
}
echo $1
}
fi
usr="$1"
shift
}
statusproc $1
}
fi
if [ "$system" = "other" ]; then
if [ -n "$NOLSB" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n "$1"
}
fi
fi
}
if [ -n "$2" ]; then
fail_msg "VBOXWEB_USER must not contain multiple users!"
exit 1
fi
}
if ! test -f $PIDFILE; then
vboxdrvrunning || {
fail_msg "VirtualBox kernel module not loaded!"
exit 0
}
PARAMS="--background"
# set authentication method + password hash
if [ $? -ne 0 ]; then
fail_msg "Error $? setting webservice authentication library to $VBOXWEB_AUTH_LIBRARY"
fi
fi
su - "$VBOXWEB_USER" -c "$vboxmanage setextradata global \"VBoxAuthSimple/users/$VBOXWEB_USER\" \"$VBOXWEB_AUTH_PWHASH\""
if [ $? -ne 0 ]; then
fail_msg "Error $? setting webservice password hash"
fi
fi
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
start_daemon $VBOXWEB_USER $binary $PARAMS > /dev/null 2>&1
# ugly: wait until the final process has forked
sleep .1
RETVAL=0
else
RETVAL=1
fi
fi
return $RETVAL
}
stop() {
if test -f $PIDFILE; then
RETVAL=$?
else
fi
fi
return $RETVAL
}
stop && start
}
echo -n "Checking for VBox Web Service"
if [ -f $PIDFILE ]; then
echo " ...running"
else
echo " ...not running"
fi
}
case "$1" in
;;
stop)
stop
;;
;;
;;
;;
;;
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL