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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-19-2004, 06:49 PM
|
#1
|
|
Member
Registered: Sep 2003
Posts: 240
Rep:
|
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
|
|
|
|
02-19-2004, 07:01 PM
|
#2
|
|
LQ Newbie
Registered: Feb 2004
Location: Ireland
Distribution: Redhat 9
Posts: 12
Rep:
|
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)
|
|
|
|
02-19-2004, 07:15 PM
|
#3
|
|
Member
Registered: Sep 2003
Posts: 240
Original Poster
Rep:
|
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....
|
|
|
|
02-20-2004, 01:10 AM
|
#4
|
|
LQ Newbie
Registered: Aug 2003
Location: kadin, jkt
Distribution: Dolphin,Shrike,98
Posts: 20
Rep:
|
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
|
|
|
|
02-20-2004, 02:57 AM
|
#5
|
|
Member
Registered: Feb 2003
Location: The Attic. Nowhere near Texas.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Rep:
|
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.
|
|
|
|
02-20-2004, 11:47 AM
|
#6
|
|
Member
Registered: Sep 2003
Posts: 240
Original Poster
Rep:
|
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!!!
|
|
|
|
05-22-2004, 02:14 AM
|
#7
|
|
Member
Registered: May 2004
Distribution: Fedora
Posts: 71
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:41 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|