#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/vbox-toggle-callback - toggle callback status # # Copyright (c) 2002-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2007-12-30 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # read eislib . /var/install/include/eislib #exec 2> /tmp/vbox-toggle-callback-trace-$$.test #set -x ### set path names ### vbox_spooldir=/var/spool/vbox ### set file names ### pgmname=`basename $0` vboxfile=/etc/config.d/vbox user=`whoami` if [ "${user}" = "root" -o "${user}" = "eis" ] then ### load configuration ### . ${vboxfile} endflag=0 if [ ${VBOX_USER_N} -gt 0 ] then until [ ${endflag} -eq 1 ] do clrhome mecho --info "Toggle VBox callback status" mecho techo --begin 1 2 2 14 8 14 techo --row "" --info "Nr" "" --info "VBox" --info "Active" --info "Callback" idx=1 count=0 while [ ${idx} -le ${VBOX_USER_N} ] do mecho_active='-std' mecho_callback='-std' eval vbox_active='$VBOX_USER_'${idx}'_ACTIVE' if [ "${vbox_active}" = "yes" ] then eval vbox_name='$VBOX_USER_'${idx}'_NAME' eval vbox_callback_status='$VBOX_USER_'${idx}'_CALL_ENABLED' if [ "${vbox_callback_status}" = "yes" ] then vbox_callback_file=${vbox_spooldir}/${vbox_name}/vbox-nocallback if [ ! -f ${vbox_callback_file} ] then mecho_callback='-std' vbox_callback='enabled' else mecho_callback='-warn' vbox_callback='disabled' fi else mecho_active='-std' vbox_callback='not activated' fi fi techo --row "" ${idx} ":" ${vbox_name} ${mecho_active} "${vbox_active}" ${mecho_callback} "${vbox_callback}" idx=`expr ${idx} + 1` done mecho /var/install/bin/ask "Please enter VBox number (1-${VBOX_USER_N}) or (q)uit:" '' '+' > /tmp/ask.$$ rc=$? nbr=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "${nbr}" in [qQ] ) endflag=1 exit 1 ;; [0-9] | [1-9][0-9] ) ### number entered ### if [ ${nbr} -ge 1 -a ${nbr} -le ${VBOX_USER_N} ] then eval active='$VBOX_USER_'${nbr}'_ACTIVE' if [ "${active}" = "yes" ] then eval name='$VBOX_USER_'${nbr}'_NAME' eval callback_status='$VBOX_USER_'${nbr}'_CALL_ENABLED' if [ "${callback_status}" = "yes" ] then callback_file=${vbox_spooldir}/${name}/vbox-nocallback if [ ! -f ${callback_file} ] then echo "# file generated by ${pgmname} (${name}) on `date`" > ${callback_file} else rm -f ${callback_file} fi else mecho --warn "Function not available for this VBox because parameter" mecho --warn "VBOX_USER_${nbr}_CALL_ENABLED='no' has been set!" fi else mecho --warn "VBox not activated!" fi else mecho --warn "Number not in range, try again!" fi ;; * ) mecho --warn "Value not in range, try again!" ;; esac anykey techo --end done else mecho --warn "No active VBox(es) found, at least one needs to be enabled!" fi else mecho --warn "You must be user 'root' or user 'eis' to use this function!" anykey fi exit 0