#!/bin/bash
[ -d /tmp/run ] && {
echo "/tmp/run exists"
rm -fr /tmp/run/*
echo "the dir is clear"
}||{
echo "/tmp/run not exists"
mkdir -p /tmp/run
echo "/tmp/run now exists"
exit
}
#!/bin/bash
read -p "please input path: " path
[ -e $path ] && {
echo "the path exists"
[ -d $path ]&& {
echo "the path is dir"
exit
}
[ -L $path ]&& {
echo "the path is link"
exit
}
[ -f $path ]&& {
echo "the path is common file"
exit
}
}||{
echo "the path not exists"
exit
}
#!/bin/bash
read -p "please input an ip:" ip
ping -c1 $ip &> /dev/null
if [ $? -eq 0 ]; then
echo "$ip can ping"
echo "server $ip can ping" | mail -s root@localhost mail01@localhost
else
echo "$ip cannot ping"
echo "server $ip cannot ping" | mail -s root@localhost mail01@localhost
fi
#!/bin/bash
read -p "please input a string: " string
case $string in
hello)
echo "world"
;;
world)
echo "hello"
;;
*)
echo “usage:please input hello or world”
;;
esac
#!/bin/bash
echo "1.判断网络是否畅通"
ping -c1 172.25.254.20 &>/dev/null
if [ $? -eq 0 ];then
echo "the network is ok"
else
echo "Error:the network is not working"
exit 1
fi
echo "2.关闭selinux和firewalld"
setenforce 0 &>/dev/null
if [ $? -eq 0 ];then
echo "selinux is disabled"
fi
systemctl stop firewalld &>/dev/null
if [ $? -eq 0 ];then
echo "firewalld is stoped"
fi
echo "3.查看软件是否安装"
rpm -q samba-common &>/dev/null
if [ $? -eq 0 ];then
echo "samba-common is installed"
else
echo "samba-common is not installed"
dnf install samba-common -y
rpm -q samba-common &>/dev/null
if [ $? -eq 0 ];then
echo "samba-common is now installed"
else
echo "samba-common installed failed"
exit 1
fi
fi
rpm -q samba &>/dev/null
if [ $? -eq 0 ];then
echo "samba is installed"
else
echo "samba is not installed"
dnf install samba -y
rpm -q samba &>/dev/null
if [ $? -eq 0 ];then
echo "samba is now installed"
else
echo "samba installed failed"
exit 1
fi
fi
rpm -q samba-client &>/dev/null
if [ $? -eq 0 ];then
echo "samba-client is installed"
else
echo "samba-client is not installed"
dnf install samba-client -y
rpm -q samba-client &>/dev/null
if [ $? -eq 0 ];then
echo "samba-client is now installed"
else
echo "samba-client installed failed"
exit 1
fi
fi
echo "4.启动smb服务"
systemctl status smb.service | grep active &>/dev/null
if [ $? -eq 0 ];then
systemctl restart smb
echo "smb.service restart success"
else
systemctl enable --now smb
fi
echo "5.添加用户和共享路径"
read -p "please input a user: " user
read -p "please input a path: " path
useradd $user
mkdir -p $path
本文地址:https://blog.csdn.net/weixin_46833747/article/details/107321546
如对本文有疑问, 点击进行留言回复!!
Python之数据分析(中位数、波动范围、极差、离差、方差、标准差)
python如何将两个索引相同的列表的数据合并成一个新列表及绘图注意事项
网友评论