LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 01-12-2007, 04:09 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
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
 
Old 01-12-2007, 04:55 AM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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
 
Old 01-12-2007, 05:21 AM   #3
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
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
 
Old 01-12-2007, 05:23 AM   #4
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
and if possible I need also alternative freebsd to

chattr +i

Thank you!!
 
Old 01-12-2007, 06:06 AM   #5
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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"
 
Old 01-12-2007, 01:15 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Moved: This thread is more suitable in *BSD and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 01-18-2007, 10:53 AM   #7
haxpor
Member
 
Registered: Dec 2006
Distribution: Ubuntu 20.04
Posts: 87

Rep: Reputation: 15
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.
 
Old 01-18-2007, 12:08 PM   #8
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
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.

Last edited by frob23; 01-18-2007 at 03:48 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Service script. bitpail Linux - Newbie 6 11-01-2006 05:00 PM
Service Settings problem satimis Linux - Distributions 1 10-13-2006 10:22 AM
problem in service er_gaurav22 Linux - Server 1 08-30-2006 02:07 AM
Telnet service problem sanjay2004 Linux - Networking 2 12-23-2004 08:31 PM
/sbin/service is empty every weekend and changed to service.1 LineS Linux - General 0 05-24-2004 02:08 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 08:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration