topmusic
Occasional Visitor
Oke my situation.
I have a mailserver running, and to get access for all users i have created a little scripts that resolves from a no-ip dynamic host to ip.
Then the ip-address is always add to the whitelist (running a cron every hour) so the users will always get access to read there email.
Now i want to adjust the script that it first check in the whitelist if its there, if so then end the script and update the log.
If its not there, then add it and write to the log also
the first little script.
Finally i have something like this, but ill get an error when running.
The error ill get is ;
root# /jffs/scripts/test-update.sh
-> RT-AX86U-Pro ip-update
[: bad number
Can someone help me with that tot get it running correctly ?
Regards
I have a mailserver running, and to get access for all users i have created a little scripts that resolves from a no-ip dynamic host to ip.
Then the ip-address is always add to the whitelist (running a cron every hour) so the users will always get access to read there email.
Now i want to adjust the script that it first check in the whitelist if its there, if so then end the script and update the log.
If its not there, then add it and write to the log also
the first little script.
Code:
#!/bin/sh
VER="v1.01a"
# - Cron job or in init-start
# - /usr/sbin/cru a IPUPDATE "0 * * * * /jffs/scripts/update-ip.sh" #Every hour
# - Check ip firewall - /jffs/scripts/firewall stats search ip 82.75.62.105 10
# - Check ip ipset - /usr/sbin/ipset list Skynet-Whitelist |grep -c 82.75.62.105
log_file="/tmp/mnt/RT-AX86U/log/emailname.log"
SCRIPT_PATH="/jffs/scripts/firewall"
now=$(date +%d-%m-%Y/%H:%M)
# User = emailname
IP=$(kdig +short ddnsname.hopto.org @resolver1.opendns.com)
echo " -> RT-AX86U-Pro ip-update"
echo "[$now]=[$IP]" >> ${log_file}
(exec "$SCRIPT_PATH" whitelist ip $IP)
Finally i have something like this, but ill get an error when running.
Code:
#!/bin/sh
VER="v1.01a"
# - Cron job or in init-start
# - /usr/sbin/cru a IPUPDATE "0 * * * * /jffs/scripts/update-ip.sh" #Every hour
# - Check ip firewall - /jffs/scripts/firewall stats search ip 82.75.62.105 10
# - Check ip ipset - /usr/sbin/ipset list Skynet-Whitelist |grep -c 82.75.62.105
log_file="/tmp/mnt/RT-AX86U/log/emailname.log"
SCRIPT_PATH="/jffs/scripts/firewall"
now=$(date +%d-%m-%Y/%H:%M)
# User = emailname
IP=$(kdig +short ddnsname.hopto.org @resolver1.opendns.com)
echo " -> RT-AX86U-Pro ip-update"
if [ "$(/jffs/scripts/firewall whitelist view | grep -c "$IP")" = 0 ] ; then
echo "ERROR - $IP is NOT in Whitelist"
(exec "$SCRIPT_PATH" whitelist ip $IP)
echo "$IP is Added to the Whitelist"
echo "[$now]=[$IP]" >> ${log_file}
fi
if [ "$IP" -eq = "1" ] ; then
echo "NEW $IP is already in the whitelist]"
echo "[$now]=[$IP]" >> ${log_file}
fi
The error ill get is ;
root# /jffs/scripts/test-update.sh
-> RT-AX86U-Pro ip-update
[: bad number
Can someone help me with that tot get it running correctly ?
Regards