Репозитории ALT
S: | 7.0.10-alt2 |
5.1: | 4.0.12-alt0.M51.1 |
4.1: | 2.1.4-alt0.M41.5 |
4.0: | |
+backports: | 1.6.6-alt0.M40.2 |
Группа :: Эмуляторы
Пакет: virtualbox
Главная Изменения Спек Патчи Исходники Загрузить Gear Bugs and FR Repocop
#!/bin/sh
#
# 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;
# you can redistribute it and/or modify it under the terms of the GNU
# 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
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
LOCKFILE="/var/lock/subsys/vboxweb-service"
PIDFILE="/var/run/vboxweb-service"
RETVAL=0
# Source vboxwebsrv configuration.
VBOXWEB_USER=vboxwebsrv
SourceIfNotEmpty /etc/sysconfig/vboxweb-service
SourceIfNotEmpty /etc/vbox/vbox.cfg
binary=vboxwebsrv
vboxmanage=VBoxManage
vboxmanageaction() {
local action="$1"
local prop="$2"
local value="$3"
local name="${4-$prop}"
if [ -n "$value" ]; then
su - "$VBOXWEB_USER" -c "$vboxmanage $action \"$prop\" \"$value\""
if [ $? -ne 0 ]; then
failure "Error $? setting webservice $name to $value"
fi
fi
}
vboxdrvrunning() {
lsmod | grep -q "vboxdrv[^_-]"
}
start() {
if ! checkstatus >/dev/null; then
vboxdrvrunning || {
failure "VirtualBox kernel module not loaded!"
exit 0
}
PARAMS=""
[ -n "$VBOXWEB_HOST" ] && PARAMS="$PARAMS -H $VBOXWEB_HOST"
[ -n "$VBOXWEB_PORT" ] && PARAMS="$PARAMS -p $VBOXWEB_PORT"
[ -n "$VBOXWEB_SSL_KEYFILE" ] && PARAMS="$PARAMS -s -K $VBOXWEB_SSL_KEYFILE"
[ -n "$VBOXWEB_SSL_PASSWORDFILE" ] && PARAMS="$PARAMS -a $VBOXWEB_SSL_PASSWORDFILE"
[ -n "$VBOXWEB_SSL_CACERT" ] && PARAMS="$PARAMS -c $VBOXWEB_SSL_CACERT"
[ -n "$VBOXWEB_SSL_CAPATH" ] && PARAMS="$PARAMS -C $VBOXWEB_SSL_CAPATH"
[ -n "$VBOXWEB_SSL_DHFILE" ] && PARAMS="$PARAMS -D $VBOXWEB_SSL_DHFILE"
[ -n "$VBOXWEB_SSL_RANDFILE" ] && PARAMS="$PARAMS -r $VBOXWEB_SSL_RANDFILE"
[ -n "$VBOXWEB_TIMEOUT" ] && PARAMS="$PARAMS -t $VBOXWEB_TIMEOUT"
[ -n "$VBOXWEB_CHECK_INTERVAL" ] && PARAMS="$PARAMS -i $VBOXWEB_CHECK_INTERVAL"
[ -n "$VBOXWEB_THREADS" ] && PARAMS="$PARAMS -T $VBOXWEB_THREADS"
[ -n "$VBOXWEB_KEEPALIVE" ] && PARAMS="$PARAMS -k $VBOXWEB_KEEPALIVE"
[ -n "$VBOXWEB_AUTHENTICATION" ] && PARAMS="$PARAMS -A $VBOXWEB_AUTHENTICATION"
[ -n "$VBOXWEB_LOGFILE" ] && PARAMS="$PARAMS -F $VBOXWEB_LOGFILE"
[ -n "$VBOXWEB_ROTATE" ] && PARAMS="$PARAMS -R $VBOXWEB_ROTATE"
[ -n "$VBOXWEB_LOGSIZE" ] && PARAMS="$PARAMS -S $VBOXWEB_LOGSIZE"
[ -n "$VBOXWEB_LOGINTERVAL" ] && PARAMS="$PARAMS -I $VBOXWEB_LOGINTERVAL"
# set authentication method + password hash
vboxmanageaction "setproperty" "websrvauthlibrary" "$VBOXWEB_AUTH_LIBRARY" "authentication library"
vboxmanageaction "setextradata global" "VBoxAuthSimple/users/$VBOXWEB_USER" "$VBOXWEB_AUTH_PWHASH" "password hash"
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
start_daemon --displayname "VirtualBox Web Service" --user "$VBOXWEB_USER" --make-pidfile --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- $binary $PARAMS
RETVAL=$?
else
RETVAL=$?
failure "VirtualBox Web Service already running"
fi
return $RETVAL
}
stop() {
stop_daemon --displayname "VirtualBox Web Service" --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- /bin/su
RETVAL=$?
return $RETVAL
}
restart() {
stop && start
}
checkstatus() {
status --displayname "VirtualBox Web Service" --pidfile "$PIDFILE" -- /bin/su
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
checkstatus
;;
setup)
;;
cleanup)
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL