| View previous topic :: View next topic |
| Author |
Message |
SubAtomic Apprentice


Joined: 20 Dec 2003 Posts: 255 Location: Hobart, TAS, Australia
|
Posted: Sun Dec 04, 2005 5:07 am Post subject: adsl-start init script |
|
|
Ok, I got a bit sick of having to manually start my adsl connection using "adsl-start" whenever I shut down my machine or rebooted my router so I hacked up a little init script and thought it may be handy for others.
It aint pretty and I havent bothered with a conf.d file or checking for adsl-start pids or anything (infact it's downright dirty) so ymmv.
/etc/init.d/adsld
| Code: | #!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2
# Init script used to start/stop adsl connection
depend(){
need net
}
start() {
ebegin Starting adsl
start-stop-daemon --start --pidfile /var/run/adsld.pid --make-pidfile --exec /usr/sbin/adsl-start
eend $?
}
stop() {
ebegin Shutting down adsl
/usr/sbin/adsl-stop
start-stop-daemon --stop --quiet --pidfile /var/run/adsld.pid --name adsl-start
rm -f /var/run/adsld.pid
eend $?
}
status() {
ebegin adsl status
/usr/sbin/adsl-status
}
|
| Code: | rc-update add adsld default
|
_________________ "The real romance is out ahead and yet to come. The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas." -- Alan Kay
Last edited by SubAtomic on Sun Dec 04, 2005 9:53 am; edited 1 time in total |
|
| Back to top |
|
 |
timeBandit Administrator


Joined: 31 Dec 2004 Posts: 2667 Location: here, there or in transit
|
Posted: Sun Dec 04, 2005 5:48 am Post subject: |
|
|
Are you aware of the local service? It's provided to handle site-specific quirks of that sort. For your example, this would achieve the same result:
Add to /etc/conf.d/local.start: | Code: | # Bring up ADSL link
/usr/sbin/adsl-start |
Add to /etc/conf.d/local.stop: | Code: | # Drop ADSL link
/usr/sbin/adsl-stop |
As root: | Code: | | rc-update add local boot |
(You may find local is already in the boot runlevel; check first with rc-update show.)
The local.start and local.stop scripts can added to as required...easier than writing a separate init script for each special case you find. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
| Back to top |
|
 |
SubAtomic Apprentice


Joined: 20 Dec 2003 Posts: 255 Location: Hobart, TAS, Australia
|
Posted: Sun Dec 04, 2005 9:55 am Post subject: |
|
|
| timeBandit wrote: | | Are you aware of the local service? It's provided to handle site-specific quirks of that sort. |
Yeah .. I'm aware of that. But when playing with my router I just find it nice to be able to
| Code: | | /etc/init.d/adsl restart |
This makes the starting, stopping, restarting and checking status of "adsl-connect" a no brainer as it is always the same set of commands initiated all in the one place rather than having to add adsl-start/adsl-stop to local for boot purposes and having to execute /usr/sbin/adsl-start, /usr/sbin/adsl-stop, /usr/sbin/adsl-status when needing to do it manually (also a point to note is that my depend "need" requires net which in turn ensures: iptables, prelude-nids, prelude-lml, prelude-manager, snort, barnyard and portsentry are executed on my system). I find it easier for me to just execute this init script
Anyway, as I said, it's just a quick hack  _________________ "The real romance is out ahead and yet to come. The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas." -- Alan Kay |
|
| Back to top |
|
 |
konna n00b


Joined: 29 Jun 2005 Posts: 24 Location: Jõgeva, Estonia
|
Posted: Sun Mar 26, 2006 11:37 pm Post subject: |
|
|
Nice piece of script, damn I wonder why i wasn`t able to find it before. :S
Thank you very much lad. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|