Chinaunix首页 | 论坛 | 博客
  • 博客访问: 54473
  • 博文数量: 27
  • 博客积分: 930
  • 博客等级: 准尉
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 14:30
文章存档

2010年(27)

我的朋友

分类: LINUX

2010-03-29 17:34:23

一 配置服务器流程如下

 

二 配置服务器过程

    首先查找samba的守护进程是否存在,若不存在,则安装samba软件(当然,前提是在某文件夹下存放了samba的安装软件,在这里将安装软件samba-3.0.25b.tar.gz与当前脚本文件放在同一文件夹下)。然后,清除防火墙规则,并启动samba服务器。

    在后面还给了一个简单的用以更新samba服务器配置的脚本。

#!/bin/bash

echo "set samba server for sharing document with Widows in local net"

smbserverfolder=/etc/init.d 

 #./smb

smbexefolder=/usr/sbin/     

 #./smbd ./nmbd

 

smbfolder=/etc/samba

smb=/etc/samba/smb.conf

#Samba have two server ---  smbd nmbd

if [ -r $smbfoler ] && [ -f $smb ] ; then 

echo "samba server has been installed, and will be opened"

else

echo "can't read $smbfolder or samba don't exist"

echo "install samba server ....."

#

#install samba server step...

#

smbdir=samba-3.0.25b

smbfile="$smbdir.tar.gz"

cp  "./$smbfile"  /tmp

cd /tmp

tar -zxvf "/tmp/$smbfile"

cd "./$smbdir/source"

./configure

make clean

make install

fi

 

#清除防火墙规则

echo "clear iptables rules....."

/sbin/iptables -F

 

echo "open samba server......"

#pgrep smbd -- pkill smbd ;pgrep nmbd -- pkill nmbd

/usr/sbin/smbd

/usr/sbin/nmbd

 

#查找是否有更新samba配置的脚本,若有则执行

if [ -f "./smb.confshare" ];then

echo "add share folder... and update samba setting ... "

./smb.confshare

else

echo "no script to add sharefolder , please manually add "

fi

 

#查找是否有用以挂载samba服务器的脚本,若有则执行

if [ -f "./smb.mounthosts" ];then

echo "mount all honts in this local net"

./smb.mounthosts

else

echo "no script to mount sharefolder ,please manually mount "

fi

 

 

-------------------------------------------------------------------

下面这个脚本名为smb.confshare,用以修改samba配置文件

 

#!/bin/bash

 

smbfolder=/etc/samba

smbconf=smb.conf

sharefolder=/home/sharedoc

 

 

echo "++++++++++++++++build share directory+++++++++++++++"

echo "/home/sharedoc"

echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"

#build a share doc in own host

if ( ! [ -d "$sharefolder" ]);then mkdir  "$sharefolder" ; fi

id nobody

chown -R nobody:nobody "$sharefolder"  

 

#set configure in samba for sharing directory

if [ -r "$smbfolder" ]; then

cd "$smbfolder"

mv "$smbconf" smbOLD.conf

cat > $smbconf << "EOF"

#++++++++++++write grant to smb.conf++++++++++++

[global]

workgroup = LinuxSir

server string = linux samba server

security = share

[linuxsharedoc]

path =$sharefolder

browseable = yes

guest ok = yes

writeable = yes

EOF

 

阅读(393) | 评论(0) | 转发(0) |
0

上一篇:Qt安装

下一篇:getopts函数及使用

给主人留下些什么吧!~~