Automatically build local yum shell script final version ps real machine Virtual Machine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.