linuxinstall4j

install4j install additional packages for different Linux families


I use Install4j for my application distribution. I have a Linux installer and during installation process I need to install additional packages. For example sudo apt-get install libpcsclite1

I don't understand which Action should I use in the installer for executing a Bash script or simple package installation.

And another question: I need to support all families of Linux; for example for Oracle Linux the command must be sudo yum install libpcsclite1

Maybe Install4j has some ready solution for such case or tool for understanding which family the current Linux distro belongs to?


Solution

  • Thanks Ingo for the solution. It works fine. Additionally in install4j when you add .sh file you should do it with execute Linux permissions (for example 744). And my script for install packages:

    #!/bin/bash
    #
    # Install additional packages for such dists: Ubuntu, Debian, Mint, Oracle  
    
    releaseFile=/etc/os-release
    
    if [ -f $releaseFile ]; then
        . $releaseFile
        os=$ID
        [ -z "$os" ] && os=$ID_LIKE
    else
        echo "Release file not found." >&2
        exit 1
    fi
    
    case $os in
        ubuntu|debian|mint)
            echo "Detected Debian family distribution."
            sudo apt-get update
            sudo apt-get install libpcsclite1
            ;;
        ol)
            echo "Detected Oracle Linux."
            sudo yum install pcsc-lite
            ;;
        *)
            echo "Unsupported Linux distribution: $os" >&2
            exit 1
            ;;
    esac