# Purpose:For Newbees
# Easy Installations and configurations of FreeRADIUS-0.81 & OpenLDAP-2.0.27 for 
Wireless Networks 
# MAC Address & User Authentication
# It should also work for Wired Networks...
#


# RUN:
# $sh wireless_authenticate.0.0.1.sh
# TESTED PLATFORM:
# *Red Hat 7.1
# *Red Hat 8.0
# TODO:
# * EAP-MD5 Script  
# * EAP-TLS Script
# * Currently, This script depends on the current config files of FreeRADIUS and 
OpenLDAP
#   It should be version independent.
# * Needs some script improvements
# * Apache Interface -Web Authentication- should be included 
# * New languages should be added


Script:
#!/bin/sh
# Purpose:For Newbees
# Easy Installations and configurations of FreeRADIUS-0.81 &
OpenLDAP-2.0.27 for Wireless Networks 
# MAC Address & User Authentication
# It should also work for Wired Networks...
#
#(c) 10 January 2003 Tamer Demir  <[EMAIL PROTECTED]>
# http://www.netlab.boun.edu.tr/~tamer/
#
-------------------------------------------------------------------------
#    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA
# -----------------------------------------------------------------------
# RUN:
# $sh wireless_authenticate.0.0.1.sh
# TESTED PLATFORM:
# *Red Hat 7.1
# *Red Hat 8.0
# TODO:
# * EAP-MD5 Script  
# * EAP-TLS Script
# * Currently, This script depends on the current config files of
FreeRADIUS and OpenLDAP
#   It should be version independent.
# * Needs some script improvements
# * Apache Interface -Web Authentication- should be included 
# * New languages should be added
clear
echo Suggestion:
echo First read the source code of this program make your changes if you
desire then run!!
echo Tavsiye:
echo nce kaynak kodu okuyun gerekiyorsa baz deiiklikleri yaptktan sonra
altrn!!
echo
echo Choose your language during installation \"MAC Address \& User
Authentication with RADIUS\&LDAP in Wireless Networks\"
echo \"Kablosuz Alarda RADIUS ve LDAP ile \"MAC Address \& User
Authentication Uygulamas \" kurulumu icin dilinizi seciniz
echo "Trke = t"
echo "english = e"
read dil
clear
# Trke
if test $dil = "t"
then
 echo
 echo "LDAP kurmak istiyormusun?"
 echo "Evet = e"
 echo "Hayir = h"
 read LDAP
 if test $LDAP = "e"
 then
   echo imdi OpenLDAP-2.0.27 dosyasn indiriyorum \(www.openldap.org\)
   echo Kaynan olduu sunucuda bir sorun olursa www.openldap.org dan bu
klasre indirebilirsiniz 
   # wget
ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.0.27.tgz
   # wget
http://www.cmpe.boun.edu.tr/~demirt/sil-source/openldap-2.0.27.tgz
   # wget http://www.netlab.boun.edu.tr/~tamer/LDAP/openldap-2.0.27.tgz
   rm -r openldap-2.0.27/
   tar zxvf openldap-2.0.27.tgz
   cd openldap-2.0.27/
        (
         ./configure --prefix=/usr/local/openldap-2.0.27/
--exec-prefix=/usr/local/openldap-2.0.27/
         make depend
         make
         make test 
         make install
        )
   cd ..
   rm -r openldap-2.0.27
 fi
 echo "imdi FreeRADIUS u indiriyorum"
#RADIUS
# wget ftp://ftp.freeradius.org/pub/radius/freeradius-0.8.1.tar.gz
# wget
http://www.cmpe.boun.edu.tr/~demirt/sil-source/freeradius-0.8.1.tar.gz
# wget http://www.netlab.boun.edu.tr/~tamer/RADIUS/freeradius-0.8.1.tar.gz
 rm -r freeradius-0.8.1
 tar zxvf freeradius-0.8.1.tar.gz
 cd freeradius-0.8.1
        (
        ./configure --prefix=/usr/local/freeradius-0.8.1-LDAP/
--with-radacctdir=/usr/local/freeradius-0.8.1-LDAP/ --with-ldap
--with-openldap=/usr/local/openldap --without-rlm_x99_token
        make
        make install
        )
 cd .. 
clear
sleep 2
echo "Kablosuz kullancnn balanaca Access Point sayisini yaziniz, NAS"
echo "Bu sayi RADIUS serverini kullanma izni olacak AP lerin sayisidir"
export COUNT=1
read COUNT
while [ "$COUNT" != "0" ]
do
  echo "Kablosuz kullancnn balanaca Access Point in IP numarasn u ekilde
girin, rnek: 192.168.91.102"
  read A 
  echo "$A              secret
">>/usr/local/freeradius-0.8.1-LDAP/etc/raddb/clients
  export COUNT=$[$COUNT - 1]
  echo $COUNT adet AP kald geriye...
  echo
  echo
done
sleep 2
echo
echo "AP de RADIUS ayarlarnda RADIUS servernn IP sini girmeyi ve sifresine
secret yazmay unutmayn"
echo "Dier AP leri clients dosyasna ekleyebilirsiniz, ama clients dosyas
clients.conf dosyas tarafndan eskitilmistir"
#LDAP l kurulum....
if test $LDAP = "e"
then
  cp freeradius-0.8.1/doc/RADIUS-LDAPv3.schema
/usr/local/openldap-2.0.27/etc/openldap/schema/
  sed -e '7s/.*/include
\/usr\/local\/openldap-2.0.27\/etc\/openldap\/schema\/RADIUS-LDAPv3.schema/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '47s/.*/suffix          "dc=tamerdemir,dc=com"/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '49s/.*/rootdn          "cn=Manager,dc=tamerdemir,dc=com"/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '664s/.*/                server = "127.0.0.1"/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '667s/.*/                basedn = "dc=tamerdemir,dc=com"/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '668s/uid/cn/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '681s/access_attr/#access_attr/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1182s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1183s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1184s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial
  echo
  echo "ilk kurum users dosyasi users.initial olarak degistirilmistir
ileride bakmaniz gerekirse diye..."
  sleep 2
  echo "DEFAULT        Auth-Type := LDAP" >
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "                Fall-Through = 1" >>
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "dn: dc=tamerdemir,dc=com" > tamerdemir-MAC.ldif
  echo "objectClass: dcObject" >> tamerdemir-MAC.ldif
  echo "dc: tamerdemir" >>tamerdemir-MAC.ldif
  echo "" >>tamerdemir-MAC.ldif
  echo
  echo "Simdi rnek Kullanici MAC Adresi eklenmesi iin bilgi veriyorum"
  echo
  echo "Orinoco/Avaya/Lucent ve FreeRADIUS:"
  echo "MAC adresleri 111111-222222 eklinde olmal, ifre nemli deil."
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC adresleri 1111122222 eklinde olmal, ifre MAC adresiyle ayn
olmal"
  echo
  echo "Cisco:"
  echo "Cisco Aironet MAC adres tanmlanmas authentication yapmiyor,
kullanc ismine gre yapyor"
  sleep 2
  echo
  echo "imdi veritabanna ka adet kullanc veya MAC adresi ekleyeceinizi
yaznz"
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "imdi MAC adreslerini veya kullanc ismini yazn"
    echo "rnek:00022d-034186 veya rnek2:tamer"
    read MAC
    echo "dn: cn=$MAC,dc=tamerdemir,dc=com" >>tamerdemir-MAC.ldif
    echo "objectclass: top" >>tamerdemir-MAC.ldif
    echo "objectclass: person" >>tamerdemir-MAC.ldif
    echo "objectclass: radiusprofile" >>tamerdemir-MAC.ldif
    echo "cn: $MAC" >>tamerdemir-MAC.ldif
    echo "sn: Avaya" >>tamerdemir-MAC.ldif
    echo "Yukardaki aklamalara gre kullanc ifresini yazn"
    read SIFRE
   
    echo "userpassword: $SIFRE" >>tamerdemir-MAC.ldif
    echo "radiusFramedIPAddress: 255.255.255.254" >>tamerdemir-MAC.ldif
    echo "radiusFramedMTU: 1024" >>tamerdemir-MAC.ldif
    echo "" >>tamerdemir-MAC.ldif
    export COUNT=$[$COUNT - 1]
    echo $COUNT adet AP kald geriye...
    echo
    echo
  done
  
  /usr/local/openldap-2.0.27/libexec/slapd
  /usr/local/openldap-2.0.27/bin/ldapadd -f tamerdemir-MAC.ldif -xv -D
"cn=Manager,dc=tamerdemir,dc=com" -w secret
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS ve LDAP bilisayarin acildiginda calismasi icin
/etc/rc.local  dosyasina yazildi"
  echo "/usr/local/openldap-2.0.27/libexec/slapd" >>/etc/rc.local
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Simdi 00022d-034186 MAC adresini Test edecegiz..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret
localhost 0 testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "Eger Access-Accept yazisini gorduyseniz kurulum basariyla
tamamlanmistir"
  sleep 3
#LDAP sz kurulum...
else
  touch Kullanicilar.txt
  echo
  echo "Orinoco/Avaya/Lucent ve FreeRADIUS:"
  echo "MAC adresleri 111111-222222 eklinde olmal, ifre nemli deil."
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC adresleri 1111122222 eklinde olmal, ifre MAC adresiyle ayn
olmal"
  echo
  echo "Cisco:"
  echo "Cisco Aironet MAC adres tanmlanmas authentication yapmiyor,
kullanc ismine gre yapyor"
  echo
  sleep 2
  echo
  echo "imdi veritabanna ka adet kullanc veya MAC adresi ekleyeceinizi
yaznz"
  echo
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "imdi MAC adreslerini veya kullanc ismini yazn"
    echo "rnek:00022d-034186 veya rnek2:tamer"
    read MAC
    
    echo
    echo "ifresini yazn:"
    read SIFRE
    echo "$MAC  Auth-Type := Local, User-Password ==
\"$SIFRE\" " >>Kullanicilar.txt
    echo "" >>Kullanicilar.txt
    export COUNT=$[$COUNT - 1]
    echo $COUNT adet kullanc kald geriye...
    echo
    echo
  done
  head -74  /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users > tmp
  echo "" >>tmp
  cat Kullanicilar.txt >>tmp
  tail -140 /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users >>tmp
  echo "" >>tmp
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial  
  rm /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  cp tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS bilisayarin acildiginda calismasi icin /etc/rc.local
dosyasina yazildi"
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Simdi 00022d-034186 MAC adresini Test edecegiz..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret
localhost 0 testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "Eger Access-Accept yazisini gorduyseniz kurulum basariyla
tamamlanmistir"
  sleep 3
  
fi  
  
echo 
echo
echo 
echo
echo "Kurulum tamamlanmistir"
echo "                      Tamer Demir"
echo "                      [EMAIL PROTECTED]"
echo "                      http://www.tamerdemir.com";
echo "Her trl gelitirme iin bana e-posta gnderebilirsiniz"
#English..........................................
else
 echo
 echo "Do you want to setup LDAP?"
 echo "yEs = e"
 echo "noH = h"
 read LDAP
 if test $LDAP = "e"
 then
   echo Now I am downloading OpenLDAP-2.0.27 \(www.openldap.org\)
   # wget
ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.0.27.tgz
   # wget
http://www.cmpe.boun.edu.tr/~demirt/sil-source/openldap-2.0.27.tgz
   # wget http://www.netlab.boun.edu.tr/~tamer/LDAP/openldap-2.0.27.tgz
   rm -r openldap-2.0.27/
   tar zxvf openldap-2.0.27.tgz
   cd openldap-2.0.27/
        (
         ./configure --prefix=/usr/local/openldap-2.0.27/
--exec-prefix=/usr/local/openldap-2.0.27/
         make depend
         make
         make test
         make install
        )
   cd ..
   rm -r openldap-2.0.27
 fi
#RADIUS
 echo "Now i am downloading FreeRADIUS"
# wget ftp://ftp.freeradius.org/pub/radius/freeradius-0.8.1.tar.gz
# wget
http://www.cmpe.boun.edu.tr/~demirt/sil-source/freeradius-0.8.1.tar.gz
# wget http://www.netlab.boun.edu.tr/~tamer/RADIUS/freeradius-0.8.1.tar.gz
 rm -r freeradius-0.8.1
 tar zxvf freeradius-0.8.1.tar.gz
 cd freeradius-0.8.1
        (
        ./configure --prefix=/usr/local/freeradius-0.8.1-LDAP/
--with-radacctdir=/usr/local/freeradius-0.8.1-LDAP/ --with-ldap
--with-openldap=/usr/local/openldap --without-rlm_x99_token
        make
        make install
        )
 cd .. 
sleep 2
clear
echo "Enter the Number of Access Points, NASes"
echo "This number is the allowed number of AP that can use RADIUS"
export COUNT=1
read COUNT
while [ "$COUNT" != "0" ]
do
  echo "Enter the IP address of the Access Points, Eg: 192.168.91.102"
  read A
  echo "$A              secret
">>/usr/local/freeradius-0.8.1-LDAP/etc/raddb/clients
  export COUNT=$[$COUNT - 1]
  echo $COUNT number of AP left...
  echo
  echo
done
sleep 2
echo
echo "Write the IP address of the RADIUS server into the AP, and write
secret as the password"
echo "In order to add other AP, you can use clients file, But clients file
is depreciated by the clients.conf file"
#with LDAP ....
if test $LDAP = "e"
then
  cp freeradius-0.8.1/doc/RADIUS-LDAPv3.schema
/usr/local/openldap-2.0.27/etc/openldap/schema/
  sed -e '7s/.*/include
\/usr\/local\/openldap-2.0.27\/etc\/openldap\/schema\/RADIUS-LDAPv3.schema/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '47s/.*/suffix          "dc=tamerdemir,dc=com"/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '49s/.*/rootdn          "cn=Manager,dc=tamerdemir,dc=com"/'
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '664s/.*/                server = "127.0.0.1"/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '667s/.*/                basedn = "dc=tamerdemir,dc=com"/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '668s/uid/cn/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '681s/access_attr/#access_attr/'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1182s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1183s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1184s/#/ /'
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial
  echo
  echo "users file is changed to users.initial for further references..."
  sleep 2
  echo "DEFAULT        Auth-Type := LDAP" >
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "                Fall-Through = 1" >>
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "dn: dc=tamerdemir,dc=com" > tamerdemir-MAC.ldif
  echo "objectClass: dcObject" >> tamerdemir-MAC.ldif
  echo "dc: tamerdemir" >>tamerdemir-MAC.ldif
  echo "" >>tamerdemir-MAC.ldif
  clear
  echo "Now I am giving some information about MAC addresses"
  echo
  echo "Orinoco/Avaya/Lucent with FreeRADIUS:"
  echo "MAC addressses  are in this format 111111-222222, password is not
important"
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC addressses  are in this format 1111122222, password is the
same as MAC addresses"
  echo
  echo "Cisco:"
  echo "Cisco Aironet does not do MAC address authentication, instead it
does user authentication"
  echo
  sleep 2
  echo "Now, Enter how many number of MAC addresses or users are we going
to add..."
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "Now enter MAC addresses or user names according to the above
information..."
    echo "Eg:00022d-034186 or Eg2:tamer"
    read MAC
    echo "dn: cn=$MAC,dc=tamerdemir,dc=com" >>tamerdemir-MAC.ldif
    echo "objectclass: top" >>tamerdemir-MAC.ldif
    echo "objectclass: person" >>tamerdemir-MAC.ldif
    echo "objectclass: radiusprofile" >>tamerdemir-MAC.ldif
    echo "cn: $MAC" >>tamerdemir-MAC.ldif
    echo "sn: Avaya" >>tamerdemir-MAC.ldif
    echo "According to the above information enter the password"
    read SIFRE
   
    echo "userpassword: $SIFRE" >>tamerdemir-MAC.ldif
    echo "radiusFramedIPAddress: 255.255.255.254" >>tamerdemir-MAC.ldif
    echo "radiusFramedMTU: 1024" >>tamerdemir-MAC.ldif
    echo "" >>tamerdemir-MAC.ldif
    export COUNT=$[$COUNT - 1]
    echo $COUNT users left...
    echo
    echo
  done
  
  /usr/local/openldap-2.0.27/libexec/slapd
  /usr/local/openldap-2.0.27/bin/ldapadd -f tamerdemir-MAC.ldif -xv -D
"cn=Manager,dc=tamerdemir,dc=com" -w secret
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS and LDAP deamons are written to /etc/rc.local  file inroder
to start when the server is restarted"
  echo "/usr/local/openldap-2.0.27/libexec/slapd" >>/etc/rc.local
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Now I will test  sample 00022d-034186 MAC Address..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret
localhost 0 testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "If you see Access-Accept, we did everything right :))"
  sleep 3
#without LDAP ...
else
  touch Kullanicilar.txt
  clear
  echo "Now I am giving some information about MAC addresses"
  echo
  echo "Orinoco/Avaya/Lucent with FreeRADIUS:"
  echo "MAC addressses  are in this format 111111-222222, password is not
important"
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC addressses  are in this format 1111122222, password is the
same as MAC addresses"
  echo
  echo "Cisco:"
  echo "Cisco Aironet does not do MAC address authentication, instead it
does user authentication"
  echo
  sleep 2
  echo "Now, Enter how many number of MAC addresses or users are we going
to add..."
  echo
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "Now enter MAC addresses or user names according to the above
information..."
    echo "Eg:00022d-034186 or Eg2:tamer"
    read MAC
    
    echo
    echo "Enter Password:"
    read SIFRE
    echo "$MAC  Auth-Type := Local, User-Password ==
\"$SIFRE\" " >>Kullanicilar.txt
    echo "" >>Kullanicilar.txt
    export COUNT=$[$COUNT - 1]
    echo $COUNT user left...
    echo
    echo
  done
  head -74  /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users > tmp
  echo "" >>tmp
  cat Kullanicilar.txt >>tmp
  tail -140 /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users >>tmp
  echo "" >>tmp
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial  
  rm /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  cp tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS deamons are written to /etc/rc.local  file inroder to start
when the server is restarted"
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Now I will test  sample 00022d-034186 MAC Address..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret
localhost 0 testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "If you see Access-Accept, we did everything right :))"
  sleep 3
fi  
echo 
echo
echo 
echo
echo "Setup Finish"
echo "                      Tamer Demir"
echo "                      [EMAIL PROTECTED]"
echo "                      http://www.tamerdemir.com";
echo "You can mail me for any kind of programming improvement or languge
addition"
#End of English if
fi

#!/bin/sh

# Purpose:
# Easy Installations and configurations of FreeRADIUS-0.81 & OpenLDAP-2.0.27 for 
Wireless Networks 
# MAC Address & User Authentication
# It should also work for Wired Networks...
#

#(c) 10 January 2003 Tamer Demir  <[EMAIL PROTECTED]>
# http://www.netlab.boun.edu.tr/~tamer/
# -------------------------------------------------------------------------
#    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# -----------------------------------------------------------------------

# RUN:
# $sh wireless_authenticate.0.0.1.sh

# TESTED PLATFORM:
# *Red Hat 7.1
# *Red Hat 8.0

# TODO:
# * EAP-MD5 Script  
# * EAP-TLS Script
# * Currently, This script depends on the current config files of FreeRADIUS and 
OpenLDAP
#   It should be version independent.
# * Needs some script improvements
# * Apache Interface -Web Authentication- should be included 
# * New languages should be added

clear
echo Suggestion:
echo First read the source code of this program make your changes if you desire then 
run!!
echo Tavsiye:
echo �nce kaynak kodu okuyun gerekiyorsa baz� de�i�iklikleri yapt�ktan sonra 
�al��t�r�n!!
echo
echo Choose your language during installation \"MAC Address \& User Authentication 
with RADIUS\&LDAP in Wireless Networks\"
echo \"Kablosuz A�larda RADIUS ve LDAP ile \"MAC Address \& User Authentication 
Uygulamas� \" kurulumu icin dilinizi seciniz
echo "T�rk�e = t"
echo "english = e"
read dil
clear

# T�rk�e
if test $dil = "t"
then
 echo
 echo "LDAP kurmak istiyormusun?"
 echo "Evet = e"
 echo "Hayir = h"
 read LDAP
 if test $LDAP = "e"
 then
   echo �imdi OpenLDAP-2.0.27 dosyas�n� indiriyorum \(www.openldap.org\)
   echo Kayna��n oldu�u sunucuda bir sorun olursa www.openldap.org dan bu klas�re 
indirebilirsiniz 
   # wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.0.27.tgz
   # wget http://www.cmpe.boun.edu.tr/~demirt/sil-source/openldap-2.0.27.tgz
   # wget http://www.netlab.boun.edu.tr/~tamer/LDAP/openldap-2.0.27.tgz
   rm -r openldap-2.0.27/
   tar zxvf openldap-2.0.27.tgz
   cd openldap-2.0.27/
        (
         ./configure --prefix=/usr/local/openldap-2.0.27/  
--exec-prefix=/usr/local/openldap-2.0.27/
         make depend
         make
         make test 
         make install
        )
   cd ..
   rm -r openldap-2.0.27
 fi
 echo "�imdi FreeRADIUS u indiriyorum"
#RADIUS
# wget ftp://ftp.freeradius.org/pub/radius/freeradius-0.8.1.tar.gz
# wget http://www.cmpe.boun.edu.tr/~demirt/sil-source/freeradius-0.8.1.tar.gz
# wget http://www.netlab.boun.edu.tr/~tamer/RADIUS/freeradius-0.8.1.tar.gz
 rm -r freeradius-0.8.1
 tar zxvf freeradius-0.8.1.tar.gz
 cd freeradius-0.8.1
        (
        ./configure --prefix=/usr/local/freeradius-0.8.1-LDAP/ 
--with-radacctdir=/usr/local/freeradius-0.8.1-LDAP/ --with-ldap 
--with-openldap=/usr/local/openldap --without-rlm_x99_token
        make
        make install
        )
 cd .. 

clear
sleep 2
echo "Kablosuz kullan�c�n�n ba�lanaca�� Access Point sayisini yaziniz, NAS"
echo "Bu sayi RADIUS serverini kullanma izni olacak AP lerin sayisidir"
export COUNT=1
read COUNT
while [ "$COUNT" != "0" ]
do
  echo "Kablosuz kullan�c�n�n ba�lanaca�� Access Point in IP numaras�n� �u �ekilde 
girin, �rnek: 192.168.91.102"
  read A 
  echo "$A              secret ">>/usr/local/freeradius-0.8.1-LDAP/etc/raddb/clients
  export COUNT=$[$COUNT - 1]
  echo $COUNT adet AP kald� geriye...
  echo
  echo
done

sleep 2
echo
echo "AP de RADIUS ayarlar�nda RADIUS server�n�n IP sini girmeyi ve sifresine secret 
yazmay� unutmay�n"
echo "Di�er AP leri clients dosyas�na ekleyebilirsiniz, ama clients dosyas� 
clients.conf dosyas� taraf�ndan eskitilmistir"
#LDAP l� kurulum....
if test $LDAP = "e"
then
  cp freeradius-0.8.1/doc/RADIUS-LDAPv3.schema 
/usr/local/openldap-2.0.27/etc/openldap/schema/
  sed -e '7s/.*/include         
\/usr\/local\/openldap-2.0.27\/etc\/openldap\/schema\/RADIUS-LDAPv3.schema/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '47s/.*/suffix          "dc=tamerdemir,dc=com"/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '49s/.*/rootdn          "cn=Manager,dc=tamerdemir,dc=com"/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '664s/.*/                server = "127.0.0.1"/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '667s/.*/                basedn = "dc=tamerdemir,dc=com"/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '668s/uid/cn/' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp 
; mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '681s/access_attr/#access_attr/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1182s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1183s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1184s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf

  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial
  echo
  echo "ilk kurum users dosyasi users.initial olarak degistirilmistir ileride bakmaniz 
gerekirse diye..."
  sleep 2
  echo "DEFAULT        Auth-Type := LDAP" > 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "                Fall-Through = 1" >> 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users

  echo "dn: dc=tamerdemir,dc=com" > tamerdemir-MAC.ldif
  echo "objectClass: dcObject" >> tamerdemir-MAC.ldif
  echo "dc: tamerdemir" >>tamerdemir-MAC.ldif
  echo "" >>tamerdemir-MAC.ldif
  echo
  echo "Simdi �rnek Kullanici MAC Adresi eklenmesi i�in bilgi veriyorum"
  echo
  echo "Orinoco/Avaya/Lucent ve FreeRADIUS:"
  echo "MAC adresleri 111111-222222 �eklinde olmal�, �ifre �nemli de�il."
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC adresleri 1111122222 �eklinde olmal�, �ifre MAC adresiyle ayn� olmal�"
  echo
  echo "Cisco:"
  echo "Cisco Aironet MAC adres tan�mlanmas� authentication yapmiyor, kullan�c� ismine 
g�re yap�yor"
  sleep 2
  echo
  echo "�imdi veritaban�na ka� adet kullan�c� veya MAC adresi ekleyece�inizi yaz�n�z"
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "�imdi MAC adreslerini veya kullan�c� ismini yaz�n"
    echo "�rnek:00022d-034186 veya �rnek2:tamer"
    read MAC
    echo "dn: cn=$MAC,dc=tamerdemir,dc=com" >>tamerdemir-MAC.ldif
    echo "objectclass: top" >>tamerdemir-MAC.ldif
    echo "objectclass: person" >>tamerdemir-MAC.ldif
    echo "objectclass: radiusprofile" >>tamerdemir-MAC.ldif
    echo "cn: $MAC" >>tamerdemir-MAC.ldif
    echo "sn: Avaya" >>tamerdemir-MAC.ldif

    echo "Yukar�daki a��klamalara g�re kullan�c� �ifresini yaz�n"
    read SIFRE
   
    echo "userpassword: $SIFRE" >>tamerdemir-MAC.ldif
    echo "radiusFramedIPAddress: 255.255.255.254" >>tamerdemir-MAC.ldif
    echo "radiusFramedMTU: 1024" >>tamerdemir-MAC.ldif
    echo "" >>tamerdemir-MAC.ldif
    export COUNT=$[$COUNT - 1]
    echo $COUNT adet AP kald� geriye...
    echo
    echo

  done
  
  /usr/local/openldap-2.0.27/libexec/slapd
  /usr/local/openldap-2.0.27/bin/ldapadd -f tamerdemir-MAC.ldif -xv -D 
"cn=Manager,dc=tamerdemir,dc=com" -w secret
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd

  clear
  echo "RADIUS ve LDAP bilisayarin acildiginda calismasi icin /etc/rc.local  dosyasina 
yazildi"
  echo "/usr/local/openldap-2.0.27/libexec/slapd" >>/etc/rc.local
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Simdi 00022d-034186 MAC adresini Test edecegiz..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret localhost 0 
testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "Eger Access-Accept yazisini gorduyseniz kurulum basariyla tamamlanmistir"
  sleep 3

#LDAP s�z kurulum...
else
  touch Kullanicilar.txt
  echo
  echo "Orinoco/Avaya/Lucent ve FreeRADIUS:"
  echo "MAC adresleri 111111-222222 �eklinde olmal�, �ifre �nemli de�il."
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC adresleri 1111122222 �eklinde olmal�, �ifre MAC adresiyle ayn� olmal�"
  echo
  echo "Cisco:"
  echo "Cisco Aironet MAC adres tan�mlanmas� authentication yapmiyor, kullan�c� ismine 
g�re yap�yor"
  echo
  sleep 2
  echo
  echo "�imdi veritaban�na ka� adet kullan�c� veya MAC adresi ekleyece�inizi yaz�n�z"
  echo
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "�imdi MAC adreslerini veya kullan�c� ismini yaz�n"
    echo "�rnek:00022d-034186 veya �rnek2:tamer"
    read MAC
    
    echo
    echo "�ifresini yaz�n:"
    read SIFRE
    echo "$MAC  Auth-Type := Local, User-Password == \"$SIFRE\" " >>Kullanicilar.txt
    echo "" >>Kullanicilar.txt

    export COUNT=$[$COUNT - 1]
    echo $COUNT adet kullan�c� kald� geriye...
    echo
    echo
  done
  head -74  /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users > tmp
  echo "" >>tmp
  cat Kullanicilar.txt >>tmp
  tail -140 /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users >>tmp
  echo "" >>tmp
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial  
  rm /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  cp tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS bilisayarin acildiginda calismasi icin /etc/rc.local  dosyasina 
yazildi"
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Simdi 00022d-034186 MAC adresini Test edecegiz..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret localhost 0 
testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "Eger Access-Accept yazisini gorduyseniz kurulum basariyla tamamlanmistir"
  sleep 3
  
fi  
  
echo 
echo
echo 
echo
echo "Kurulum tamamlanmistir"
echo "                      Tamer Demir"
echo "                      [EMAIL PROTECTED]"
echo "                      http://www.tamerdemir.com";
echo "Her t�rl� geli�tirme i�in bana e-posta g�nderebilirsiniz"

#English..........................................

else

 echo
 echo "Do you want to setup LDAP?"
 echo "yEs = e"
 echo "noH = h"
 read LDAP
 if test $LDAP = "e"
 then
   echo Now I am downloading OpenLDAP-2.0.27 \(www.openldap.org\)
   # wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.0.27.tgz
   # wget http://www.cmpe.boun.edu.tr/~demirt/sil-source/openldap-2.0.27.tgz
   # wget http://www.netlab.boun.edu.tr/~tamer/LDAP/openldap-2.0.27.tgz
   rm -r openldap-2.0.27/
   tar zxvf openldap-2.0.27.tgz
   cd openldap-2.0.27/
        (
         ./configure --prefix=/usr/local/openldap-2.0.27/  
--exec-prefix=/usr/local/openldap-2.0.27/
         make depend
         make
         make test
         make install
        )
   cd ..
   rm -r openldap-2.0.27
 fi
#RADIUS
 echo "Now i am downloading FreeRADIUS"
# wget ftp://ftp.freeradius.org/pub/radius/freeradius-0.8.1.tar.gz
# wget http://www.cmpe.boun.edu.tr/~demirt/sil-source/freeradius-0.8.1.tar.gz
# wget http://www.netlab.boun.edu.tr/~tamer/RADIUS/freeradius-0.8.1.tar.gz
 rm -r freeradius-0.8.1
 tar zxvf freeradius-0.8.1.tar.gz
 cd freeradius-0.8.1
        (
        ./configure --prefix=/usr/local/freeradius-0.8.1-LDAP/ 
--with-radacctdir=/usr/local/freeradius-0.8.1-LDAP/ --with-ldap 
--with-openldap=/usr/local/openldap --without-rlm_x99_token
        make
        make install
        )
 cd .. 
sleep 2
clear
echo "Enter the Number of Access Points, NASes"
echo "This number is the allowed number of AP that can use RADIUS"
export COUNT=1
read COUNT
while [ "$COUNT" != "0" ]
do
  echo "Enter the IP address of the Access Points, Eg: 192.168.91.102"
  read A
  echo "$A              secret ">>/usr/local/freeradius-0.8.1-LDAP/etc/raddb/clients
  export COUNT=$[$COUNT - 1]
  echo $COUNT number of AP left...
  echo
  echo
done

sleep 2
echo
echo "Write the IP address of the RADIUS server into the AP, and write secret as the 
password"
echo "In order to add other AP, you can use clients file, But clients file is 
depreciated by the clients.conf file"
#with LDAP ....
if test $LDAP = "e"
then
  cp freeradius-0.8.1/doc/RADIUS-LDAPv3.schema 
/usr/local/openldap-2.0.27/etc/openldap/schema/
  sed -e '7s/.*/include         
\/usr\/local\/openldap-2.0.27\/etc\/openldap\/schema\/RADIUS-LDAPv3.schema/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '47s/.*/suffix          "dc=tamerdemir,dc=com"/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '49s/.*/rootdn          "cn=Manager,dc=tamerdemir,dc=com"/' 
</usr/local/openldap-2.0.27/etc/openldap/slapd.conf > tmp ; mv -f tmp 
/usr/local/openldap-2.0.27/etc/openldap/slapd.conf
  sed -e '664s/.*/                server = "127.0.0.1"/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '667s/.*/                basedn = "dc=tamerdemir,dc=com"/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '668s/uid/cn/' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp 
; mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf 
  sed -e '681s/access_attr/#access_attr/' 
</usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; mv -f tmp 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1182s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1183s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf
  sed -e '1184s/#/ /' </usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf > tmp ; 
mv -f tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/radiusd.conf

  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial
  echo
  echo "users file is changed to users.initial for further references..."
  sleep 2
  echo "DEFAULT        Auth-Type := LDAP" > 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  echo "                Fall-Through = 1" >> 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users

  echo "dn: dc=tamerdemir,dc=com" > tamerdemir-MAC.ldif
  echo "objectClass: dcObject" >> tamerdemir-MAC.ldif
  echo "dc: tamerdemir" >>tamerdemir-MAC.ldif
  echo "" >>tamerdemir-MAC.ldif
  clear
  echo "Now I am giving some information about MAC addresses"
  echo
  echo "Orinoco/Avaya/Lucent with FreeRADIUS:"
  echo "MAC addressses  are in this format 111111-222222, password is not important"
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC addressses  are in this format 1111122222, password is the same as MAC 
addresses"
  echo
  echo "Cisco:"
  echo "Cisco Aironet does not do MAC address authentication, instead it does user 
authentication"
  echo
  sleep 2
  echo "Now, Enter how many number of MAC addresses or users are we going to add..."
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "Now enter MAC addresses or user names according to the above information..."
    echo "Eg:00022d-034186 or Eg2:tamer"
    read MAC
    echo "dn: cn=$MAC,dc=tamerdemir,dc=com" >>tamerdemir-MAC.ldif
    echo "objectclass: top" >>tamerdemir-MAC.ldif
    echo "objectclass: person" >>tamerdemir-MAC.ldif
    echo "objectclass: radiusprofile" >>tamerdemir-MAC.ldif
    echo "cn: $MAC" >>tamerdemir-MAC.ldif
    echo "sn: Avaya" >>tamerdemir-MAC.ldif

    echo "According to the above information enter the password"
    read SIFRE
   
    echo "userpassword: $SIFRE" >>tamerdemir-MAC.ldif
    echo "radiusFramedIPAddress: 255.255.255.254" >>tamerdemir-MAC.ldif
    echo "radiusFramedMTU: 1024" >>tamerdemir-MAC.ldif
    echo "" >>tamerdemir-MAC.ldif
    export COUNT=$[$COUNT - 1]
    echo $COUNT users left...
    echo
    echo

  done
  
  /usr/local/openldap-2.0.27/libexec/slapd
  /usr/local/openldap-2.0.27/bin/ldapadd -f tamerdemir-MAC.ldif -xv -D 
"cn=Manager,dc=tamerdemir,dc=com" -w secret
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd

  clear
  echo "RADIUS and LDAP deamons are written to /etc/rc.local  file inroder to start 
when the server is restarted"
  echo "/usr/local/openldap-2.0.27/libexec/slapd" >>/etc/rc.local
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Now I will test  sample 00022d-034186 MAC Address..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret localhost 0 
testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "If you see Access-Accept, we did everything right :))"
  sleep 3

#without LDAP ...
else
  touch Kullanicilar.txt
  clear
  echo "Now I am giving some information about MAC addresses"
  echo
  echo "Orinoco/Avaya/Lucent with FreeRADIUS:"
  echo "MAC addressses  are in this format 111111-222222, password is not important"
  echo
  echo "3Com AP8000 ve FreeRADIUS:"
  echo "MAC addressses  are in this format 1111122222, password is the same as MAC 
addresses"
  echo
  echo "Cisco:"
  echo "Cisco Aironet does not do MAC address authentication, instead it does user 
authentication"
  echo
  sleep 2
  echo "Now, Enter how many number of MAC addresses or users are we going to add..."
  echo
  export COUNT=1
  read COUNT
  while [ "$COUNT" != "0" ]
  do
    echo "Now enter MAC addresses or user names according to the above information..."
    echo "Eg:00022d-034186 or Eg2:tamer"
    read MAC
    
    echo
    echo "Enter Password:"
    read SIFRE
    echo "$MAC  Auth-Type := Local, User-Password == \"$SIFRE\" " >>Kullanicilar.txt
    echo "" >>Kullanicilar.txt

    export COUNT=$[$COUNT - 1]
    echo $COUNT user left...
    echo
    echo
  done
  head -74  /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users > tmp
  echo "" >>tmp
  cat Kullanicilar.txt >>tmp
  tail -140 /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users >>tmp
  echo "" >>tmp
  cp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users 
/usr/local/freeradius-0.8.1-LDAP/etc/raddb/users.initial  
  rm /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  cp tmp /usr/local/freeradius-0.8.1-LDAP/etc/raddb/users
  
  /usr/local/freeradius-0.8.1-LDAP/sbin/radiusd
  clear
  echo "RADIUS deamons are written to /etc/rc.local  file inroder to start when the 
server is restarted"
  echo "/usr/local/freeradius-0.8.1-LDAP/sbin/radiusd" >>/etc/rc.local
  sleep 1
  echo "Now I will test  sample 00022d-034186 MAC Address..."
  sleep 1
  /usr/local/freeradius-0.8.1-LDAP/bin/radtest 00022d-034186 secret localhost 0 
testing123
  echo "radtest 00022d-034186 secret localhost 0 testing123"
  echo "If you see Access-Accept, we did everything right :))"
  sleep 3
fi  
echo 
echo
echo 
echo
echo "Setup Finish"
echo "                      Tamer Demir"
echo "                      [EMAIL PROTECTED]"
echo "                      http://www.tamerdemir.com";
echo "You can mail me for any kind of programming improvement or languge addition"
#End of English if
fi

Reply via email to