本文参加博客大赛:如果你就得还行,离开时请动动小手 投一票 谢谢
1 自动搭建本地YUM源 ps适合vmware 虚拟机判定,与真实机
脚本截图:
#!/bin/bash
#auth :dhh
clear
addr=/etc/yum.repos.d
mkdir $addr/bf >/dev/null 2>&1
mv $addr/*.repo $addr/bf
touch $addr/localyum.repo
read -p " 输入你想挂载yum源的目录:" addr2
mkdir $addr2 >/dev/null 2>&1
mac=`ifconfig|grep eth0|awk '{print $5}'|awk -F: '{print $1$2$3}'`
if [ "$mac" = "000C29" ]; then
echo " 你正在使用虚拟机,请确保vmware中iso文件已经连接"
sleep 2
mount /dev/cdrom $addr2 >/dev/null 2>&1
else
read -p " 你正在使用真实机"
clear
echo " 你系统中拥有的iso文件有:"
find / -name "*.iso"|cat -n|more
read -p " press enter to continue!"
echo " 你的系统版信息如下:"
cat /etc/issue|sed -n 1p
uname -r
read -p " press enter to continue!";clear
read -p " 根据你系统信息,输入你需要挂载光盘的序号:" num
B=`find / -name "*.iso"|sed -n ''$num'p'`
mount -o loop $B $addr2 >/dev/null 2>&1
fi
cat << dmm >$addr/localyum.repo
[LOCAL-YUM]
name=localyum
baseurl=file://$addr2
enabled=1
gpgcheck=0
dmm
yum clean all >/dev/null 2>&1
echo " yum 搭建完成"
chmod +x yum.sh
while true
do
read -p " 输入你想要安装的软件包名字(ctrl+c退出!!):" PN;
yum install $PN;
done
2 双色球摇号脚本,,如果你是彩民--你值得拥有
脚本截屏
#/bin/bash
echo "红球"
echo -e "\033[31m`seq 32|xargs`\033[0m"
echo "篮球"
echo -e "\033[34m`seq 16|xargs`\033[0m"
read
red=(`seq 32`)
echo -n "您的幸运号码是*** 红球:"
for i in `seq 6`
do
len=${#red[@]}
((in=$RANDOM % $len))
echo -n "${red[$in]} " && unset red[$in] && red=(${red[@]})
done
blue=(`seq 16`)
echo -n "篮球:"
((on=$RANDOM % 16))
echo "${blue[$on]}***"
3 点名脚本,根据文件点名 ps需要在
/etc/dianming
下创建
name.txt
文件
name.txt的格式
脚本截屏
#!/bin/bash
#auth:dhh
dire="/etc/dianming"
[ ! -d $dire ]&&mkdir -p $dire
file="/etc/dianming/name.txt"
file2="/etc/dianming/name.bak"
[ ! -f $file ]&&touch $file
[ ! -f $file2 ] &&cp $file $file2
num=`wc -l $file|awk '{print $1}'`
function suijishu ()
{
ran=$(($RANDOM%$num+1))
name=`sed -n ''"$ran"'p' $file|awk -F '#' '{print $3}'`
}
if [[ $num == 0 ]];then
echo "1 从备份中恢复"
echo "2 手动添加"
read -p "输入你的选择:" choice
case $choice in
1)
cp $file2 $file
;;
2)
echo "请将待选名单按照格式添加到$file中"
exit 0
;;
esac
else
echo "有$num同学未被点到"
for ((i=1;i<=60;i++))
do
if [ $num == 1 ];then
i=60
fi
suijishu
echo -ne "\033[s"
echo -ne "\033[34m $name \033[0m"
sleep 0.1
echo -ne "\033[u"
done
suijishu
echo -n "恭喜"
echo -e -n "\033[31m $name \033[0m "
echo "中奖了"
sed -i ''"$ran"'d' $file
exit 0
fi