Skip to content

Instantly share code, notes, and snippets.

@franz-josef-kaiser
Last active May 13, 2022 01:01
Show Gist options
  • Select an option

  • Save franz-josef-kaiser/df7dc6adf9489c40ceb1efaf7ac89b0c to your computer and use it in GitHub Desktop.

Select an option

Save franz-josef-kaiser/df7dc6adf9489c40ceb1efaf7ac89b0c to your computer and use it in GitHub Desktop.

Revisions

  1. franz-josef-kaiser revised this gist Sep 30, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,6 @@ Again, just refer to the usual process.
    ## Upgrading
    ### Git
    Just run a `git fetch` followed by a `git pull`
    ## Upgrading.
    ## Upgrading
    ### Homebrew
    The usual `brew update` followed by `brew upgrade foo` and `brew cask upgrade foo`. You can script that too.
    ### Package Managers of all sorts
  2. franz-josef-kaiser revised this gist Sep 30, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion install.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,9 @@ then
    echo -e "\033[32m > @TODO already installed.\033[0m"
    exit
    fi

    # OS Switch, author "Timmmm"
    # @link https://stackoverflow.com/a/8597411/376483
    # @license CC-BY-SA 4.0
    # Linux
    if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    # Install
  3. franz-josef-kaiser revised this gist Sep 29, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion install.sh
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,8 @@ elif [[ "$OSTYPE" == "freebsd"* ]]; then

    # WTF
    else
    echo " > Unknown distribution. Nothing to install."
    echo -e "\033[31m > Unknown distribution. Nothing to install.\033[m"
    exit
    fi

    echo -e "\033[32m > @TODO installed. Done!\033[0m"
  4. franz-josef-kaiser created this gist Sep 29, 2020.
    24 changes: 24 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Bash Installer
    If you are collaborating with others, chances that not everyone's on the same OS are good. If you want to avoid "running on my machine" kind of problems, just share an installer script for your favorite binaries installers/ upgrader/ uninstallers. This is one way to do it.

    This is a simple installer script that selects different installation methods based on the OS you are running this on.
    ## How to
    Just replace `@TODO` with whatever you are installing. Make sure to adjust the different installation methods some project/ program offers.

    **Linux** currently is running a Git clone installer that symlinks into some `$PATH` supporting place. This does _not_ clone the complete repo, but just the last commit!
    ## Uninstallation
    ### Git
    If you need to uninstall something you cloned via Git, just run `rm -rf --preserve-root` on the directory you cloned to. Maybe use `echo rm -rf /path/to/dir` first to check the output.
    ### Homebrew
    Just run `brew uninstall foo` or the same for `cask`.
    ### Package Managers
    Again, just refer to the usual process.
    ## Upgrading
    ### Git
    Just run a `git fetch` followed by a `git pull`
    ## Upgrading.
    ## Upgrading
    ### Homebrew
    The usual `brew update` followed by `brew upgrade foo` and `brew cask upgrade foo`. You can script that too.
    ### Package Managers of all sorts
    All other package managers support the same procdure: Fetch the most current list, then upgrade.
    51 changes: 51 additions & 0 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    #!/usr/bin/env bash

    # Install @TODO
    # @link https://@TODO.example.com/link/to/docs

    echo " > Installing @TODO - DETAILED NAME HERE…"

    if command -v @TODO &> /dev/null
    then
    echo -e "\033[32m > @TODO already installed.\033[0m"
    exit
    fi

    # Linux
    if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    # Install
    cd "${HOME}" || (echo " > Directory does not exist. Exiting." && exit)
    mkdir -p "${HOME}/.local/bin/"
    git clone --depth 1 [email protected]:@TODO.git ~/.@TODO
    . "${HOME}/.profile"
    # Set a symlink to something already in the $PATH
    # to avoid cluttering the path
    ln -s "${HOME}/.@TODO/bin/*" "${HOME}/.local/bin"

    # Mac OSX
    elif [[ "$OSTYPE" == "darwin"* ]]; then
    # Install via Homebrew or via Cask
    brew cask install @TODO

    # POSIX compatibility layer and Linux environment emulation for Windows
    elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
    # Chocolate package manager
    command -v choco >/dev/null 2>&1 || {
    choco install @TODO
    }
    # Else: You might need to copy from some other OS here.

    # I'm not sure this can happen.
    elif [[ "$OSTYPE" == "win32" ]]; then
    echo " > WTF. Win32."

    # Free BSD… In case you really, really need it
    elif [[ "$OSTYPE" == "freebsd"* ]]; then
    pkg install @TODO

    # WTF
    else
    echo " > Unknown distribution. Nothing to install."
    fi

    echo -e "\033[32m > @TODO installed. Done!\033[0m"