Tool Function Analysis

Source: Internet
Author: User

Tool Function Analysis
These functions belong to the Environment preparation class. In fact, it is important to check the environment when writing similar scripts. This prevents errors reported when some environments are not available. The first function is the prepare_dir function, the code for detecting the directory is as follows:

Prepare_dirs () {# create the necessary Directory, which will be output to ECHO_DEBUG "Creating necessary directories during installation... "# PKG_DIR, PKG_MISC_DIR, which has been defined in the previous article. FOR Loop reading, skipped. If not, create it directly. For I in $ {PKG_DIR }$ {PKG_MISC_DIR} do [-d "$ {I}"] | mkdir-p "$ {I}" done}
After executing this function, you can create all the required directories. Next, analyze the fetch_misc () function. The Code is as follows:
Fetch_misc () {# enter this directory, prepare to download the Installation File cd $ {PKG_MISC_DIR} # calculate the total number of installation misc_total =$ ($ (echo $ {MISCLIST} | wc-w | awk '{print $1 }'))) # define the counter misc_count = 1 # Install the alert to get the ECHO_INFO "Fetching source tarbils in the source file... "# for Loop read the tag list, get it, and download it to the local for I in $ {MISCLIST }; do url = "$ {IREDMAIL_MIRROR}/yum/misc/$ {I}" ECHO_INFO "+ $ {misc_count} of $ {misc_total }: $ {url} "$ {FETCH_CMD}" $ {url} "misc_count =$ (misc_count + 1) done}

 

In fact, the meaning of this script is to download the corresponding version of the installation file from the address below

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.