#!/bin/sh #------------------------------------------------------------------------------ # __FLI4LVER__ # vbox.cgi - display vbox status and calls # based on the previous main_Vbox.cgi, created by tg/cp # # Creation: 2003-06-12 aw # Last Update: $Id$ # #------------------------------------------------------------------------------ # get main helper functions #set_debug=yes . /srv/www/include/cgi-helper case $FORM_action in "start*"|"stop*") sec="start" ;; del*) sec="delete" ;; *) sec="view" ;; esac check_rights "vbox" "$sec" SPOOLPREFX=/var/spool/vbox # header [refresh] # # Builds the http and html page header and optionally # inserts a meta refresh tag to automatically reload # a given URL header () { RTIME=$1 show_html_header "$_MP_vbox" "refresh=$RTIME; url=$myname" } # start [num] # # Starts the specified vbox start () { ttyi_n=$1 set -- `eval 'echo $VBOX_TTYI_'$ttyi_n` user=$2 case x$REMOTE_USER in x$user|x$VBOX_ADMIN_USERNAME|x) rm -f /var/run/vbox_stop_$ttyi_n ;; *) return 1 ;; esac } # stop [num] # # Stops the specified vbox stop () { ttyi_n=$1 set -- `eval 'echo $VBOX_TTYI_'$ttyi_n` user=$2 case x$REMOTE_USER in x$user|x$VBOX_ADMIN_USERNAME|x) if [ -f /var/run/vboxgetty-ttyI$ttyi_n.pid ] then echo >/var/run/vbox_stop_$ttyi_n kill `cat /var/run/vboxgetty-ttyI$ttyi_n.pid` rm -f /var/run/vboxgetty-ttyI$ttyi_n.pid fi ;; *) return 1 ;; esac } ls2date () { read zeile YEAR=`echo $zeile | cut -d " " -f 5 -` DAY=`echo $zeile | cut -d " " -f 3 -` if [ $DAY -lt 10 ] then DAY=`echo 0$DAY` fi TIME=`echo $zeile | cut -d " " -f 4 -` MONTHSUBST='s/Jan/01/g;s/Feb/02/g;s/Mar/03/g;s/Apr/04/g;s/May/05/g;s/Jun/06/g;s/Jul/07/g;s/Aug/08/g;s/Sep/09/g;s/Oct/10/g;s/Nov/11/g;s/Dec/12/g' MONTH=`echo $zeile | cut -d " " -f 2 - | sed -e $MONTHSUBST` echo $YEAR-$MONTH-$DAY $TIME } # Check, if vbox is running if [ -f /etc/vbox/vboxgetty.conf ] then #get variables . /var/run/vbox.conf RTIME=9999 case $FORM_action in "") header echo "
$_VBOX_cmd_startall | $_VBOX_cmd_stopall
" i='0' showbox= for i in `seq 1 $VBOX_USER_N` do set `eval echo '$VBOX_USER_'$i'_USERNAME'` USRNAME=$1 [ "$REMOTE_USER" = "$USRNAME" -o "$REMOTE_USER" = "$VBOX_ADMIN_USERNAME" -o -z "$REMOTE_USER" ] || continue SPOOLDIR=$SPOOLPREFX/$USRNAME/incoming showbox=yes show_tab_header "$USRNAME" no echo ""
# Show list of users incoming messages
echo '
| "
# Show status of users MSNs
echo '
|
$MSGINFO
$MSGINFO
$_VBOX_msg_confirmdelete
" echo "$_VBOX_cmd_yes | $_VBOX_cmd_no
" show_tab_footer show_html_footer else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; delc) eval USER='$VBOX_USER_'$FORM_nr'_USERNAME' MSG=$SPOOLPREFX/$USER/incoming/$FORM_msg if [ -f $MSG ] then header 2 rm $MSG show_info "" "$_VBOX_msg_deleted" echo "$_MN_bck" show_html_footer else header 3 show_error "" "$_VBOX_msg_nomessage" show_html_footer fi ;; start) start $FORM_nr case $? in 1) header 3 show_error "" "$_VBOX_msg_notallowed" show_html_footer ;; *) sleep 3 echo "Location: $myname" echo ;; esac ;; stop) stop $FORM_nr case $? in 1) header 2 show_error "" "$_VBOX_msg_notallowed" show_html_footer ;; *) sleep 3 echo "Location: $myname" echo ;; esac ;; "startall" ) for i in `seq $VBOX_TTYI_MIN $VBOX_TTYI_N` do start "$i" done sleep 2 header 3 show_info "" "$_VBOX_msg_allstarted" echo "
$_MN_bck" show_html_footer ;; "stopall" ) for i in `seq $VBOX_TTYI_MIN $VBOX_TTYI_N` do stop "$i" done sleep 2 header 3 show_info "" "$_VBOX_msg_allstopped" echo "
$_MN_bck" show_html_footer ;; *) echo "Location: $myname" echo ;; esac else header show_error "" "
$_VBOX_msg_notavailable`grep -q VBOX /bootmsg.txt && echo '
' ; \ grep VBOX /bootmsg.txt ; echo ''`" show_html_footer fi