dae - daemon control script - request for comments

Hi all,

I have created a small shell script called dae to help speed up the process of controlling system daemons. That is to make it quicker to stop / start / restart or otherwise interact with the system startup scripts.

The latest development version can be found at https://github.com/dylanbr/dae or there is an older version already in ports/sysutils/dae.

I'm looking for comments anyone may have regarding bugs, additional features or anything that would make this script more useful (without deviating too far from it's core purpose).

Thanks!

- Dylan
 
Thanks for the link SirDice - I'll definitely take a look but on first glance it doesn't look to be the same.

What I might need to do is add fsc support to dae.

To clarify: dae is only concerned with taking action over daemons -- it is a conveniant shorthand to allow one to perform these actions with the least amount of effort. It does have any monitoring capability. Where one would normally type something like "/usr/local/etc/rc.d/apache2 restart; /usr/local/etc/rc.d/mysql restart", one can type "dae apa= my=" instead.

Hope this helps to explain a little -- this is definitely not any sort of earth shattering change to the way things work -- just something for lazy people like me to speed things up a little ;)
 
dylanbr said:
To clarify: dae is only concerned with taking action over daemons -- it is a conveniant shorthand to allow one to perform these actions with the least amount of effort. It does have any monitoring capability. Where one would normally type something like "/usr/local/etc/rc.d/apache2 restart; /usr/local/etc/rc.d/mysql restart", one can type "dae apa= my=" instead.
Which is similar to the intended # fscadm enable apache
 
dylanbr said:
Thanks for the link SirDice - I'll definitely take a look but on first glance it doesn't look to be the same.

What I might need to do is add fsc support to dae.

To clarify: dae is only concerned with taking action over daemons -- it is a conveniant shorthand to allow one to perform these actions with the least amount of effort. It does have any monitoring capability. Where one would normally type something like "/usr/local/etc/rc.d/apache2 restart; /usr/local/etc/rc.d/mysql restart", one can type "dae apa= my=" instead.

Hope this helps to explain a little -- this is definitely not any sort of earth shattering change to the way things work -- just something for lazy people like me to speed things up a little ;)

You should install mksh. File completion works very well, so all you have to do is:
Code:
/u<tab>lo<tab>e<tab>rc<tab>po<tab> restart
to get
Code:
/usr/local/etc/rc.d/postfix restart
:)
 
A comparison:

If I'm reading the fscadm man page correctly, "fscadm enable apache" will enable service monitoring via fscd for your apache service and start it again if it dies but it will not restart the service if it is already running. From what I can see fscadm doesn't actually support a mechanism to force a restart - only to add monitoring.

"dae apa=" on the other hand will not enable any sort of service monitor, it will not check if the service is running, it will just send a "restart" to the closest matching script starting with "apa". This means I don't have to worry whether I'm running apache or apache2 or apache22, as long as the script starts with apa. It's also quicker to type which is great on slow lines. ( I'm from Africa, we're good at slow lines ;) ). And finally in my example I restart two services with a single command, another time saver.

I feel I should stress again -- this is about minimising the input and knowledge needed to accomplish the action. One could probably accomplish the same thing by using a set of aliases or some shell expansion. I decided to rather go for a shell script to do the job.

It looks like both are great tools for managing whatever is running on your system -- but they service two different purposes. I can envisage using fscd to make sure apache keeps running but using dae to restart it if I need to change the configuration file.
 
killasmurf86 said:
You should install mksh. File completion works very well, so all you have to do is:
Code:
/u<tab>lo<tab>e<tab>rc<tab>po<tab> restart
to get
Code:
/usr/local/etc/rc.d/postfix restart
:)

22 characters vs. 8 for "dae pos=" -- you are obviously not near as lazy as I am! :h

Thanks for the comment.
 
killasmurf86 said:
You should install mksh. File completion works very well, so all you have to do is:
Code:
/u<tab>lo<tab>e<tab>rc<tab>po<tab> restart
to get
Code:
/usr/local/etc/rc.d/postfix restart
:)

No need for mksh, this works on tcsh, csh and bash too ;)
 
Ye I know, but I like how it works on mksh [much better]
In danger of straying widely off-topic here, but I'd like to ask why?
(Seriously, I've never used it so I'm curious as to how completion works much better in mksh)

And btw, in FreeBSD tcsh==csh.
 
jalla said:
In danger of straying widely off-topic here, but I'd like to ask why?
(Seriously, I've never used it so I'm curious as to how completion works much better in mksh)

And btw, in FreeBSD tcsh==csh.

1) it's faster to press single tab, than Ctrl+D
2) if I enter 1 character and hit tab, I will see all available commands
3) if I neter part of path, that matches other directories (for example /usr/l) and hit enter it will show all matching directories, so I can pick faster.... [t?csh feels much different there]

There are some situations, where completion in t?csh isn't as good as mksh... But I don't remember exact case, so I can't tell you... however when you work with bough of them (I do), then you notice the difference.
You really need to try... to see... anyway, t?csh completion is good enough....

btw, you don't need to rehash mksh :) (I like it)
 
Trying not to take it even further off topic
jalla said:
And btw, in FreeBSD tcsh==csh.
Correct. It's the same executable (one is a hardlink to the other) but they do behave differently.
 
Dylanbr, you can also use the already installed utilities from the base distribution.
1. rcstart -- starts a service.
2. rcorder -- print out a dependency ordering of a set of interdependent files.
3. rcrestart -- restarts a service, symlinked to rcstart.
4. rcstatus -- gives the status of services, symlinked to rcstart.
5. rcstop -- stops a service, symlinked to rcstart.
 
Sorry Dylanbr, my mistake. I found them on the net. I've been using them far to long and just forgot about it. Here's the copyright from the scripts.

Here's the output of 'uname -a'.
Code:
FreeBSD rbserver.umsmed.edu 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

# Copyright (c) 2006-2009
# Dominic Fandrey <kamikaze@bsdforen.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Dominic does maintain the /usr/ports/sysutils/bsdadminscripts package. I will see if he still supports them for FreeBSD and if he does I'll upload them to my web site.
 
Actually, they're all quite usefull. And most I didn't even know about :\

I personally like fsc. Now lets see if I can break a ten year old habit :)
 
wblock said:
Odd that nobody has mentioned service(8) yet.

# service apache22 restart
# service devfs restart

rbelk said:
OK Guys, they are in the bsdadminscripts port. So install it and your good to go.

SirDice said:
Actually, they're all quite usefull. And most I didn't even know about :\

I personally like fsc. Now lets see if I can break a ten year old habit :)

Thanks for all the great feedback guys!

It is very interesting to see the growth in functionality in this area. I do hope that eventually we end up with something that is standardised across the entire BSD ecosystem.

Personally what I'd like to see is the service monitoring of fsc coupled with the ability of service (or the rc* utilities) to report on the ordering and activation status and finally the shortcuts and globbing I've put into dae. That would give me confidence that once I start a service it stays running but also let me make changes quickly and easily.

Exciting times. :e
 
Back
Top