Subversion Repositories ALCASAR

Rev

Rev 3312 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3312 Rev 3318
Line 25... Line 25...
25
tmp_file="alcasar-users-database-$new.sql"
25
tmp_file="alcasar-users-database-$new.sql"
26
 
26
 
27
stop_acct () # Close the accounting open sessions
27
stop_acct () # Close the accounting open sessions
28
{
28
{
29
	date_now=`date "+%F %X"`
29
	date_now=`date "+%F %X"`
30
	echo "UPDATE radacct SET acctstoptime = '$date_now', acctterminatecause = 'Admin-Reset' WHERE acctstoptime IS NULL" | mariadb -u$DB_USER -p$DB_PASS $DB_RADIUS
30
	echo "UPDATE radacct SET acctstoptime = '$date_now', acctterminatecause = 'Admin-Reset' WHERE acctstoptime IS NULL" | /usr/bin/mariadb -u$DB_USER -p$DB_PASS $DB_RADIUS
31
}
31
}
32
 
32
 
33
check ()
33
check ()
34
{
34
{
35
	echo "check (and repair if needed) the database :"
35
	echo "check (and repair if needed) the database :"
36
	mariadb-check --databases $DB_RADIUS -u $DB_USER -p$DB_PASS --auto-repair
36
	/usr/bin/mariadb-check --databases $DB_RADIUS -u $DB_USER -p$DB_PASS --auto-repair
37
}
37
}
38
 
38
 
39
remove_old_users ()	# Remove users who haven't logged in for more than a year (TO BE VERIFY BEFORE ACTIVATE)
39
remove_old_users ()	# Remove users who haven't logged in for more than a year (TO BE VERIFY BEFORE ACTIVATE)
40
{
40
{
41
	del_date=`date +%F`
41
	del_date=`date +%F`
Line 117... Line 117...
117
		if [ -e  $tmp_file ];
117
		if [ -e  $tmp_file ];
118
			then rm -f  $tmp_file
118
			then rm -f  $tmp_file
119
		fi
119
		fi
120
		check
120
		check
121
		echo "Export the database in file : $tmp_file.gz"
121
		echo "Export the database in file : $tmp_file.gz"
122
		mariadb-dump -u $DB_USER -p$DB_PASS --opt -BcQC  $DB_RADIUS > $rep_tr/$tmp_file
122
		/usr/bin/mariadb-dump -u $DB_USER -p$DB_PASS --opt -BcQC  $DB_RADIUS > $rep_tr/$tmp_file
123
		gzip -f $rep_tr/$tmp_file
123
		gzip -f $rep_tr/$tmp_file
124
		echo "End of export $( date "+%Hh %Mmn" )"
124
		echo "End of export $( date "+%Hh %Mmn" )"
125
		;;
125
		;;
126
	-c | --check | -check)	
126
	-c | --check | -check)	
127
		check
127
		check
Line 132... Line 132...
132
				echo "Enter a SQL file name ('.sql' or '.sql.gz')"
132
				echo "Enter a SQL file name ('.sql' or '.sql.gz')"
133
			exit 0
133
			exit 0
134
		else
134
		else
135
			case $2 in
135
			case $2 in
136
			*.sql.gz )
136
			*.sql.gz )
137
				gunzip -f < $2 | mariadb -u $DB_USER -p$DB_PASS
137
				gunzip -f < $2 | /usr/bin/mariadb -u $DB_USER -p$DB_PASS
138
				stop_acct
138
				stop_acct
139
				;;
139
				;;
140
			*.sql )
140
			*.sql )
141
				mariadb -u $DB_USER -p$DB_PASS < $2
141
				/usr/bin/mariadb -u $DB_USER -p$DB_PASS < $2
142
				stop_acct
142
				stop_acct
143
				;;
143
				;;
144
			esac
144
			esac
145
			migrationsPath="$DIR_BIN/alcasar-db-migrations"
145
			migrationsPath="$DIR_BIN/alcasar-db-migrations"
146
			"$migrationsPath/alcasar-migration_db-3.2.0.sh"
146
			"$migrationsPath/alcasar-migration_db-3.2.0.sh"
Line 148... Line 148...
148
			"$migrationsPath/alcasar-migration_db-3.3.1.sh"
148
			"$migrationsPath/alcasar-migration_db-3.3.1.sh"
149
			"$migrationsPath/alcasar-migration_db-3.7.0.sh"
149
			"$migrationsPath/alcasar-migration_db-3.7.0.sh"
150
		fi
150
		fi
151
		;;
151
		;;
152
	-r | --raz | -raz)
152
	-r | --raz | -raz)
153
		mariadb-dump -u $DB_USER -p$DB_PASS --opt -BcQC  $DB_RADIUS > $rep_tr/$tmp_file
153
		/usr/bin/mariadb-dump -u $DB_USER -p$DB_PASS --opt -BcQC  $DB_RADIUS > $rep_tr/$tmp_file
154
		gzip -f $rep_tr/$tmp_file
154
		gzip -f $rep_tr/$tmp_file
155
		mariadb -u$DB_USER -p$DB_PASS $DB_RADIUS < /etc/raddb/empty-radiusd-db.sql
155
		/usr/bin/mariadb -u$DB_USER -p$DB_PASS $DB_RADIUS < /etc/raddb/empty-radiusd-db.sql
156
		;;
156
		;;
157
	-a | --acct_stop | -acct_stop)
157
	-a | --acct_stop | -acct_stop)
158
		stop_acct
158
		stop_acct
159
		;;
159
		;;
160
	-e | --expire_user)
160
	-e | --expire_user)