#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/vbox-reset-rssfiles - reset vbox rss files # # Copyright (c) 2002-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2007-03-17 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/vboxlog-trace-$$.test #set -x ### set file names ### vboxfile=/etc/config.d/vbox vbox_spooldir=/var/spool/vbox ### load configuration ### . ${vboxfile} log_dir=/var/log log_file=vboxgetty ### view log file ### clrhome mecho --info "Reset RSS files" mecho if [ "${START_VBOX}" = "yes" -a ${VBOX_USER_N} -gt 0 ] then techo --begin 1 3 2 10 2 30 idx=1 while [ ${idx} -le ${VBOX_USER_N} ] do rss_exist=0 eval name='$VBOX_USER_'${idx}'_NAME' VBOX_RSSDIR='' if [ -f ${vbox_spooldir}/${name}/write_rss ] then # possible rss usage, read mail_att file . ${vbox_spooldir}/${name}/write_rss if [ -n "${VBOX_RSSDIR}" ] then # parameter exists if [ -d ${VBOX_RSSDIR} ] then # rss directory exists ls ${VBOX_RSSDIR}/*.mp3 >/dev/null 2>/dev/null if [ $? -eq 0 ] then # files found, delete them rss_exist=1 fi fi fi fi if [ ${rss_exist} -eq 1 ] then techo --row "" ${idx} - "${name}" - "rss files found" else techo --row "" ${idx} - "${name}" - "" fi idx=`expr ${idx} + 1` done techo techo --end idx=`expr ${idx} - 1` endflag=0 until [ ${endflag} -eq 1 ] do mecho -n "Please select vbox number (1-${idx}), (q)uit: " read nbr case "${nbr}" in [qQ] ) endflag=1 exit 1 ;; [0-9] | [1-9][0-5] ) ### number entered ### if [ ${nbr} -ge 1 -a ${nbr} -le ${idx} ] then eval name='$VBOX_USER_'${nbr}'_NAME' VBOX_RSSDIR='' if [ -f ${vbox_spooldir}/${name}/write_rss ] then # possible rss usage, read write_rss file . ${vbox_spooldir}/${name}/write_rss if [ -n "${VBOX_RSSDIR}" ] then # parameter exists if [ -d ${VBOX_RSSDIR} ] then # rss directory exists ls ${VBOX_RSSDIR}/*.mp3 >/dev/null 2>/dev/null if [ $? -eq 0 ] then # files found, delete them /var/install/bin/ask "Remove rss files" 'n' > /tmp/ask.$$ rc=$? yesno=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then rm $tmpfile exit 1 fi if [ "$yesno" = "yes" ] then # delete files rm -f ${VBOX_RSSDIR}/2*.mp3 rm -f ${VBOX_RSSDIR}/2*.txt # update rss file cat ${VBOX_RSSDIR}/header.txt ${VBOX_RSSDIR}/footer.txt > ${VBOX_RSSDIR}/rss.xml chmod 640 ${VBOX_RSSDIR}/rss.xml chown ${name} ${VBOX_RSSDIR}/rss.xml chgrp nogroup ${VBOX_RSSDIR}/rss.xml mecho --info "rss files deleted!" fi endflag=1 else mecho --warn "no rss files to delete, try again!" fi else mecho --warn "no rss directory exists, try again!" fi else mecho --warn "no rss files to delete, try again!" fi else mecho --warn "no rss files to delete, try again!" fi else mecho --warn "number not in range, try again!" fi ;; * ) ;; esac done fi anykey