DrJohnZoidberg
Honorary Master
- Joined
- Jul 24, 2006
- Messages
- 23,995
I recently moved over to an afterhours account because I'm not really ever at home before 7pm. The only problem is that the after hours uncapped account is throttled to 192kbps during the day which is pretty useless if I want to ssh or ftp remotely or if I am at home that day and want to browse around.
The solution: use my free afrihost gig for during the day and then switch over at 7pm to the after hours account - this would be a mission to do in the router the whole time (if only my router could do this) so I decided to write a simple bash script to do it for me. I also have a cronjob running which will switch accounts automatically while I'm logged on.
The script connects with the normal capped account if its between 7am and 7pm on a weekday and connects to the after hours account if its after 7pm and on weekends.
Anyway here is the startup script, maybe somebody else finds it useful (or can improve on it):
I haven't actually tested it very much so it may not even work properly. Hehe, I will update as I use it during the week.
Remember this is only a start up script, I am also using a cronjob to switch over while the pc is on (that script is still very messy, so don't want to post it here yet).
Hope somebody finds this useful!
EDIT: Oh yes, this must be run as root, so you would place it in a root crontab with the @reboot flag.
The solution: use my free afrihost gig for during the day and then switch over at 7pm to the after hours account - this would be a mission to do in the router the whole time (if only my router could do this) so I decided to write a simple bash script to do it for me. I also have a cronjob running which will switch accounts automatically while I'm logged on.
The script connects with the normal capped account if its between 7am and 7pm on a weekday and connects to the after hours account if its after 7pm and on weekends.
Anyway here is the startup script, maybe somebody else finds it useful (or can improve on it):
Code:
#!/bin/bash
nowtime=$(date +%H%M)
nowday=$(date +%w)
starttime=700
endtime=1900
normalaccountname='dsl-provider'
afterhoursaccountname='afterhours'
if ifconfig | grep ppp > /dev/null
then
echo "PPPOE connection already active!"
exit
else
if [ "$nowday" -ge "1" ] && [ "$nowday" -lt "6" ]
then
if [ "$nowtime" -ge "$starttime" ] && [ "$nowtime" -le "$endtime" ]
then
pon $normalaccountname
echo "Weekday between $starttime and $endtime"
else
pon $afterhoursaccountname
echo "Weekday between $endtime and $starttime"
fi
else
pon $afterhoursaccountname
echo Weekend Baby!
fi
fi
I haven't actually tested it very much so it may not even work properly. Hehe, I will update as I use it during the week.
Remember this is only a start up script, I am also using a cronjob to switch over while the pc is on (that script is still very messy, so don't want to post it here yet).
Hope somebody finds this useful!
EDIT: Oh yes, this must be run as root, so you would place it in a root crontab with the @reboot flag.
Last edited: