Create an unzipped installation package in Shell

Source: Internet
Author: User
Create an unzipped installation package in Shell

Principles

In Linux, you can use several basic commands to create a self-extracting program. The principle is: The Cat command can be used to connect two files (with> append can achieve the same effect). The previous file is a shell script, which is responsible for decompression and installation; the next file is a compressed package. Combine these two files into a new executable file (the first is the decompression program, followed by a compressed package), which has the function of automatic decompression and installation. The most important command here is how many lines (that is, compressed files) are decompressed by tail-n.

The program execution logic is as follows:
1. Execute the shell script code in the program
2. decompress the part after the program
3. Configure and install
4. Exit the program

Application Example

OK. Let's look at this example:

The current directory contains a compressed file web.tar.gz and a text file install_script.
1. Write a self-extract script
Cat install_script
#! /Bin/bash
Line = 'wc-L $0 | awk '{print $1 }''
Line = 'expr $ line-10'
Tail-N $ line $0 | tar ZX-C/tmp
CD/tmp/Web
./Install_web.sh
Ret = $?
# These blank lines are necessary, otherwise they will affect 10 of $ line-10.
#
#
Exit $ RET
This worker is responsible for the decompression and installation of the web.tar.gz script

2. Create and install the tar package
Web.tar.gz is a collection of tar packages that contain the most common MySQL + Apache + PhP source code packages.

Ls Web/
Httpd-2.2.8.tar.gz install_web.sh mysql-5.0.51b.tar.gz php-5.2.6.tar.gz
Install_web.sh is the installation script (any configure and make can be written here ).

3. Generate a self-extracting Installer
Cat install_script web.tar.gz> Web. Install
Chmod + x web. Install

4. Run the automatic installation program.
./Web. Install

After the program is executed, it unpacks all the compressed packages and performs the confire and make operations according to the logic in install_web.sh. The complexity of various operations in the Linux environment is encapsulated, which is as simple as that in windows.

Chmod + x web. Install
Note: The source code must be executed by the root user. The installation is successful after all three steps are completed. After the installation, all programs are installed in/home/work/web, in addition, the Work user starts MySQL and Apache (port 8080 ). This installation file passed the test in our standard 64-bit server environment (some 32-bit environments have older libraries and require additional compilation). The entire process takes 40 minutes. The temporary directory during installation is under/tmp/web. You can run tail-F/tmp/web/install_web.log to view the detailed compilation information and progress.

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.