Subversion Repositories ALCASAR

Rev

Rev 1348 | Rev 1350 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 1348 Rev 1349
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 1348 2014-05-13 22:13:45Z richard $ 
2
#  $Id: alcasar.sh 1349 2014-05-14 14:52:19Z richard $ 
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
 
5
 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
7
# Ce programme est un logiciel libre ; This software is free and open source
7
# Ce programme est un logiciel libre ; This software is free and open source
Line 42... Line 42...
42
#	dnsmasq			: Name server configuration
42
#	dnsmasq			: Name server configuration
43
#	BL			: BlackList of Toulouse configuration : split into 3 BL (for Dnsmasq, for dansguardian and for Netfilter)
43
#	BL			: BlackList of Toulouse configuration : split into 3 BL (for Dnsmasq, for dansguardian and for Netfilter)
44
#	cron			: Logs export + watchdog + connexion statistics
44
#	cron			: Logs export + watchdog + connexion statistics
45
#	fail2ban		: Fail2ban installation and configuration
45
#	fail2ban		: Fail2ban installation and configuration
46
#	post_install		: Security, log rotation, etc.
46
#	post_install		: Security, log rotation, etc.
-
 
47
#	gammu_smsd			: Autoregister addon (gammu-smsd)
47
 
48
 
48
DATE=`date '+%d %B %Y - %Hh%M'`
49
DATE=`date '+%d %B %Y - %Hh%M'`
49
DATE_SHORT=`date '+%d/%m/%Y'`
50
DATE_SHORT=`date '+%d/%m/%Y'`
50
Lang=`echo $LANG|cut -c 1-2`
51
Lang=`echo $LANG|cut -c 1-2`
51
# ******* Files parameters - paramètres fichiers *********
52
# ******* Files parameters - paramètres fichiers *********
Line 63... Line 64...
63
CONF_FILE="$DIR_DEST_ETC/alcasar.conf"		# central ALCASAR conf file
64
CONF_FILE="$DIR_DEST_ETC/alcasar.conf"		# central ALCASAR conf file
64
PASSWD_FILE="/root/ALCASAR-passwords.txt"	# text file with the passwords and shared secrets
65
PASSWD_FILE="/root/ALCASAR-passwords.txt"	# text file with the passwords and shared secrets
65
# ******* DBMS parameters - paramètres SGBD ********
66
# ******* DBMS parameters - paramètres SGBD ********
66
DB_RADIUS="radius"				# database name used by FreeRadius server
67
DB_RADIUS="radius"				# database name used by FreeRadius server
67
DB_USER="radius"				# user name allows to request the users database
68
DB_USER="radius"				# user name allows to request the users database
-
 
69
DB_GAMMU="gammu"				# database name used by Gammu-smsd
68
# ******* Network parameters - paramètres réseau *******
70
# ******* Network parameters - paramètres réseau *******
69
HOSTNAME="alcasar"				# 
71
HOSTNAME="alcasar"				# 
70
DOMAIN="localdomain"				# default local domain
72
DOMAIN="localdomain"				# default local domain
71
EXTIF=`/sbin/ip route|grep default|cut -d" " -f5`	# EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
73
EXTIF=`/sbin/ip route|grep default|cut -d" " -f5`	# EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
72
INTIF=`/sbin/ip	link|grep '^[[:digit:]]:'|grep -v "lo\|$EXTIF"|cut -d" " -f2|tr -d ":"`		# INTIF is connected to the consultation network
74
INTIF=`/sbin/ip	link|grep '^[[:digit:]]:'|grep -v "lo\|$EXTIF"|cut -d" " -f2|tr -d ":"`		# INTIF is connected to the consultation network
Line 1655... Line 1657...
1655
	fi
1657
	fi
1656
	clear
1658
	clear
1657
	reboot
1659
	reboot
1658
} # End post_install ()
1660
} # End post_install ()
1659
 
1661
 
-
 
1662
 
-
 
1663
##################################################################
-
 
1664
## 			Fonction "gammu_smsd"			##
-
 
1665
## - Creation de la base de donnée Gammu			##
-
 
1666
## - Creation du fichier de config: gammu_smsd_conf		##
-
 
1667
##								##
-
 
1668
##################################################################
-
 
1669
gammu_smsd()
-
 
1670
{
-
 
1671
# Create 'gammu' databse
-
 
1672
MYSQL="/usr/bin/mysql -uroot -p$mysqlpwd --exec"
-
 
1673
	$MYSQL="CREATE DATABASE IF NOT EXISTS $DB_GAMMU;GRANT ALL ON $DB_GAMMU.* TO $DB_USER@localhost IDENTIFIED BY '$radiuspwd';FLUSH PRIVILEGES"
-
 
1674
# Add a gammu database structure
-
 
1675
	mysql -u$DB_USER -p$radiuspwd $DB_GAMMU < $DIR_CONF/gammu-smsd-db-vierge.sql
-
 
1676
 
-
 
1677
 
-
 
1678
# Creation du fichier de config gammu_smsd_conf
-
 
1679
cat << EOF > /etc/gammu_smsd_conf
-
 
1680
[gammu]
-
 
1681
port = /dev/ttyUSB0
-
 
1682
connection = at115200
-
 
1683
 
-
 
1684
;########################################################
-
 
1685
 
-
 
1686
[smsd]
-
 
1687
 
-
 
1688
PIN = 1234
-
 
1689
 
-
 
1690
logfile = /var/log/gammu-smsd/gammu-smsd.log
-
 
1691
logformat = textall
-
 
1692
debuglevel = 0
-
 
1693
 
-
 
1694
service = sql
-
 
1695
driver = native_mysql
-
 
1696
user = $DB_USER
-
 
1697
password = $radiuspwd
-
 
1698
pc = localhost
-
 
1699
database = $DB_GAMMU
-
 
1700
 
-
 
1701
RunOnReceive = /usr/local/bin/alcasar-sms.sh --new_sms
-
 
1702
 
-
 
1703
StatusFrequency = 30
-
 
1704
LoopSleep = 2
-
 
1705
 
-
 
1706
;ResetFrequency = 300
-
 
1707
;HardResetFrequency = 120
-
 
1708
 
-
 
1709
CheckSecurity = 1 
-
 
1710
CheckSignal = 1
-
 
1711
CheckBattery = 0
-
 
1712
EOF
-
 
1713
 
-
 
1714
chmod 755 /etc/gammu_smsd_conf
-
 
1715
 
-
 
1716
#Creation dossier de log Gammu-smsd
-
 
1717
mkdir /var/log/gammu-smsd
-
 
1718
chmod 755 /var/log/gammu-smsd
-
 
1719
 
-
 
1720
#Edition du script sql gammu <-> radius
-
 
1721
$SED "10c u_db=\"$DB_USER\"" $DIR_DEST_BIN/alcasar-sms.sh
-
 
1722
$SED "11c p_db=\"$radiuspwd\"" $DIR_DEST_BIN/alcasar-sms.sh
-
 
1723
 
-
 
1724
} # END gammu_smsd()
-
 
1725
 
-
 
1726
 
-
 
1727
 
-
 
1728
 
1660
#################################
1729
#################################
1661
#  	Main Install loop  	#
1730
#  	Main Install loop  	#
1662
#################################
1731
#################################
1663
dir_exec=`dirname "$0"`
1732
dir_exec=`dirname "$0"`
1664
if [ $dir_exec != "." ]
1733
if [ $dir_exec != "." ]
Line 1717... Line 1786...
1717
		$DIR_SCRIPTS/alcasar-urpmi.sh
1786
		$DIR_SCRIPTS/alcasar-urpmi.sh
1718
		if [ "$?" != "0" ]
1787
		if [ "$?" != "0" ]
1719
		then
1788
		then
1720
			exit 0
1789
			exit 0
1721
		fi
1790
		fi
1722
echo "STOP" ; read a
-
 
1723
		if [ -e $CONF_FILE ]
1791
		if [ -e $CONF_FILE ]
1724
		then
1792
		then
1725
# Uninstall the running version
1793
# Uninstall the running version
1726
			$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
1794
			$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
1727
		fi
1795
		fi