Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:47:19+00:00 2026-06-12T04:47:19+00:00

I am trying to work out the proper process of installing with Wget, in

  • 0

I am trying to work out the proper process of installing with Wget, in this example I’ll use Nginx.

# Download nginx to /tmp/ directory
wget http://nginx.org/download/nginx-1.3.6.tar.gz -r -P /tmp

# Extract nginx into /tmp/nginx directory
tar xzf nginx-1.3.6.tar.gz -C /tmp/nginx

# Configure it to be installed in opt
./configure --prefix=/opt/nginx

# Make it
make

# Make install
make install

# Clean up temp folder
rm -r /tmp/*

Is this the idealised process? Is there anything I can improve on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:47:20+00:00Added an answer on June 12, 2026 at 4:47 am

    First of all, you definitely seem to reinvent the wheel: if the problem that you want to solve is automated packaging / building software on target systems, then there are myriads of solutions available, in form of various package management systems, port builders, etc.

    As for your shell script, there are a couple of things you should consider fixing:

    • Stuff like http://nginx.org/download/nginx-1.3.6.tar.gz or nginx-1.3.6.tar.gz are constants. Try to extract all constants in separate variables and use them to make maintaining this script a little bit easier, for example:

      NAME=nginx
      VERSION=1.3.6
      FILENAME=$NAME-$VERSION.tar.gz
      URL=http://nginx.org/download/$FILENAME
      TMP_DIR=/tmp
      INSTALL_PREFIX=/opt
      
      wget "$URL" -r -P "$TMP_DIR"
      tar xzf "$FILENAME" -C "$TMP_DIR/nginx"
      
    • You generally can’t be 100% sure that wget exists on target deployment system. If you want to maximize portability, you can try to detect popular networking utilities, such as wget, curl, fetch or even lynx, links, w3m, etc.

    • Proper practices on using a temporary directory is a long separate question, but, generally, you’ll need to adhere to 3 things:

      • One should somehow find out the temporary directory location. Generally, it’s wrong to assume that /tmp is always a temporary directory, as it can be not mounted, it can be non-writable, if can be tmpfs filesystem which is full, etc, etc. Unfortunately, there’s no portable and universal way to detect what temporary directory is. The very least one should do is to check out contents of $TMPDIR to make it possible for a user to point the script to proper temporary dir. Another possibly bright idea is a set of heuristic checks to make sure that it’s possible to write to desired location (checking at least $TMPDIR, $HOME/tmp, /tmp, /var/tmp), there’s decent amount of space available, etc.
      • One should create a temporary directory in a safe manner. On Linux systems, mktemp --tmpdir -d some-unique-identifier.XXXXXXXXX is usually enough. On BSD-based systems, much more manual work needed, as default mktemp implementation is not particularly race-resistant.
      • One should clean up temporary directory after use. Cleaning should be done not only on a successful exit, but also in a case of failure. This can be remedied with using a signal trap and a special cleanup callback, for example:

        # Cleanup: remove temporary files
        cleanup()
        {
                local rc=$?
                trap - EXIT
        
                # Generally, it's the best to remove only the files that we
                # know that we have created ourselves. Removal using recursive
                # rm is not really safe.
                rm -f "$LOCAL_TMP/some-file-we-had-created"
                [ -d "$LOCAL_TMP" ] && rmdir "$LOCAL_TMP"
        
                exit $rc
        }
        trap cleanup HUP PIPE INT QUIT TERM EXIT
        
        # Create a local temporary directory
        LOCAL_TMP=$(mktemp --tmpdir -d some-unique-identifier.XXXXXXXXX)
        
        # Use $LOCAL_TMP here
        
    • If you really want to use recursive rm, then using any * to glob files is a bad practice. If your directory would have more than several thousands of files, * would expand to too much arguments and overflow shell’s command line buffer. I might even say that using any globbing without a good excuse is generally a bad practice. The rm line above should be rewritten at least as:

      rm -f /tmp/nginx-1.3.6.tar.gz
      rm -rf /tmp/nginx
      

      Removing all subdirectories in /tmp (as in /tmp/*) is a very bad practice on a multi-user system, as you’ll either get permission errors (you won’t be able to remove other users’ files) or you’ll potentially heavily disrupt other people’s work by removing actively used temporary files.

    • Some minor polishing:

      • POSIX-standard tar uses normal short UNIX options nowadays, i.e. tar -xvz, not tar xvz.
      • Modern GNU tar (and, AFAIR, BSD tar too) doesn’t really need any of “uncompression” flags, such as -z, -j, -y, etc. It detects archive/compression format itself and tar -xf is sufficient to extract any of .tar / .tar.gz / .tar.bz2 tarballs.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work out the correct pattern to use for a Singleton that
I'm a beginner at PHP, and I'm still trying to work out proper file
I am trying to work out the template for an ebook. This is what
My goal is very simple today, I am trying to work out the proper
I am trying work out with MERGE statment to Insert / Update Dimension Table
Im trying to work out how to get the value from one setting in
I trying to work out what regex will match filenames in quotes. Eg. blah
i am trying to work out the following problem in Java (although it could
I am trying to work out why I can not access the nested function
I am trying to work out how I can insert the string End into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.