Skip to content

postinstall.sh

Nils edited this page Jan 6, 2021 · 5 revisions

postinstall.sh

With postinstall.sh you start the post-installation steps.

Set the variables BASE and TYPE in the bash script or with the options -b and -t. The variables are needed later for the generation of the other scripts (before.sh, after.sh and packages.list).

In addition the following variables are determined. These can also be used for later generation.

  • HOSTNAME_FQDN → hostname -f
  • OPERATING_SYSTEM → Various checks
  • OPERATING_SYSTEM_TYPE → uname
  • ARCHITECTURE → uname -m

Usage

Usage: postinstall.sh [-t <TYPE>] [-b <BASE>] [-h]:
        [-t <TYPE>]      sets the type of installation (default: server)
        [-b <BASE>]      sets the base url or dir (default: https://raw.githubusercontent.com/Cyclenerd/postinstall/master/base)
        [-h]             displays help (this message)

Examples:

  • Default: postinstall.sh
  • Other type: postinstall.sh -t workstation
  • Custum base dir: postinstall.sh -b /tmp/install

Generation

To generate the package lists and scripts, postinstall.sh looks at a number of places after configuration files.

  • BASE
  • BASE/HOSTNAME_FQDN
  • BASE/TYPE
  • BASE/OPERATING_SYSTEM
  • BASE/OPERATING_SYSTEM/TYPE

Example:

# Create BASE
mkdir install
cd install
# Create list of packages for all OPERATING_SYSTEMs and TYPEs
vi packages.list

# Create TYPE
mkdir server
# Create before.sh for all OPERATING_SYSTEMs and only TYPE server
vi before.sh

# Create OPERATING_SYSTEM
mkdir DEBIAN
# Create after.sh script only for DEBIAN and only TYPE server
cd DEBIAN
mkdir server
cd server
vi after.sh

Check out this repository to understand it better. It can become quite complex.

Example

Suppose you installed Fedora (Red Hat) Linux on your server with hostname (HOSTNAME_FQDN) myserver.domain.local. So your operating system (OPERATING_SYSTEM) would be REDHAT.

The default type of installation (TYPE) is server.

If you now run postinstall.sh as root the following locations are tested by default:

Package list:

Before script:

  • [...]/base/before.sh
  • [...]/base/myserver.domain.local/before.sh
  • [...]/base/server/before.sh
  • [...]/base/REDHAT/before.sh
  • [...]/base/REDHAT/server/before.sh

After script:

  • [...]/base/after.sh
  • [...]/base/myserver.domain.local/after.sh
  • [...]/base/server/after.sh
  • [...]/base/REDHAT/after.sh
  • [...]/base/REDHAT/server/after.sh

When the generation has been completed, everything is started in the following order:

  1. Run before script
  2. Install packages
  3. Run after script

In our example this would be:

  • Before
    • Get primary user group from user (nils)
    • Create private SSH key
  • Packages
    • Several...
  • After
    • SSH Daemon Configuration

If we change the type of installation (postinstall.sh -t workstation) to workstation, Spotify is installed:

  • Before
    • Get primary user group from user (nils)
    • Create private SSH key
    • Installing RPM Fusion free and nonfree repositories
  • Packages
    • Several... and Spotify
  • After
    • Nothing
Clone this wiki locally