Subversion Repositories ALCASAR

Rev

Rev 2600 | Rev 2631 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2600 Rev 2601
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-sms.sh 2600 2018-08-19 23:48:55Z tom.houdayer $
2
# $Id: alcasar-sms.sh 2601 2018-08-19 23:58:27Z tom.houdayer $
3
 
3
 
4
# alcasar-sms.sh
4
# alcasar-sms.sh
5
# by Nicolas Aubry & Rexy
5
# by Nicolas Aubry & Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 15... Line 15...
15
nb_essais=3
15
nb_essais=3
16
time_account=1
16
time_account=1
17
time_ban=2
17
time_ban=2
18
#########################################
18
#########################################
19
####### IDs DB ##########################
19
####### IDs DB ##########################
20
u_db="radius"
20
PASSWD_FILE="/root/ALCASAR-passwords.txt"
-
 
21
u_db=$(grep '^db_user='     $PASSWD_FILE | cut -d'=' -f2-)
21
p_db="password"
22
p_db=$(grep '^db_password=' $PASSWD_FILE | cut -d'=' -f2-)
22
#########################################
23
#########################################
23
#########################################
24
#########################################
24
 
25
 
25
rad="radcheck"
26
rad="radcheck"
26
radgp="radusergroup"
27
radgp="radusergroup"
Line 80... Line 81...
80
		sql_add_gp="INSERT INTO $radgp (username,groupname) VALUES ('sms','sms'); INSERT INTO $radgpck (groupname,attribute,op,value) VALUES ('sms','Simultaneous-Use',':=',1);"
81
		sql_add_gp="INSERT INTO $radgp (username,groupname) VALUES ('sms','sms'); INSERT INTO $radgpck (groupname,attribute,op,value) VALUES ('sms','Simultaneous-Use',':=',1);"
81
		mysql --user=$u_db --password=$p_db --database=radius -Bs -e "$sql_add_gp"
82
		mysql --user=$u_db --password=$p_db --database=radius -Bs -e "$sql_add_gp"
82
	fi
83
	fi
83
 
84
 
84
	#Start gammu
85
	#Start gammu
85
		echo $separator >> $logfile
86
	echo $separator >> $logfile
86
		sudo gammu-smsd --config $config --pid /var/run/gammu-smsd.pid --daemon
87
	/usr/bin/systemctl -q start gammu-smsd.service
-
 
88
	/usr/bin/systemctl -q enable gammu-smsd.service
87
} # end function start_gammu
89
} # end function start_gammu
88
 
90
 
89
function stop_gammu() {
91
function stop_gammu() {
90
	#Stop gammu
92
	#Stop gammu
91
		sudo kill -9 gammu-smsd
93
	/usr/bin/systemctl -q stop gammu-smsd.service
-
 
94
	/usr/bin/systemctl -q disable gammu-smsd.service
92
		sleep 10
95
	sleep 10
93
		echo $end >> $logfile
96
	echo $end >> $logfile
94
} # end function stop_gammu
97
} # end function stop_gammu
95
 
98
 
96
function unlock() {
99
function unlock() {
97
	#Suppression du numero dans la table SMS_ban_perm
100
	#Suppression du numero dans la table SMS_ban_perm
98
		sql_remove_ban_perm="connect gammu; DELETE FROM $sms_p"
101
		sql_remove_ban_perm="connect gammu; DELETE FROM $sms_p"