Linux-based self-extracting Installation

Source: Internet
Author: User
Linux-Linux general technology-Linux programming and kernel information. For more information, see the following. In linux, you can use several basic commands to create a self-extracting program. Let's talk about the principle. First, the cat command can be used to connect two files (with> append can achieve the same effect). The first 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 preceding is the decompression program), 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.

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

Finished.

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.