samba升级



    前提RHEL5.3 samba3.5.11
1.备份(service smb stop)
   #rsync -av /etc/samba/ /etc/samba.old/
   #cp /etc/init.d/smb /etc/init.d/smb.bak 
    检测一下原先的版本号 rpm -q samba(如果是rpm装的,不是的话用smbd -b)
2.编译安装新的源码包(samba-3.5.11)
#tar -xvf samba-3.0.37.tar.gz
   #cd samba-3.5.11
# cd source3
#./autogen.sh
   #./configure   --prefix=/usr/local/samba
   #make &&make install
   #cp -v /etc/samba/*.tdb /usr/local/samba/private/
   #cp -v /etc/samba/smb.conf /usr/local/samba/lib/
   #rm -rfv /etc/samba/
# ./bin/smbpasswd #测试一下,
 vi /etc/ld.so.conf
加入:/usr/local/samba/lib
然后运行#ldconfig
# yum remove system-config-samba (或rpm -e )
# yum remove samba
设置Samba路径
Samba默认是安装在/usr/local/samba,因此安装完成后,可能bin、sbin目录下的程序以及man无法使用。
解决办法:
a.修改/etc/profile (全局) 或者在.bash_profile,.bashrc 文件中加上对应路径(使用下面的脚本也是一个选择)
例如# vim ~/.bash_profile
PATH=$PATH:HOME/bin:/usr/local/samba/bin:/usr/local/samba/sbin
b.增加man手册
#vim /etc/man.config
MANPATH /usr/local/samba/share/man
MANPATH_MAP /usr/local/samba/bin /usr/local/samba/share/man
MANPATH_MAP /usr/local/samba/sbin /usr/local/samba/share/man 
修改samba服务启动脚本
#cp /etc/init.d/smb.bak /etc/init.d/smb
Vim smb (修改脚本)
#!/bin/sh
#
# chkconfig: - 91 35
# description: Starts and stops the Samba smbd and nmbd daemons \
#        used to provide SMB network services.
#
# pidfile: /usr/local/samba/var/locks/var/smbd.pid
# pidfile: /usr/local/samba/var/locks/nmbd.pid
# config:  /usr/local/samba/lib/smb.conf
# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 1
fi
# Avoid using root's TMPDIR
unset TMPDIR
# Source networking configuration.
. /etc/sysconfig/network
if [ -f /etc/sysconfig/samba ]; then
   . /etc/sysconfig/samba
fi
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
# Check that smb.conf exists.
[ -f /usr/local/samba/lib/smb.conf ] || exit 6
RETVAL=0
start() {
        KIND="SMB"
echo -n $"Starting $KIND services: "
daemon smbd $SMBDOPTIONS
RETVAL=$?
echo
        KIND="NMB"
echo -n $"Starting $KIND services: "
daemon nmbd $NMBDOPTIONS
RETVAL2=$?
echo
[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /usr/local/samba/var/locks/smbd.pid || \
   RETVAL=1
return $RETVAL
}
stop() {
        KIND="SMB"
echo -n $"Shutting down $KIND services: "
killproc smbd
RETVAL=$?
echo
KIND="NMB"
echo -n $"Shutting down $KIND services: "
killproc nmbd
RETVAL2=$?
[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /usr/local/samba/var/locks/smbd.pid
echo ""
return $RETVAL
}
restart() {
stop
start
}
reload() {
        echo -n $"Reloading smb.conf file: "
killproc smbd -HUP
RETVAL=$?
echo
return $RETVAL
}
rhstatus() {
status smbd
RETVAL=$?
status nmbd
RETVAL2=$?
if [ $RETVAL -ne 0 ] ; then
return $RETVAL
fi
if [ $RETVAL2 -ne 0 ] ; then
return $RETVAL2
fi
}
# Allow status as non-root.
if [ "$1" = status ]; then
       rhstatus
       exit $?
fi
# Check that we can write to it... so non-root users stop here
[ -w /usr/local/samba/lib/smb.conf ] || exit 4
case "$1" in
  start)
   start
;;
  stop)
   stop
;;
  restart)
   restart
;;
  reload)
   reload
;;
  status)
   rhstatus
;;
  *)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 2
esac
exit $?
加入服务 Chkconfig --add smb
修改bin的路径
 #!/bin/bash
for bin in `ls -1 /usr/local/samba/bin`
do
cp -bv /usr/local/samba/bin/$bin /usr/bin/
done

for sbin in `ls -1 /usr/local/samba/sbin`
do
cp -bv -s /usr/local/samba/sbin/$sbin /usr/sbin/
done

exit 0
此时
可以启动samba了
   Service smb start


本文出自 “Mylinux” 博客

相关内容

    暂无相关文章