#!/bin/sh
################################################################################
# Script name: predircheck_v1.2.beta.sh #
# Author: SoD #
# Contact: SoD- @ EFNet #
# Releasedate: 2001-07-24 #
# #
# This script is labeled as beta since I haven't tested it that much. #
# This script is executed by glftpd before a directory is created and then #
# checks for up to 3 things (depending on if you enable all checks or not): #
# * Checks for dupe in the dupelog (dirname, not files of course) #
# * Checks for what group the release origins from, banned or affil #
# * Checks for releaseyear (only works for the mp3 scene) #
# #
# Installation: -Put this file in some approperiate place, for example #
# /glftpd/bin/predircheck_v1.2.beta.sh #
# -Make it executable #
# (chmod 755 /glftpd/bin/predircheck_v1.2.beta.sh) #
# -Edit glftpd.conf and change the line with pre_dir_check to: #
# pre_dir_check /bin/predircheck_v1.2.beta.sh #
# -Edit this script to suit your needs #
# #
# Requirements: awk, cut, echo, expr, grep, tail, tr #
# #
# Limitations: -Can't handle dirnames with spaces in them. #
# #
# Changelog: v1.0 -> v1.1: The script can now deny uploads of a certain#
# groups releases (so affils dont get raced). #
# v1.1 -> v1.2.beta: Fixed a minor bug that RARELY would cause #
# the script to report a dupe when it wasn't. #
# Also made $AFFILS and $BANNED_GROUPS case #
# insensitive so that the output from the #
# script will look a bit nicer. Some speed #
# improvements were also made. #
# Changes in settings: $AFFILS and $BANNED_GROUPS can be changed to case #
# insensitive (not nescessary). #
################################################################################
# Put your affils here, case insensitive, separate with space.
AFFILS="SND SF RiSE KvEXXX"
# Put whatever groups from whatever scene you want banned here, case
# insensitive, separate with space.
BANNED_GROUPS="iMPG iDC KrbZ TMG cDiAMOND"
# What years do you want banned, all years up until and including this one will
# be denied by the dirscript if you invoke that function.
BANNED_YEARS="2000"
# Where is your dupelog located?
GL_DUPELOG="/ftp-data/logs/dupelog"
# Now setup your sections and what features to use in them in the case-switch at
# the bottom of the script. Not that userfriendly but who cares... Remember to
# set it so that CD1-, CD2-, sample- and requestdirs are excluded.
################################################################################
# This function makes shure banned groups releases don't get uploaded.
check_banned_groups () {
GROUP=`echo $1 | awk -F "-" '{print $NF}' | tr '[:upper:]' '[:lower:]'`
for BANNED_GROUP in $BANNED_GROUPS; do
if [ `echo $BANNED_GROUP | tr '[:upper:]' '[:lower:]'` = $GROUP ]; then
echo -e ""$BANNED_GROUP"'s releases are banned"
exit 2
fi
done
}
# This function makes shure that no dupes gets uploaded.
scan_dupelog () {
TMP=`grep -ix "...... $1" $GL_DUPELOG | tail -n1`
if [ "$TMP" ]; then
echo -e "$1 already exists in the dupelog, it was last created at"\
" `echo $TMP | awk '{print $1}'`"
exit 2
fi
}
# This function denies creation of too old mp3's.
check_banned_years () {
YEAR_FIELD=`expr \`echo $1 | awk -F "-" '{print NF}'\` - 1`
YEAR=`echo $1 | cut -d "-" -f$YEAR_FIELD | tr -d "()"`
if [ $YEAR -le $BANNED_YEARS ]; then
echo -e "This site only accepts releases newer than year $BANNED_YEARS"
exit 2
fi
}
# This function makes shure that no one races your affils.
check_affils () {
GROUP=`echo $1 | awk -F "-" '{print $NF}' | tr '[:upper:]' '[:lower:]'`
for AFFIL in $AFFILS; do
if [ `echo $AFFIL | tr '[:upper:]' '[:lower:]'` = $GROUP ]; then
echo -e ""$AFFIL"'s are affils here"
exit 2
fi
done
}
# Just put your paths here and call any (or none) of the above functions. Just
# look at the examples and I think you'll understand how it works. Remember to
# exit every case with "exit ;;".
case $PWD/$1 in
/site/mp3/????/*/* ) exit ;;
/site/mp3/????/* ) scan_dupelog $1
check_banned_groups $1
check_banned_years $1
check_affils $1
exit ;;
/site/vcd/*/* ) exit ;;
/site/vcd/* ) scan_dupelog $1
check_affils $1
exit ;;
/site/iso/*/* ) exit ;;
/site/iso/* ) scan_dupelog $1
check_banned_groups $1
exit ;;
/site/0day/????/* ) scan_dupelog $1
check_banned_groups $1
exit ;;
* ) exit ;;
esac