# TestExtStor.sh: test whether external memory is present (mounted)
# send mail and/or SMS when something is missing
# (c) jada4p 2023
# send as SMS to my mobile phone via mail to myself and gmail filter
# sending it to my address at post.cz where it is forwarded to mobile
# operator's SMS gate
# it seems that Vodafone terminated possibility of sending SMS by mail
# inspired by @JardaB request and loss of one of USB flash after reboot
# based on use of "df" and some other scripts
# commands 'df | grep "^/dev/s" | wc -l' return '0' when no external
# memory was found, otherwise count of them
# TestExtStor.sh -m send mail
# -s send SMS
# -b send both mail and SMS
# -i display usage
# usage: default mode is "m" - changed from prior 'b' due to troubles
# at Vodafone ISP
M="M"
for i
do
case $i in
-m) # send mail
M="M"
shift
;;
-s) # send SMS
M="S"
shift
;;
-b) # send both
M="B"
shift
;;
-i) # display usage
echo "TestExtStor.sh -m send mail"
echo " -s send SMS"
echo " -b send both mail and SMS"
echo " -i display usage"
echo "default mode is 'm'"
exit
;;
*) # error, display usage
if [ "$i" == "" ]
then continue
else
echo "invalid parameter: '$i', usage:"
/root/TestExtStor.sh -i
exit
fi
;;
esac
done
C=2 # number of external storage units used
N=`df | grep "^/dev/s" | wc -l` # found N units
if [ $N = $C ]
then
# echo "OK - (all) external memory unit(s) found"
exit
else
# echo "BAD - some external memory unit(s) missing"
MSG=`df`
SMS="Router TOjp - external storage error"
if [ "$M" == "B" -o "$M" == "M" ]
then
# echo "sending mail"
echo -e "Subject: $SMS\n\n$MSG" | msmtp root
if [ "$M" != "M" ]
then
# echo "sending SMS"
echo -e "Subject: SMS\n\n$SMS" | msmtp root
fi
else
if [ "$M" == "S" ]
then
# echo "sending SMS"
echo -e "Subject: SMS\n\n$SMS" | msmtp root
else
echo "wrong mode $M, see usage"
/root/TestExtStor.sh -i
exit
fi
fi
fi
You have to change value of variable C to correspond count of your units… As to possibility of sending SMS, I have to ask Vodafone where the problem is…
I used to use Vodafone (Czech) mail to SMS service. Unfortunately they cancelled it recently due to economic reasons. They said it was used by small number of users only.
It’s a pity. It was handy.
As far as I know T-Mobile had similar service, but I don’t know its current status, neither I know whether O2 has it.