This post is published as a personal reference, It describes a method via which you can modify the user account expiration default time of 00:00:00 to some other time, so that middle night disconnection can be avoided & user can get some time in official hours to recharge there account. with traditional FREERADIUS we can modify the disconnection in RADCHECK table, but since DMA doesn’t defines the expiration there & uses its own authentication module which checks for the user expiration date in RM_USERS table, therefore we have to make little modification to facilitate this option.
Another option is to create TRIGGERS, so that whenever a new user is created, it should modify the time instantly, or add the user name in separate table, and using predefined bash script which can monitor the table and perform action accordingly. lots of options can be opted.
As asked by few network OP’s who are using dmasoftlab radius manager as there billing system & performs manual recharge after getting payment from the users by door to door collection, One of the most annoying issue is the expiration time at which users get disconnected dueto expiration limit expires. By default when a user is created his time is entered in following format
2021-03-20 00:00:00
As a result, as soon as date changes at 00:00:00 hours, the user will be disconnected from the system. which means in the middle of night. Users starts calling OP help desk & most of the time, its difficult to recharge accounts in mid night.
Therefore its better to change the expiration time to happen in official working hours so that both user & OP can have some time to recharge the accounts within office hours.
To automate this process, create a bash script & schedule it to run after every 10 minutes. This script will change all users expiration HOURS to your modified time.
SCRIPT !
Create TEMP folder & script content
mkdir /temp mkdir /temp/expmod.sh nano /temp/expmod.sh
& paste following
#!/bin/sh # set -x # BASH base script to change EXPIRATION hours in DMA RADIUS Manager RM_USERS table # to modify users expiration disconnection time so that middle night disconnection can be avoided # You can schedule this script to run every XX minutes/hours # example : in cron use below line # */5 * * * * /temp/expmod.sh ################################################ # By Syed Jahanzaib / aacable at hotmail dot com # CREATED on : 20th-March-2021 ################################################ # MYSQL related. MAKE SURE TO CHANGE THESE to MATCH YOUR LOCAL's SQLUSER="root" SQLPASS="zaib1234" export MYSQL_PWD=$SQLPASS CMD="mysql -u$SQLUSER --skip-column-names -s -e" DB="radius" # DMA related, change below timings as per your requirements DEFAULT_TIME="00:00:00" NEW_EXP_TIME="20:00:00" COLUMN_NAME="expiration" # R.M Table which contain users expiration information (in freeradius, we use Expiration attribute in radcheck, # But DMA uses its own authentication module to validate users details from the rm_users table USER_TABLE="rm_users" # Date Related DATE=`date` TODAY=$(date +"%Y-%m-%d") # Start execution # Modify the 00:00:00 hours to suite yours local time, I have used 8pm timings as an example $CMD "use $DB; UPDATE $USER_TABLE SET $COLUMN_NAME = replace($COLUMN_NAME, '$DEFAULT_TIME', '$NEW_EXP_TIME');" # or you can use single line code here in mysql directly or by $CMD #UPDATE rm_users SET expiration = replace(expiration, '00:00:00', '20:00:00'); # ECHO on screen and also LOG in /var/log/syslog (for ubuntu) echo "DMASOFTLAB RADIUS MANAGER - User expiration HOURS now changed from $COLUMN_NAME to $NEW_EXP_TIME - Script executed successfully @ $DATE" logger "DMASOFTLAB RADIUS MANAGER - User expiration HOURS now changed from $COLUMN_NAME to $NEW_EXP_TIME - Script executed successfully @ $DATE" #Script Ends here
Regard’s
Syed Jahanzaib