The first line in a bash script should be
Put a description in the beginning of the script if its purpose is not totally clear by its name or the like.
set -o errexit
Instructs bash to immediately exit if any command has a non-zero exit status. You may add '|| true' to commands that you allow to fail/have a non-zero exit code.
set -o nounset
When set, a reference to any variable you haven't previously defined - with the exceptions of $* and $@ - is an error, and causes the program to immediately exit.
set -o pipefail
This setting prevents errors in a pipeline from being masked. If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline.
Write all error data to stderr by putting
in front of or after 'echo' commands.
When referencing variables, use curly brackets instead of just $VARIABLE.
The following lines are useful if software is automatically installed using apt-get:
apt-get --assume-yes (or -y) ...
Automatic 'yes' answer to questions from apt-get
DEBIAN_FRONTEND=noninteractive apt-get ...
Makes the frontend never interact with you at all and makes the default answers be used for all questions.
After copying installation data to a temporary location and executing it, do not forget to remove it if your installation was successful.