#!/bin/sh # This script will output the necessary INSERT commands # for the sqlippool module in freeradius # 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. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # Copyright (C) 2007 The FreeRADIUS Project http://www.freeradius.org # # 7-05-07 - Author: Roy Walker <roy_walker@hotmail.com> # Enter the pool-name attribute POOL_NAME=your_pool_name # Set the first 2 octets of the IP network NETWORK=1.1 # Set the starting point of the third octet START_RANGE=1 # Set the ending point of the third octet END_RANGE=254 # Set the starting point of the fourth octet MIN_IP=1 # Set the ending point of the fourth octet MAX_IP=254 ######################################################################## # ######################################################################## # # Make sure that END_RANGE is higher than START_RANGE if [ $START_RANGE -gt $END_RANGE ] ; then echo "ERROR: Then ending range must be higher than the starting range." exit 1 fi SUBNET=$START_RANGE IP=$MIN_IP count=0 while [ true ]; do if [ $IP -gt $MAX_IP ] ; then if [ $SUBNET -eq $END_RANGE ] ; then exit 0; else SUBNET=$(( $SUBNET + 1 )) IP=$MIN_IP fi fi echo "INSERT INTO radippool (pool_name, FramedIPAddress) VALUES ('$POOL_NAME', '$NETWORK.$SUBNET.$IP');" IP=$(( $IP + 1 )) done; exit 0