Skip to content

before.sh

Nils edited this page Dec 1, 2016 · 1 revision

before.sh

before.sh is generated and executed before the installation of the packages (packages.list).

If the script is only to be executed under a specific operating system, save it in the respective folder (for example, REDHAT)

Create your own files without #!/bin/bash at the beginning.

The following functions can help you:

  • echo_step "your text" → outputs a step collored in cyan, without outputing a newline
  • echo_warning "your text" → outputs [ WARNING ] in yellow, at the rightmost side of the screen
  • echo_success → outputs [ OK ] in green, at the rightmost side of the screen
  • exit_with_failure "your text" → outputs and logs a message before exiting the script and outputs [ FAILED ] in red, at the rightmost side of the screen.

You should redirect outputs to the log >>"$INSTALL_LOG" 2>&1.

Also take care that the commands do not expect any input.

Example

Add RPMFusion

echo_step "  Installing RPM Fusion free and nonfree repositories"
$INSTALLER $INSTALL "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
	"https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" >>"$INSTALL_LOG" 2>&1
if [ "$?" -ne 0 ]; then
	echo_warning "Failed to install repositories, will attempt to continue"
else
	echo_success
fi
Clone this wiki locally