This small program is simple, but it is the first shell script written by the novice. It has many factors to consider, but some errors are not handled ,,
#! /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 "Enter the directory where you want to mount the yum Source:" addr2
Mkdir $ addr2>/dev/null 2> & 1
Xu = "000C29"
Mac = 'ifconfig | grep HWaddr | awk '{print $5}' | sed-n '1p' | tr ': ''' | awk '{print $1 $2 $3 }''
If ["$ mac" = "$ xu"]; then
Echo "you are using a virtual machine. Please make sure that the iso file in vmware is connected"
Sleep 2
Mount/dev/cdrom $ addr2>/dev/null 2> & 1
Else
Read-p "you are using a real machine"
Clear
Echo "the iso files in your system include :"
Find/-name "*. iso" | cat-n | more
Read-p "press enter to continue! "
Echo "your system version information is as follows :"
Cat/etc/issue | sed-n 1 p
Uname-r
Read-p "press enter to continue! "; Clear
Read-p "according to your system information, enter the serial number of the disc to be mounted:" 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 build complete"
Chmod + x yum. sh
While true
Do
Read-p "enter the name of the package you want to install (ctrl + c Exit !!) : "PN;
Yum install $ PN;
Done