# once.sh
Unified shell environment for UCP components and ONCE the Object Network Communication Environment


This Repo consists of two main topics
1. The oosh object oriented bash environment with completion, logging and debugging
1. the once bash script to manage a ONCE installation into any environment
1. 1. Supported environments — see [Supported Platforms](docs/supported-platforms.md) for the full matrix

Code flows through a gated pipeline: `dev` → `stage` → `prod`. See [Branching Strategy](docs/branching.md) for details.

## prereqs

- **curl / wget / fetch** (only one, for the one-liner to fetch the installer)
  — macOS: already present · Debian/Ubuntu: `apt-get install -y curl` · RHEL/Fedora: `dnf install -y curl` · Alpine: `apk add curl`
- **bash 4+** — macOS: `brew install bash` · Debian/Ubuntu/RHEL: already present (Ubuntu 22/24 ships bash 5)
- **git** — macOS: `xcode-select --install` · Debian/Ubuntu: `sudo apt install git` · RHEL/Fedora: `sudo dnf install git` · Alpine: `apk add git`

> **Why curl/wget/fetch is listed first:** the install one-liner below (`sh -c "$(curl …)"`) relies on the shell's command-substitution to pull the installer from GitHub. If the fetcher is missing, the shell silently runs `sh -c ""` and nothing happens — you'll see *`sh: curl: command not found`* with no framed error. Install a fetcher first (any one of curl / wget / fetch), then run the one-liner.
>
> The installer itself checks **bash 4+** and **git** and prints a consolidated error with per-platform install hints if either is missing.

## one-file install

**One file, double-click (macOS) or `./` (Linux):**

1. **[⬇ Download Install oosh.command](https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/Install%20oosh.command)** (right-click → Save Link As…)
2. Run it:
   - **macOS:** double-click in Finder.
   - **Linux:** `chmod +x "Install oosh.command" && ./"Install oosh.command"`
3. A terminal runs the install. Enter your sudo password when prompted.

That's it — the `.command` file self-bootstraps: it fetches the bootstrap script from GitHub and runs it. No need to download the whole repo.

> **First-run macOS prompt:** downloaded files carry Apple's quarantine flag. macOS will say "*Install oosh.command* cannot be opened because the developer cannot be verified." Right-click the file → **Open** → **Open** to confirm. After you approve it once, double-click works normally. Linux has no equivalent gate.

> **Also works from a clone:** if you `git clone` the repo or download the ZIP, the same `Install oosh.command` in the repo root runs your local `init/oosh` instead of fetching from GitHub. Same UX either way.

## fast install - use it anywhere

| Method    | Command                                                                                           |
|:----------|:--------------------------------------------------------------------------------------------------|
| **curl**  | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)"` |
| **wget**  | `sh -c "$(wget -O- https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)"`   |
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)"` |

`init/oosh` is a POSIX `sh` script, so `sh -c` works on every supported
platform (dash on Debian, ash on Alpine, bash on macOS). `bash -c` also
works if you prefer it.

Substitute the `prod` segment of the URL with `dev` (or any branch name) to
install from a non-default branch, e.g. `…/dev/init/oosh`.


### More detailed logging for debugging is available with these commands
```
unbuffer env -i sh -xc "$(wget -O- https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)" | tee install.log.txt

> or if already available locally
unbuffer env -i sh -x init/oosh | tee install.log.txt 

> to view the file use 

less -r install.log.txt

> install unbuffer in one of the following ways
brew install expect
oo cmd expect
sudo apt-get install expect

```
in VSCODE use [use the ANSI Colors plugin](https://marketplace.visualstudio.com/items?itemName=iliazeus.vscode-ansi)

## manual install
```
wget https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh ;
chmod 700 oosh
./oosh


or
cat oosh | sh -x
```

### you do not have curl or wget: try

```
sudo apt update
sudo apt install curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)"

or as root

apt update
apt install curl
sh -c "$(wget -O- https://raw.githubusercontent.com/Cerulean-Circle-GmbH/once.sh/prod/init/oosh)"
```


## Starting an OOSH shell

After install, just type **`bash`** — that's it. Your prompt becomes:

```
[oosh <hostname>] user@host:~ >
```

Tab completion works on all OOSH scripts (`otmux <TAB>`, `hiveMind <TAB>`, etc).

Details and troubleshooting: [docs/oosh.md — Starting an OOSH Shell](docs/oosh.md#starting-an-oosh-shell).

## Advanced usage: ONCE Server

setup a once server management environment

```
    oosh/init/once
    
```

The once server Installation is currently highly interactive and only supported as a **root** user.
Basically you will follow a state machine
```
    once v                                  # gives you the current once version
    once init                               # create a ONCE configuration for the current user

    **follow the state machine....*** once told you in `once init` what to do next
    once domain.set <your.domain.com>       # sets the domain for this installation. 
                                            # user localhost if its a development installation
    once domain.discover                    # gets the domain from the host configuration

    once states.list  <?all>                # shows you which state is currently set
                                            # the optional parameter all shows all states

    once stage next                         # tries to stage one step in the state list

    once check.STATE_NAME                   # checks if this state is already reached
    e.g.                                    # TAB completion should work. press TAB TAB to see all options
    once check.domain.set

    TROUBLE SHOOTING
    once state.su.set <stateNameOrNumber>   # sets the state hard so that you can skip states 

    once bind test.wo-da.de                 # binds the config to keycloak on test.wo-da.de
    
```
