</pre><p> wrote a script, mainly do 1, mount the local ISO image file 2, boot local ISO image boot automatically mount 3, configure the local Yum source with ISO image </p><pre>
#!/bin/bash#author:wjf#date:2015/04/22#desc:establish a yum on local rhel6.4echo "Please enter ISO image full path" read V_iso_pathecho " Please enter the directory to mount the image "read v_mount_dirv_curr_date= ' date +%y%m%d%h%m ' mount-t iso9660-o loop ${v_iso_path} ${v_mount_dir}v_is_ Mount= ' df-h |grep ${v_iso_path} ' if [-Z ' ${v_is_mount} "] then echo" Mount unsuccessful, check the mount process "else echo "Mount ISO image successfully, start configuring Yum ..." echo "Configure disc mount boot from" echo "Backup/etc/fstab file to/etc/fstab.${ V_curr_date}.bak "Cp/etc/fstab/etc/fstab.${v_curr_date}.bak echo" ${v_iso_path} ${v_mount _dir} iso9660 Loop 0 0 ">>/etc/fstab mount-a echo-ne" [base]\nname=base\nbaseurl=f Ile://${v_mount_dir}\nenabled=1\ngpgcheck=0\n\n[server]\nname=server\nbaseurl=file://${v_mount_dir}/server\ nenabled=1\ngpgcheck=0\n ">/etc/yum.repos.d/local.repo Yum Clear all Yum Updatefi
Output results
[[email protected] wjf_scripts]# bash ISO configure local Yum source. SH Enter the full path to the ISO image/mnt/rhel-server-6.4-x86_64-dvd.iso Please enter the directory you want to mount the image for/mnt /yumiso Mount ISO Image successfully, start configuring Yum ... Configure CD-mount boot-up backup/etc/fstab file to/etc/fstab.201504231045.bakloaded Plugins:product-id, Refresh-packagekit, security, Subscription-managerthis system is not registered to Red Hat subscription Management. You can use the Subscription-manager to register. No such command:clear. Please Use/usr/bin/yum--helploaded Plugins:product-id, Refresh-packagekit, security, subscription-managerthis system Is isn't registered to Red Hat Subscription Management. You can use the Subscription-manager to register. Server | 3.9 kb 00:00 ... base | 3.9 kb
Summarize the points of knowledge
1. If []
Then
elif []
Else
Fi
Standard syntax for IF statements
There must be a space between the "if" and the judgment statement.
You must end with "fi", or you will get an error.
2. ISO image Mount statement
Mount-t Iso9660-o Loop/mnt/rhel6.4.iso/mnt/yumiso
The CD-ROM mount statement is
Mount-t Iso9660/dev/cdrom/mnt/testiso
You can see that the mount image requires more than one loop parameter.
Similarly, file system mounts involve a configuration file of/etc/fstab
The configuration behavior of the ISO image according to its syntax format
/mnt/rhel6.4.iso/mnt/yumiso iso9660 Loop 0 0
3. Yum Source Configuration
The Yum source automatically loads all configuration files that end with. Repo in the/ETC/YUM.REPOS.D directory.
Repo the format in the configuration file.
No other characters, such as spaces, can appear at the beginning of the configuration file, or a parsing error will occur. At first, in order to be beautiful in the script, each line added a space, resulting in an error.
Shell programming mount ISO image file and configure local Yum source