LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   service problem (https://www.linuxquestions.org/questions/%2Absd-17/service-problem-518592/)

graziano1968 01-12-2007 04:09 AM

service problem
 
hello

on a my friend server if I execute

service exim start
or
service exim stop

does not work , because doesn't recognize "service" command

On my server I use service command daily

How to activate service command on his server too ?
He has a freebsd server.


Thank you

reddazz 01-12-2007 04:55 AM

The service command is only available on Redhat based distributions and derivates. YOu should be able to manage exim by doing something like
Code:

#/usr/local/etc/rc.d/exim start/stop/reload/status/restart

graziano1968 01-12-2007 05:21 AM

Thank you I didn't know it

I noticed that also
chkconfig --add exim

is not avaialble on freebsd

How to add or remove a service on frebsd from startup list if chkconfig is not avaialble ?

Thank you

graziano1968 01-12-2007 05:23 AM

and if possible I need also alternative freebsd to

chattr +i

Thank you!!

reddazz 01-12-2007 06:06 AM

Quote:

Originally Posted by graziano1968
Thank you I didn't know it

I noticed that also
chkconfig --add exim

is not avaialble on freebsd

How to add or remove a service on frebsd from startup list if chkconfig is not avaialble ?

Thank you

You need to read the FreeBSD Handbook. To add services at boot up, edit /etc/rc.conf and add something like
Code:

exim_enable="YES"

david_ross 01-12-2007 01:15 PM

Moved: This thread is more suitable in *BSD and has been moved accordingly to help your thread/question get the exposure it deserves.

haxpor 01-18-2007 10:53 AM

May be if we write our own program that act like 'service' and then set PATH to its execute path for System, that could be better. But at this point I am not sure about setting PATH so I can offer only the familiar code only.:)

Code for C Program could be something like below.

Note: Save file as service.c
Compile with: cc -o service.out service.c
Execute with: ./service.out [start/stop/restart]
include<stdio.h>
int main(int argc, char *argv[]){
//Start exim
if(strcmp(argv[0],"start")){
system("/usr/local/etc/rc.d/exim start");
}
//Stop Exim
else if(strcmp(argv[0],"stop")){
system("/usr/local/etc/rc.d/exim stop");
}
//Restart Exim
else if(strcmp(argv[0],"restart")){
system("/usr/local/etc/rc.d/exim stop");
system("/usr/local/etc/rc.d/exim start");
}
//If the program have more parameter then add your code here..
//..
return 0;
}

Hope it's useful to you all.
If has any method for setting Path to the above program tell me too.
Thanks.

frob23 01-18-2007 12:08 PM

We could use a shell script (it would be more flexible) and we don't even need to complicate it with much at all.

Call this script service:
Code:

#!/bin/sh
# Service wrapper for services... more linux-like.

PATHS="/etc/rc.d/* /usr/local/etc/rc.d/*"

if [ "x" = x"${1}" ]; then
        echo "You need to include a service name, and more commonly, a request."
        exit 1;
fi

SERVNAME=`rcorder ${PATHS} | grep "${1}"`

shift

${SERVNAME} ${@}

I haven't fully tested this... being at work. But it should work or some minor variation would. And you can put it in /usr/local/sbin and then call it like you'd normally would call service (which I admit to never using).

The scripts themselves handle the parsing of the arguments so we don't need to. We just locate the correct script and pass it the arguments. It saves you from having to type the path or locate the script... but I personally don't see it as reducing the complexity... it's just as easy to type the path.


All times are GMT -5. The time now is 02:04 AM.