Smb.conf:
[nagios@nagios scripts]# cat config.txt #This file is smaba server configuse. [global] workgroup = MYGROUP server string = Samba Server Version %v security = share passdb backend = tdbsam load printers = yes cups options = raw [samba] comment=Temporary file space path=/samba read only=no public=yes
Scripts:
[nagios@nagios scripts]# cat samba_install.sh #!/bin/sh ####################################################### #Author: Created by randolph 2016-02 #Blog:http://randolph.blog.51cto.com #Function: This scripts function is Install samba_server #Version:4.1.2 ####################################################### #Source function library. . /etc/init.d/functions SHARE=/samba RPM_SUM=`rpm -qa|grep samba|wc -l` #Require root to run this script. uid=`id|awk -F "[=(]+" '{print $1}'` if [ $uid -ne 0 ];then action "Please run this script as root." /bin/false exit 1 fi [ -d $SHARE ] || { mkdir $SHARE } chmod 777 $SHARE #Check the current system installation package. if [ $RPM_SUM -ne 0 ]; then for packge in `rpm -qa|grep samba` do rpm -e --nodeps $packge rm -fr /etc/samba/smb.* done yum install -y samba else yum install -y samba fi #Configure the service. cp /etc/samba/smb.conf /etc/samba/smb.conf.$(date +%F)bak #egrep -v "#|^$|^;" /etc/samba/smb.conf.bak >/etc/samba/smb.conf >/etc/samba/smb.conf while read line do echo $line >>/etc/samba/smb.conf done<config.txt [ $? -ne 0 ] && { echo "please check configure." exit 1 } #start server. /etc/init.d/smb restart lsof -i:139
转载于:https://blog.51cto.com/zhagyilig/1866406