#! /bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/vbox-rss-control - control rss access rights # # Copyright (c) 2002-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2007-04-15 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-rss-access-control-trace-$$.test #set -x #---------------------------------------------------------------------------------- # check if apache2 has been enabled #---------------------------------------------------------------------------------- check_installed_apache2 () { retval=1 if [ -f ${apache2file} ] then # apache2 installed . ${apache2file} if [ "${START_APACHE2}" = "yes" ] then # mail activated if [ "${1}" != "-quiet" ] then mecho "apache2 has been enabled ..." fi retval=0 else # apache2 deactivated if [ "${1}" != "-quiet" ] then mecho --warn "apache2 has been disabled ..." fi fi fi return ${retval} } #---------------------------------------------------------------------------------- # rss files have been updated # input: $1 - full rss path # return: 0 - content has been modified # 1 - nothing has been modified #---------------------------------------------------------------------------------- changed_rss_files () { usr_rsspath=${1} retval=1 usr_rssdir=`echo "${usr_rsspath}" | sed 's#.*\/##'` last_checked_file=${vbox_spooldir}/vbox-rss-${usr_rssdir}-last-processed if [ -d ${usr_rsspath} ] then # update lease file marker if [ ! -f ${last_checked_file} -o \( ${usr_rsspath} -nt ${last_checked_file} \) ] then > ${last_checked_file} retval=0 fi fi return ${retval} } #================================================================================== # main #================================================================================== ### set path names ### vbox_spooldir=/var/spool/vbox ### set file names ### apache2file=/etc/config.d/apache2 interval=20 if check_installed_apache2 -quiet then # installed - read configuration APACHE2_INSTALLED='yes' # start control process while [ 1 ] do for DNAME in `find ${APACHE2_DOCUMENT_ROOT}/vbox-rss -type d` do if [ "${DNAME}" != "${APACHE2_DOCUMENT_ROOT}/vbox-rss" ] then if changed_rss_files ${DNAME} then # change file ownership chmod 640 ${DNAME}/rss.xml chgrp nogroup ${DNAME}/rss.xml # create symbolic link ln -sf ${DNAME}/rss.xml ${DNAME}/index.html chmod 640 ${DNAME}/*.mp3 chgrp nogroup ${DNAME}/*.mp3 fi fi done sleep ${interval} done & else # not installed mecho "apache2 package not installed!" fi #================================================================================== # end #==================================================================================