Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
adsl-start init script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
SubAtomic
Apprentice
Apprentice


Joined: 20 Dec 2003
Posts: 255
Location: Hobart, TAS, Australia

PostPosted: Sun Dec 04, 2005 5:07 am    Post subject: adsl-start init script Reply with quote

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
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2674
Location: here, there or in transit

PostPosted: Sun Dec 04, 2005 5:48 am    Post subject: Reply with quote

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
View user's profile Send private message
SubAtomic
Apprentice
Apprentice


Joined: 20 Dec 2003
Posts: 255
Location: Hobart, TAS, Australia

PostPosted: Sun Dec 04, 2005 9:55 am    Post subject: Reply with quote

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
View user's profile Send private message
konna
n00b
n00b


Joined: 29 Jun 2005
Posts: 24
Location: Jõgeva, Estonia

PostPosted: Sun Mar 26, 2006 11:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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