A simple shell script-----Implement a simple configuration of the virtual machine lab environment

Source: Internet
Author: User

Personally wrote the shell script only to find that this thing is very convenient, when you want to put some trivial, detailed small instructions to complete a single time, the script is undoubtedly the best choice, convenient, fast, the key is really lazy people must ah.

Since the installation of the centos6.5 is minimized and is an experimental environment, which is installed on the VMware workstations, after the first installation is complete, the information about the IP address is configured and an initial snapshot is made so that the system can be quickly restored with a snapshot after the next experiment.

However, due to the requirements of the experimental environment, such as firewall, SELinux, CD mount, yum source configuration, etc., are the most commonly needed to modify the options, and because of the minimal installation, the system does not have the VIM compiler tool and the man manual query, so after each restore snapshot, but also to deal with these trivial issues. To this end, I have specifically written a small script, the content is not complex, but it is a learning process, sent to share with you, by the way advice ...

#!/bin/bash# config some simple order when the system start#  create by phoenix# specify the pathserver=/etc/init.dyum=/etc/yum.repos.dmountdir=/ Media/cdromselinux=/etc/selinux/config# stop the iptabes and set it can ' t  start when the system start$server/iptables stop &>/dev/nullif  [  "$?"  =  "0"  ]; then   chkconfig iptables off    chkconfig ip6tables off   echo  "1# the iptables stop  Successfully "else   echo " 1# the iptables stop failed "fi#  shutdown the selinxu systemsetenforce 0 && sed -e  ' s/^SELINUX= Enforcing/selinux=disabled/g '   $selinux  > $selinux .bak mv -f  $selinux. bak $ selinux echo  "2# The selinux system is disabled "# mount the cd-rommount |grep sr0  &>/dev/nullif [ !  "$?"  =  "0"  ]; then   if [ ! -e  $mountdir  ]; then       mkdir -p  $mountdir  &>/dev/null   else       mount /dev/cdrom  $mountdir  &>/dev/null       echo  "3# the cd-rom is mounting successfully"     fi   else   echo  "3# the cd-rom is already  mounted " fi# Config the source of yumif [ -e  $yum/ centos-base.repo ];then   mv -f  $yum/centos-base.repo  $yum/ centos-base.repo.bak &>/dev/nullelse   echo  "4# Starting config the source of yum "sleep 3 fi sed  -e  ' s/^enabled=0/enabled= 1/g '   $yum/centos-media.repo > $yum/centos-media.repo.bak  mv -f  $yum/ centos-media.repo.bak  $yum/centos-media.repo>>/dev/nullyum clean all &>/dev/ null &&echo  "5# the source of yum configed successfully" #  Modify the code of languageecho  "#LANG =zh_cn. UTF-8 " >/etc/sysconfig/i18necho " 6# the language is modify successfully " # install the tools  "VIM"  and  "man" echo  "7# starting install  vim and man,please wait ... "sleep 3yum install vim man -y  &>/dev/null# Reboot the system when all the work is  doneecho  "#########  all work is done  ######## "sleep 2echo " Please wait the syatem restart ... "sleep  2init 6


In addition, please do not spit in my English .... Although the level of four and almost six levels, but still no use ...

This article is from the "but evil Water Heart Pan" blog, please be sure to keep this source http://shmilyfl.blog.51cto.com/8897986/1690410

A simple shell script-----Implement a simple configuration of the virtual machine lab environment

Related Article

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.