XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum [Powered by Invision Power Board]
Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > XMail Queue Manager > Daemon Startup Script


Posted by: hschneider Mar 2 2004, 09:11 AM
CODE

#!/bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
#  This file should be used to construct scripts for /etc/init.d.
#
#  Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#  Modified by Harald Schneider <h_schneider@marketmix.com>
#
# Version: @(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#

# __Start_of_configuration__
#
# Place the path to your Agent's folder here:
#

AGENT_ROOT=/var/xqmagent

#
# __End_of_configuration__

LD_ASSUME_KERNEL="2.4.1"

PATH=$AGENT_ROOT:/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=$AGENT_ROOT/xqmagent
NAME=xqmagent
DESC="XQM Agent"

test -f $DAEMON || exit 0

set -e
ulimit -c 20000

start_agent()
{
 $DAEMON
}

stop_agent()
{
 killall -KILL $NAME
}

debug_agent()
{
 $DAEMON --debug
}


case "$1" in
 start)
     echo -n "Starting $DESC: "
     start_agent
;;
 stop)
     echo -n "Stopping $DESC: "
     stop_agent
     echo "Stopped!"
;;
 debug)
     echo "Debugging $DESC ... "
     debug_agent
;;
 restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC ... "
stop_agent
sleep 1
start_agent
;;
 *)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|debug}" >&2
exit 1
;;
esac

exit 0



Just adapt the Agent's path and go ..

Posted by: Sougent Jul 8 2004, 02:19 AM
Hi,

I need the idiots guide to setting up startup scripts, I've created a copy of this XQM startup script but I can't get it to work.

Could someone give me step by step instructions for where to put this script and how to set it up so that it will run automatically when I boot up at run level 3?

If you haven't guessed, I'm new at this Linux thing and though I kinda understand the whole thing, I guess I'm missing a piece because for the life of me I can't get this to work.

Thanks,

newbie.gif

Posted by: hschneider Jul 8 2004, 06:11 AM
In most distributions, this file (name it xqmagent) needs to go to
/etc/rc.d/init.d

cd /etc/rc.d/init.d
chmod 755 xqmagent
cd /etc/rc.d/rc3.d
ln -s /etc/rc.d/init.d/xqmagent S91xqmagent

Then reboot.

This creates a symbolic link in your runlevel folder, which points to the script.
The S91 prefix tells your system to start the agent right after XMail, which typically has S90 as prefix. The magic here is, that all filenames inside the runlevel folder are executed in alphabetical order.

Posted by: Sougent Jul 8 2004, 07:03 AM
QUOTE (hschneider @ Jul 8 2004, 06:11 AM)
In most distributions, this file (name it xqmagent) needs to go to
/etc/rc.d/init.d

cd /etc/rc.d/init.d
chmod 755 xqmagent
cd /etc/rc.d/rc3.d
ln -s /etc/rc.d/init.d/xqmagent S91xqmagent

Then reboot.

This creates a symbolic link in your runlevel folder, which points to the script.
The S91 prefix tells your system to start the agent right after XMail, which typically has S90 as prefix. The magic here is, that all filenames inside the runlevel folder are executed in alphabetical order.

Hi,

That worked, to a point, but it failed with a "no such file or directory" when it tried to come up on the reboot.

My xqmagent directory is /var/xqmagent, the AGENT_ROOT looks correct. Otherwise the script is exactly as posted here.

Any ideas?

Joe

Posted by: hschneider Jul 8 2004, 07:58 AM
cd /etc/rc.d/init.d
./xqmagent start

Any messages after this ?
Which OS and distribution do you use ?

Posted by: Sougent Jul 10 2004, 10:17 PM
QUOTE (hschneider @ Jul 8 2004, 07:58 AM)
cd /etc/rc.d/init.d
./xqmagent start

Any messages after this ?
Which OS and distribution do you use ?


: bad interpreter: No such file or directoory


Fedora Core release 1 (Yarrow)
Kernel 2.4.22-1.2194.nptl



Posted by: hschneider Jul 10 2004, 11:20 PM
This can mean several things. In fact the script cannot be executed.
Make sure that

- the 1st line of the script starts with #! and is not blank,
- that sh exists in your /bin folder and
- you don't use non-Unix lineendings in the case you've edited the script on Windows.

Posted by: Sougent Jul 11 2004, 02:29 AM
QUOTE (hschneider @ Jul 10 2004, 11:20 PM)
This can mean several things. In fact the script cannot be executed.
Make sure that

- the 1st line of the script starts with #! and is not blank,
- that sh exists in your /bin folder and
- you don't use non-Unix lineendings in the case you've edited the script on Windows.

Non-Unix line endings it was........

Everything works now except that when I run it from the command line it takes a good minute from the point it says Daemonized before it gives me back the command line.

Takes a long while when booting up too, but finally makes it through.

Thanks for your help.

wacko.gif

Posted by: hschneider Jul 11 2004, 08:53 AM
This delay can be supressed in the next version. It starts scanning the queue on teh very first startup, which can take some time depending on your hardware.

Posted by: dbatch Apr 11 2005, 05:40 PM
RedHat Fedora requires

The following two lines in the startup scripts

chkconfig

and

description

These are some example lines from my xmail rc script, it should be the same for xqm


#!/bin/sh
#
# chkconfig: 2345 80 30
# description: Xmail server
#
#

Posted by: hschneider Apr 11 2005, 07:43 PM
Thanks!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)