LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-19-2004, 06:49 PM   #1
t3___
Member
 
Registered: Sep 2003
Posts: 240

Rep: Reputation: 30
Samba at startup


My objective is to get samba and nmbd to start automatically at boot time.

I ran a search on the forums here, and found a thread indicating that samba usually installs with a startup script that can be placed in /etc/init.d to make all smb related services active at startup.

After searching I found that I do indeed have a file called "smb" (no quotes though) in my /etc/init.d folder - I pasted the contents of the file below.

QUESTION - is this file the samba startup script that previous thread was refering to? And if so, why is samba and nmbd NOT starting at boot time.... Im guessing that I need to uncomment some lines in the script??? Which lines... or all? Please advise.

Any help would be greatly appreciated. Also, if anyone has a different approach to starting samba at boot, I would love to understand any alternatives as well.

~~~~~~~~~~~~~~~~~~~~
here is the file
~~~~~~~~~~~~~~~~~~~~

#! /bin/sh
# Copyright (c) 1999-2003 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Lars Mueller <lmuelle@suse.de>
#
# /etc/init.d/smb
# and its symbolic link
# /usr/sbin/rcsmb
#
### BEGIN INIT INFO
# Provides: smb
# Required-Start: $network $remote_fs syslog
# X-UnitedLinux-Should-Start: cupsd winbind nmb
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: Samba SMB/CIFS file and print server
### END INIT INFO

DAEMON_DIR="/usr/lib/samba/"
SMBD_BIN="smbd"
SMB_CONF="/etc/samba/smb.conf"
SYSCONFIG_FILE="/etc/sysconfig/samba"
PID_FILE="/var/run/samba/smbd.pid"
SAM_STATE_FILE="/var/run/samba/samsmbd.state"

# Status shell functions
. /etc/rc.status
# Reset status of this service
rc_reset

# Check for existence of needed config files.
for configfile in ${SMB_CONF} ${SYSCONFIG_FILE}; do
if [ ! -f ${configfile} ]; then
echo -n "Samba configuration file ${configfile} does not exist. "
# Tell the user this has skipped
rc_status -s
exit 6
fi
done

# Source Samba settings
. ${SYSCONFIG_FILE}

BIN_SUFFIX=$( echo ${SAMBA_SAM} | tr '[:upper:]' '[:lower:]')
# If a wrong or no BIN_SUFFIX is set, warn the user and set a default.
if [ x"${BIN_SUFFIX}" != x"classic" -a x"${BIN_SUFFIX}" != x"ldap" ]; then
echo "Unknown Samba Security Authentication Mechanism, ${SAMBA_SAM}."
echo "Please fix the sysconfig setting. Using default, classic for now."
BIN_SUFFIX="classic"
fi

# Get current sam if a state file exists.
test -f ${SAM_STATE_FILE} && \
curr_sam=$( cat ${SAM_STATE_FILE}) || \
curr_sam=${BIN_SUFFIX}

# Check for missing binary
if [ ! -x ${DAEMON_DIR}${BIN_SUFFIX}/${SMBD_BIN} ]; then
echo -n "Samba daemon, ${DAEMON_DIR}${BIN_SUFFIX}/${SMBD_BIN} is not installed. "
# Tell the user this has skipped
rc_status -s
exit 5
fi

# wait for cupsd to be ready
function wait_for_cupsd
{
echo -n "Samba SMB: Waiting for cupsd to get ready"
SAMBA_CUPSD_TIMEOUT=30
rc_timer_on ${SAMBA_CUPSD_TIMEOUT} 42
for ((i=0; i<${SAMBA_CUPSD_TIMEOUT}; i++)); do
if lpstat -r &>/dev/null; then continue
else sleep 1
fi
done
rc_timer_off

lpstat -r &>/dev/null && rc_status -v || rc_status -s
rc_reset
}

# check and create TDB
function check_create_tdb
{
test -f /var/lib/samba/$1.tdb || \
echo "create /var/lib/samba/$1.tdb" | /usr/lib/samba/tdbtool >/dev/null
}

# be extra carefull cause connection fail if TMPDIR is not writeable
export TMPDIR="/var/tmp"

case "$1" in
start)
if grep -qi '^[[:space:]]*printing[[:space:]]*=[[:space:]]*cups' ${SMB_CONF} && chkconfig --check cups; then
wait_for_cupsd
fi
if [ ${BIN_SUFFIX} != ${curr_sam} ]; then
echo -n "Samba ${curr_sam} SMB daemon might run; I will try to stop it first. "
killproc -p ${PID_FILE} ${DAEMON_DIR}${curr_sam}/${SMBD_BIN}
rc_status -v
fi
echo -n "Starting Samba ${BIN_SUFFIX} SMB daemon "
checkproc -p ${PID_FILE} ${DAEMON_DIR}${BIN_SUFFIX}/${SMBD_BIN} && \
echo -n " Warning: daemon already running. "
check_create_tdb brlock
check_create_tdb locking
startproc -p ${PID_FILE} ${DAEMON_DIR}${BIN_SUFFIX}/${SMBD_BIN} -D -s ${SMB_CONF}
rc_status -v
echo ${BIN_SUFFIX} >${SAM_STATE_FILE}
;;
stop)
echo -n "Shutting down Samba ${curr_sam} SMB daemon "
checkproc -p ${PID_FILE} ${DAEMON_DIR}${curr_sam}/${SMBD_BIN} || \
echo -n " Warning: daemon not running. "
killproc -p ${PID_FILE} ${DAEMON_DIR}${curr_sam}/${SMBD_BIN}
rc_status -v
rm -f ${SAM_STATE_FILE}
;;
try-restart)
$0 status >/dev/null && $0 restart
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 reload
rc_status
;;
reload)
echo -n "Reloading Samba ${curr_sam} SMB daemon "
checkproc -p ${PID_FILE} ${DAEMON_DIR}${curr_sam}/${SMBD_BIN} || \
echo -n " Warning: daemon not running. "
killproc -p ${PID_FILE} -HUP ${DAEMON_DIR}${curr_sam}/${SMBD_BIN}
rc_status -v
;;
status)
echo -n "Checking for Samba ${curr_sam} SMB daemon "
checkproc -p ${PID_FILE} ${DAEMON_DIR}${curr_sam}/${SMBD_BIN}
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit
 
Old 02-19-2004, 07:01 PM   #2
wi77ard
LQ Newbie
 
Registered: Feb 2004
Location: Ireland
Distribution: Redhat 9
Posts: 12

Rep: Reputation: 0
If you are running redhat 9, i know how ............

goto start aplications (kde) / gnome menu

then system settings, then server settings

and choose services.

this will open a new window with loads of check boxes, scroll down until you find smb and make sure it has a tick in its box. once done save using the menu file -> save and then quit and reboot your system. This should automatically start smb.

hope this helps (hope you use Redhat lol)
 
Old 02-19-2004, 07:15 PM   #3
t3___
Member
 
Registered: Sep 2003
Posts: 240

Original Poster
Rep: Reputation: 30
nope, as my signature indicated, im on Suse 9.0.

Furthermore I am particularly intersted in understand what is "under the hood" as opposed to a shortcup method.

thanks nonetheless....
 
Old 02-20-2004, 01:10 AM   #4
levian
LQ Newbie
 
Registered: Aug 2003
Location: kadin, jkt
Distribution: Dolphin,Shrike,98
Posts: 20

Rep: Reputation: 0
Hi,
In which run level you would like samba to run?
The smb script in /etc/init.d only defines on "how" the smb service would like to start, stop, or restart.
To start the smb service on particular run level simply make a symlink in /etc/rc?.d to the smb script in /etc/init.d. The symlink should begin with S (whereas K will stop the service) followed by two digits number that will provide a mechanism to select the priority in which the program will run.

For example if we would like smb to start at runlevel 5 :
#ln -s /etc/init.d/smb /etc/rc5.d/S91smb

Im still a beginner, though, so i may make a mistake also. cheers
 
Old 02-20-2004, 02:57 AM   #5
TexasDex
Member
 
Registered: Feb 2003
Location: The Attic. Nowhere near Texas.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133

Rep: Reputation: 15
Explanation of runlevels: At different runlevels your computer enables different services. You can customize it so that your computer runs the SMBD service only while in mode 3 (console) or you can add it to both 3 and 5 (the most commonly used runlevels)

Runlevel 0: Halt
Runlevel 1: Single user - no services
Runlevel 2: other (custom)
Runlevel 3: typically console mode
Runlevel 4: other (custom)
Runlevel 5: X11 (GUI) mode
Runlevel 6: Reboot

Levian's explanation on how to add a service to a runlevel looks right--i havn't done it in a while.
 
Old 02-20-2004, 11:47 AM   #6
t3___
Member
 
Registered: Sep 2003
Posts: 240

Original Poster
Rep: Reputation: 30
Wow... thanks everyone for the replies....

Ok, so I understand that I must make a symlink (somewhere) in the /etc/rc.d/rc#.d folder... I want samba to run all the time (in gui and runlevel 3), so I must create 2 symlinks, right?

my other question now is how on earth would I chose a number for the "priority"? I havent a clue what priority I would like this to run at... is there a default value for this field.

Also... can someone verify the syntax on the command that levian noted for me?

THANKS EVERYONE!!!
 
Old 05-22-2004, 02:14 AM   #7
Linner
Member
 
Registered: May 2004
Distribution: Fedora
Posts: 71

Rep: Reputation: 15
levian syntax is right.

#ln -s /etc/init.d/smb /etc/rc[runlevel].d/S[priority]smb

with regards to priority, i have noticed that when you view the those init.d script file, there is entry for chkconfig. i think thats the priority numbers.

well, i havent tried it...newbie too. ;-) goodluck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
startup and samba nick021 Linux - Newbie 3 04-17-2005 02:30 PM
samba startup at boot snocked Slackware 5 10-07-2003 10:03 AM
Starting Samba at startup rwelch Linux - General 4 03-17-2003 11:10 PM
How can I start Samba on startup? bripage Linux - Networking 6 07-31-2002 03:30 PM
Samba startup on boot. bripage Linux - General 6 07-28-2002 10:00 PM


All times are GMT -5. The time now is 05:52 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration