| 1 | #!/bin/sh
|
|---|
| 2 | # Start/stop the IPCop VM
|
|---|
| 3 | #
|
|---|
| 4 | ### BEGIN INIT INFO
|
|---|
| 5 | # Provides: vbox-ipcop
|
|---|
| 6 | # Required-Start: $syslog $time vboxdrv vboxnet
|
|---|
| 7 | # Required-Stop: $syslog $time
|
|---|
| 8 | # Default-Start: 2 3 4 5
|
|---|
| 9 | # Default-Stop: 0 1 6
|
|---|
| 10 | # Short-Description: IPCop in Virtualbox VM
|
|---|
| 11 | # Description: IPCop in Virtualbox VM
|
|---|
| 12 | ### END INIT INFO
|
|---|
| 13 |
|
|---|
| 14 | VBOXUSER=mauro
|
|---|
| 15 | VARRUNDIR=/var/run/VBoxHeadless
|
|---|
| 16 | PIDFILE=$VARRUNDIR/ipcop.pid
|
|---|
| 17 | VRDPADDR=192.168.0.5
|
|---|
| 18 | VRDPPORT=4000
|
|---|
| 19 |
|
|---|
| 20 | test -f /usr/bin/VBoxHeadless || exit 0
|
|---|
| 21 |
|
|---|
| 22 | . /lib/lsb/init-functions
|
|---|
| 23 |
|
|---|
| 24 | case "$1" in
|
|---|
| 25 | start) log_daemon_msg "Starting IPCop in Virtualbox" "VBoxHeadless"
|
|---|
| 26 | mkdir -p $VARRUNDIR
|
|---|
| 27 | chgrp vboxusers $VARRUNDIR
|
|---|
| 28 | chmod g+ws $VARRUNDIR
|
|---|
| 29 | USER=$VBOXUSER LOGNAME=$VBOXUSER start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --name VBoxHeadless --chuid $VBOXUSER --startas /usr/bin/VBoxHeadless -- -s IPCop -a $VRDPADDR -p $VRDPPORT
|
|---|
| 30 | /sbin/route add default gw 192.168.0.15
|
|---|
| 31 | log_end_msg $?
|
|---|
| 32 | ;;
|
|---|
| 33 | stop) log_daemon_msg "Stopping IPCop in Virtualbox" "VBoxHeadless"
|
|---|
| 34 | /sbin/route del default gw 192.168.0.15
|
|---|
| 35 | su -c '/usr/bin/VBoxManage controlvm IPCop keyboardputscancode 1d 38 53' $VBOXUSER
|
|---|
| 36 | sleep 30
|
|---|
| 37 | start-stop-daemon --stop --quiet --pidfile $PIDFILE --name VBoxHeadless
|
|---|
| 38 | rm -f $PIDFILE
|
|---|
| 39 | log_end_msg $?
|
|---|
| 40 | ;;
|
|---|
| 41 | restart)
|
|---|
| 42 | $0 stop
|
|---|
| 43 | $0 start
|
|---|
| 44 | ;;
|
|---|
| 45 | status)
|
|---|
| 46 | su -c '/usr/bin/VBoxManage showvminfo IPCop' $VBOXUSER | grep '^State:'
|
|---|
| 47 | ;;
|
|---|
| 48 | *) log_action_msg "Usage: /etc/init.d/vbox-ipcop {start|stop|restart|status}"
|
|---|
| 49 | exit 2
|
|---|
| 50 | ;;
|
|---|
| 51 | esac
|
|---|
| 52 | exit 0
|
|---|