# setup.sh · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/blob/HEAD/setup.sh)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: HEAD

Commit: ccd67937717f30ac89b3bdf39f6753838ca03b9c

Blob: c1885be41dc51ec50ebc6cad365f77763ebcf323

Size: 1829 bytes

[Immutable source](https://git.cafe/lucenx/codexbar-plasma/blob/ccd67937717f30ac89b3bdf39f6753838ca03b9c/setup.sh?format=markdown)

```
#!/usr/bin/env bash

# Parse the complete bootstrap before executing a streamed download.
{
  set -euo pipefail

  no_input=false
  for argument in "$@"; do
    case "$argument" in
      --no-input) no_input=true ;;
      --with-cli) ;;
      -h|--help)
        printf '%s\n' 'usage: bash setup.sh [--with-cli] [--no-input]' \
          'Installs the latest stable widget release for the current user.' \
          '--with-cli also installs/reuses the private CLI; select it in widget settings.' \
          '--no-input skips optional prompts and never restarts Plasma.'
        exit 0
        ;;
      *) printf '%s\n' 'Unsupported setup option. Use --help for supported options.' >&2; exit 2 ;;
    esac
  done

  for required_command in curl bash; do
    command -v "$required_command" >/dev/null 2>&1 || {
      printf 'Missing required command: %s\n' "$required_command" >&2
      exit 127
    }
  done

  if ! installer=$(curl --fail --location --show-error --silent \
    --connect-timeout 10 --max-time 30 --max-filesize 65536 --max-redirs 5 \
    --proto '=https' --proto-redir '=https' \
    https://raw.githubusercontent.com/Lucenx9/codexbar-plasma/main/scripts/update-widget.sh); then
    printf '%s\n' 'Could not download the installer; setup stopped.' >&2
    exit 1
  fi
  if [[ "$installer" != *$'\n# codexbar-plasma-updater-end' ]]; then
    printf '%s\n' 'Installer download is incomplete; setup stopped.' >&2
    exit 1
  fi

  if [[ "$no_input" == true ]]; then
    exec bash -c "$installer" codexbar-setup --setup "$@" </dev/null
  elif [[ -t 0 ]]; then
    exec bash -c "$installer" codexbar-setup --setup "$@"
  elif { true </dev/tty; } 2>/dev/null; then
    exec bash -c "$installer" codexbar-setup --setup "$@" </dev/tty
  else
    exec bash -c "$installer" codexbar-setup --setup "$@" </dev/null
  fi
}

```
