一键配置本地yum源的shell脚本
效果如图:
代码
#!/bin/bash #Author:GaoHongYu #QQ:1061767621 #Time:2019-12-26 16:30:19 #Name:yumgz.sh #Version:V1.0 CKGZ=$( df -Th | grep -o "iso9660" ) KJGZ=$( cat /etc/fstab | grep -o "iso9660" ) read -p "欢迎使用Yum自动挂载脚本,y开始|n退出: " xw if [ $xw == y ];then echo "$CKGZ" &> /dev/null if [ "$CKGZ" == 'iso9660' ];then echo "检测到您的光盘已挂载" elif [ $? -ne 0 ];then echo "您的光盘未挂载,接下来将自动进行挂载!" mount /dev/sr0 /media/cdrom &> /dev/null fi if [ $? -eq 0 ];then echo "光盘已挂载成功!" echo "接下来将自动配置本地Yum源!" echo "配置中,请耐心等待..." cd /etc/yum.repos.d/ mkdir bak &> /dev/null mv C* bak &> /dev/null rm -rf /etc/yum.repos.d/local.repo echo "[local]" > /etc/yum.repos.d/local.repo echo "name=local" >> /etc/yum.repos.d/local.repo echo "baseurl=file:///media/cdrom" >> /etc/yum.repos.d/local.repo echo "gpgcheck=0" >> /etc/yum.repos.d/local.repo echo "enabled=1" >> /etc/yum.repos.d/local.repo yum -y clean all &> /dev/null yum makecache &> /dev/null fi echo "$KJGZ" &> /dev/null if [ "$KJGZ" == 'iso9660' ];then echo "您已设置光盘开机挂载,无需重复设置" else echo "正在为您设置开机自动挂载!" echo "/dev/sr0 /media/cdrom iso9660 defaults 0 0" >> /etc/fstab echo "开机自动挂载已为您配置完毕!" echo "恭喜您,本地Yum源已经配置成功!" fi elif [ "$xw" == 'n' ];then echo "退出程序成功!" exit 0 fi
相关推荐
laisean 2020-11-11
Julyth 2020-10-16
laisean 2020-09-27
liguojia 2020-09-27
tvk 2020-07-30
Zaratustra 2020-06-26
IsanaYashiro 2020-06-16
拿什么来拯救自己 2020-06-21
87201442 2020-10-15
MXstudying 2020-09-05
WasteLand 2020-09-15
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh
mathchao 2020-09-15
Zaratustra 2020-07-29
zhaowj00 2020-07-26
ldcwang 2020-06-25
赵家小少爷 2020-06-14
大牛牛 2020-06-14
klarclm 2020-06-13