Syed Jahanzaib Personal Blog to Share Knowledge !

November 17, 2015

DMASOFTLAB Radius Manager SMS/Email Alert for already expired account!

Filed under: Radius Manager — Tags: — Syed Jahanzaib / Pinochio~:) @ 12:53 PM

sms_alert

Task:

In Radius manager billing system, it is required to send users SMS/Email informing them that his/her internet account has been expired today, using local KANNEL sms gateway via bash / curl. The only difference between this and other expiry alerts is that this script will send alert to user (usually) right after his account expires only.

 


 

OS:
Linux / Ubuntu 12.4.5 /32bit

Billing System:
DMASOFTLAB Radius Manager 4.1.5

SMS Info:
Kannel 4.x with Teltonika Serial/COM G10 Modem with ‘Ufone’ operator SIM and yearly SMS bundle package.

Teltonika ModemCOM-G10 Serial / Com used to send / receive SMS using KANNEL as SMS Gateway

 


 

Solution:

Make this script and schedule it to run daily in night.

mkdir /temp/
touch /temp/sms2expiredusers.sh
nano /temp/sms2expiredusers.sh

(& copy paste following, make sure to change the info as mentioned in variables)

#!/bin/bash
# # set -x
# BASH base SMS script to inform users that there internet account been expired in Radius Manager today.
# the simple logic can be applied for about any other task as well. I tried to make it as simple as it can be
# By Syed Jahanzaib / aacable at hotmail dot com / https://aacable.wordpress.com
# CREATED on : 17th November, 2015 / 10:am

# Modify following data before execution
SQLUSER="root"
SQLPASS="SQLPASS"
# Kannel Server IP, if its local leave it as it is
KURL="http://127.0.0.1:13013"
KID="kannel"
KPASS="kannel"
TMP="/tmp/expiredusers.sms"
DAYS="00"
COMPANY="YOUR COMPANY NAME"

### DO-NOT EDIT BELOW THIS LINE ####

#Remove temp files created by earlier execution of this script
rm -fr /tmp/*.sms
> $TMP

mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; select username,firstname,lastname,mobile,expiration from rm_users where expiration = CURRENT_DATE() - INTERVAL $DAYS DAY;" > $TMP

# Apply Count Loop Formula to read each users (from column 1 in tmp file) data and fit individualy later in sms
num=0
cat $TMP  |awk 'NF > 1' | while read users
do
num=$[$num+1]

USR=`echo $users |awk '{print $1}'`
FNAME=`echo $users |awk '{print $2}'`
LNAME=`echo $users |awk '{print $3}'`
mobile=`echo $users | awk '{print $4}'`
exp=`echo $users | awk '{print $5}'`


######################
# ACCOUNT EXPIRY CHECK and some JUNK data transported from other scripts i made earlier.
######################

TODAY=$(date +"%Y-%m-%d")
TODAYDIGIT=`echo $TODAY  | sed -e 's/-//g'`
MONTH=$(date +"-%m")
CMONTH=`echo $MONTH  | sed -e 's/-//g'`
MONTHYEAR=$(date +"%B-%Y")
ALPHAMONTHYEAR=`echo $MONTHYEAR #| sed -e 's/-//g'`
SRVID=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; SELECT srvid FROM radius.rm_users WHERE rm_users.username = '$USR';"`
SRVPRICE=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius;  SELECT unitprice FROM radius.rm_services WHERE rm_services.srvid = $SRVID;" |cut -f1 -d"."`

#LOOK FOR USER ACTUAL SERVICE NAME
PKGNAME=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; SELECT srvname FROM radius.rm_services WHERE rm_services.srvid = '$SRVID';"`


########### ACCOUNT STATUS EXPIRED TODAY ACTION / SEND SMS OR EMAIL ############

# PRINT FETCHED VALUES into files, which we will use later to send sms using url encoded command of kannel
echo "$COMPANY ALERT:

Dear Mr. $FNAME $LNAME, Your internet account ID [$USR] with Package of [$PKGNAME] has expired on $exp.
Please pay your dues to renew your account.

For furhter information & support you may reach us at our Helpline.

$COMPANY
Powered by Jz" > /tmp/$USR.sms

# PRINT FETCHED VALUES into files,  ECHO JUST FOR SCREEN BASE INFO / ZAIB
echo "$COMPANY ALERT:
Dear Mr. $FNAME $LNAME, Your internet account ID [$USR] with Package of [$PKGNAME] has expired on $exp.
Please pay your dues to renew your account.

For furhter information & support you may reach us at our Helpline.

$COMPANY
Powered by Syed.Jahanzaib"

# SEND SMS via KANNEL to USERS about epxired account.
curl "$KURL/cgi-bin/sendsms?username=$KID&password=$KPASS&to=$mobile" -G --data-urlencode text@/tmp/$USR.sms

echo "Sleeping for 20 seconds to add delay in sms sending, to prevent your mobile SIM being blocked due to flooded sms"
sleep 20
done

Schedule it in cron ,
# Radius Manager expiry notification for today’s expired account Script

crontab -e
# add add following or as required.
@daily  /temp/sms2expiredusers.sh

Note: Some more testing need to be done, will do later and update this post.

Regard’s
Syed Jahanzaib

IBM Lotus Notes: Inbox Emails disappears when sort by DATE

Filed under: IBM Related, Uncategorized — Syed Jahanzaib / Pinochio~:) @ 9:14 AM

Today one of our company user faced strange issue in his lotus notes clients {8.5.3 FP6}.

When they just open the Inbox without any sorting, there is no problem and all mail shown. Once they try to sort the mails by ‘Date‘,  all emails in inbox view disappears.

After trying various things like refresh/replace design etc, we finally managed to sort the issue by running UPDALL on that specific db.

From the Domino Server Console  , Issue following command


load updall -R mail/USERDB.nsf

( -R : Rebuild All used views)

Fixed !

Jz!

 

%d bloggers like this: