codekasten/web-splash/web-splash.sh

57 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
#
# this skript is GPL software (http://www.fsf.org/licensing/licenses/gpl.html)
# suggestions and questions to: devel@sumpfralle.de
# homepage: https://systemausfall.org/toolforge/web-splash
#
set -ue
. /etc/web-splash.conf
. "$SPLASH_LIB/web-splash-functions.inc"
# check for DEBUG mode
[ "$SPLASH_DEBUG" -eq 1 ] && set -x
ACTION="--help"
[ $# -gt 0 ] && ACTION="$1"
case "$ACTION" in
start|restart )
remove_old
init_chains
;;
stop )
remove_old
;;
register )
[ $# -gt 2 ] && echo "[WEB_SPLASH] too many parameters: only one IP address is allowed" && exit 1
[ $# -lt 2 ] && echo "[WEB_SPLASH] you have to specify an IP address" && exit 2
register_IP "$2"
;;
unregister )
[ $# -gt 2 ] && echo "[WEB_SPLASH] too many parameters: only one IP address is allowed" && exit 1
[ $# -lt 2 ] && echo "[WEB_SPLASH] you have to specify an IP address" && exit 2
unregister_IP "$2"
;;
update )
update_IP_list
;;
traffic )
if [ $# -eq 1 ]
then get_IP_list | while read IP
do echo "$IP `get_IP_traffic \"$IP\"`"
done
else IP="$2"
get_IP_traffic "$IP"
fi
;;
* )
echo "Syntax: $0 {start|stop|restart|register|unregister|update|traffic}"
echo
;;
esac