opensamba.sh

来源:互联网 发布:java接口对于耦合实例 编辑:程序博客网 时间:2024/06/03 17:14
#!/bin/bashsmbconf=/etc/samba/smb.confbak=".bak"ifredhat=$(cat /proc/version | grep redhat)ifcentos=$(cat /proc/version | grep centos)ifubuntu=$(cat /proc/version | grep ubuntu)ifdebian=$(cat /proc/version | grep -i debian)ifgentoo=$(cat /proc/version | grep -i gentoo)ifsuse=$(cat /proc/version | grep -i suse)if [ `uname -m` == "x86_64" ];thenmachine=x86_64elsemachine=i686fihelpFun(){cat<<help    usage:$0[-o|-c|-h]    eg:$0[*|-o] #open sambahelp    exit 0;}openSmbFun(){if [ -e "$smbconf$bak" ];then    if [ -e "$smbconf" ];then        rm "$smbconf"    fi    cp "$smbconf$bak" "$smbconf"else    cp "$smbconf" "$smbconf$bak"fi/bin/echo "[opt]    comment = opt    path = /opt    writable = yes" >> "$smbconf"echo -e "\033[32;1m Samba:password for root\033[0m"#add root usersmbpasswd -a root#smb start if [ "$ifubuntu" != "" ];thenservice smbd start    echo -e "\033[36;1m Opened Success. \033[0m"elif [ "$ifsuse" != "" ];then    /etc/init.d/smb start    echo -e "\033[36;1m Opened Success. \033[0m"elif [ "$ifcentos" != "" ];thensystemctl start smb.service#防火墙 添加规则firewall-cmd --permanent --zone=public --add-service=sambafirewall-cmd --reload    echo -e "\033[36;1m Opened Success. \033[0m"else    echo -e "\033[31;1m not support \033[0m"    exit 0;fiexit 0;}closeSmbFun(){#close root usersmbpasswd -d root#smb stopif [ "$ifubuntu" != "" ];thenservice smbd stopelif [ "$ifsuse" != "" ];then    /etc/init.d/smb stopelif [ "$ifcentos" != "" ];thensystemctl stop smb.serviceelse    echo -e "\033[31;1m not support?\033[0m"    exit 0;fi#del smb.confif [[ -e "$smbconf" ]];then    rm "$smbconf"fiecho -e "\033[36;1m Closed Success. \033[0m"exit 0;}test1(){echo  -e "\033[31;1m 31 \033[0m"echo  -e "\033[32;1m 32 \033[0m"echo  -e "\033[33;1m 33 \033[0m"echo  -e "\033[34;1m 34 \033[0m"echo  -e "\033[35;1m 35 \033[0m"echo  -e "\033[36;1m 36 \033[0m"echo  -e "\033[37;1m 37 \033[0m"echo  -e "\033[38;1m 38 \033[0m"echo  -e "\033[39;1m 39 \033[0m"}#--------------------------------------------------------#if [ "$1" = "-c" ] || [ "$1" = "-h" ];then    op="$1"else    op="-o"ficase "$op" in    -o) openSmbFun ;;    -c) closeSmbFun ;;    -h) helpFun ;;esac#--------------------------------------------------------#

 
原创粉丝点击