Skip to content

Commit

Permalink
sudoless with --syslink (#73)
Browse files Browse the repository at this point in the history
* lando will now install in ~/.lando/bin by default

* lando will now install in ~/.lando/bin by default part 2

* lando will now install in ~/.lando/bin by default part 3

* lando will now install in ~/.lando/bin by default part 4

* lando will now install in ~/.lando/bin by default part 5

* lando will now install in ~/.lando/bin by default part 6

* lando will now install in ~/.lando/bin by default part 7

* lando will now install in ~/.lando/bin by default part 8

* add --syslink option and its auto resolution for POSIX install

* add --syslink option and its auto resolution for POSIX install part 2

* docs
  • Loading branch information
pirog authored Nov 23, 2024
1 parent 0ce0ad3 commit 392595d
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 118 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/pr-posix-script-curl-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
npm run prepare
- name: Run setup-lando.sh on ${{ matrix.os }}
shell: bash
run: |
/bin/bash -c "$(curl -fsSL file://${{ github.workspace }}/dist/setup-lando.sh)"
lando version --all
run: /bin/bash -c "$(curl -fsSL file://${{ github.workspace }}/dist/setup-lando.sh)"
- name: Test
shell: bash
run: lando version --all

12 changes: 5 additions & 7 deletions .github/workflows/pr-posix-script-os-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ jobs:
- name: Run setup-lando.sh on ${{ matrix.os }}
if: runner.os == 'Linux'
shell: bash
run: |
./setup-lando.sh --debug
lando version --all
run: ./setup-lando.sh
- name: Run setup-lando.sh on ${{ matrix.os }}
if: runner.os == 'macOS'
shell: bash
run: |
./setup-lando.sh --debug --no-setup
lando setup -y --debug --skip-networking
lando version --all
run: ./setup-lando.sh --no-setup && lando setup -y --debug --skip-networking
- name: Test
shell: bash
run: lando version --all
2 changes: 1 addition & 1 deletion .github/workflows/pr-posix-script-replacer-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ jobs:
shell: bash
run: |
which lando | grep "$HOME/.lando/bin/lando"
readlink -f $(which lando) | grep /usr/local/bin/lando
readlink -f $(which lando) | grep -E "^$HOME/\.data/lando/[^/]+/lando$"
lando version | grep ${{ matrix.old-version }} || echo $? | grep 1 && lando version
68 changes: 57 additions & 11 deletions .github/workflows/pr-posix-script-versions-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

jobs:
setup-lando-posix-versions-test:
setup-lando-posix-version-input-test:
runs-on: ${{ matrix.os }}
env:
LANDO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -45,9 +45,6 @@ jobs:
- version: 'bin/lando'
check: 'v3.100.999-babylon.5'
os: macos-14
- version: 'set-with-envvar'
check: 'v3.22.0'
os: ubuntu-24.04

steps:
- name: Checkout code
Expand All @@ -56,11 +53,60 @@ jobs:
fetch-depth: 0
- name: Setup Lando version ${{ matrix.version }}
shell: bash
run: |
if [[ "${{ matrix.version }}" == "set-with-envvar" ]]; then
LANDO_VERSION=v3.22.0 ./setup-lando.sh --no-setup
else
./setup-lando.sh --version=${{ matrix.version }} --no-setup
fi
run: ./setup-lando.sh --version=${{ matrix.version }} --no-setup
- name: Test
shell: bash
run: lando version | grep -E '${{ matrix.check }}'

lando version | grep -E '${{ matrix.check }}'
setup-lando-posix-version-env-test:
runs-on: ${{ matrix.os }}
env:
LANDO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
include:
- version: '3'
check: 'v3.'
os: ubuntu-24.04
- version: 'v3.21.0-beta.10'
check: 'v3.21.0-beta.10'
os: macos-14
- version: '3-stable'
check: 'v3.'
os: ubuntu-24.04
- version: '3-edge'
check: 'v3.'
os: ubuntu-24.04
- version: '3-latest'
check: 'v3.'
os: ubuntu-24.04
- version: '3-dev'
check: 'v3\..*\..*-.*-.*'
os: ubuntu-24.04
- version: 'stable'
check: 'v3.'
os: macos-14
- version: 'edge'
check: 'v3.'
os: macos-14
- version: 'latest'
check: 'v3.'
os: macos-14
- version: 'dev'
check: 'v3.'
os: ubuntu-24.04
- version: 'bin/lando'
check: 'v3.100.999-babylon.5'
os: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Lando version ${{ matrix.version }}
shell: bash
run: LANDO_VERSION=${{ matrix.version }} ./setup-lando.sh --no-setup
- name: Test
shell: bash
run: lando version | grep -E '${{ matrix.check }}'
3 changes: 2 additions & 1 deletion .github/workflows/pr-windows-script-replacer-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ jobs:
}
if (-not (lando version | Select-String -Pattern "${{ matrix.old-version }}")) {
throw "Error: lando is not the version we expect!"
$reported = lando version
throw "Error: lando is not the version we expect! expected ${{ matrix.version}} but found $reported"
}
- name: Replace Lando with setup-script
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

### Changes

* Added `--syslink` to add symlinks to `/usr/local/bin` on POSIX install, see notes below
* Improved post-install `PATH` consideration
* Updated default `--dest` to `~/.lando/bin` on POSIX install
* Updated POSIX script to run `sudoless` if possible, see notes below

### Notes

* `--syslink` will be automatically set on `CI`
* `--syslink` will be automatically set if a `lando` already exists at `/usr/local/bin` and the invoking user has permission to edit it

## v3.5.0 - [November 22, 2024](https://github.com/lando/setup-lando/releases/tag/v3.5.0)

* Added `path` based installation to POSIX `setup-lando.sh` script
Expand Down
8 changes: 7 additions & 1 deletion bin/lando
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

'use strict';

console.log('v3.100.999-babylon.5');
// get args
const args = process.argv.slice(2);

// if we have "shellenv" then spoof
if (args.includes('shellenv')) console.log('export PATH="$HOME/.lando/bin${PATH+:$PATH}";');
// otherwise just go for version
else console.log('v3.100.999-babylon.5');
82 changes: 50 additions & 32 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Linux quickstart is to paste the below into a terminal and execute it.
/bin/bash -c "$(curl -fsSL https://get.lando.dev/setup-lando.sh)"
```

If you are looking to customize your install then [advanced usage](#advanced) if for you.
If you are looking to customize your install then [advanced usage](#advanced) is for you.

## Advanced

Expand All @@ -26,46 +26,64 @@ chmod +x ./setup-lando.sh

# get usage info
bash setup-lando.sh --help

# example advanced invocation
# note you will need to change these values to ones that make sense for you
# consult the usage and notes below for more into
bash setup-lando.sh \
--arch=x64 \
--dest=/Users/pirog/bin \
--fat \
--no-setup \
--os=linux \
--version=3.21.2 \
--debug \
--yes
```

### Usage

```bash
[NONINTERACTIVE=1] [CI=1] setup-lando.sh \
[--arch <x64|arm64>] \
[--debug] \
[--dest <path>] \
[--fat ] \
[--no-setup] \
[--version <version>] \
[--yes]
```
Usage: [NONINTERACTIVE=1] [CI=1] setup-lando.sh [options]

* `--arch <x64|arm64>`: Specifies the architecture to install (x64 or arm64). Defaults to the system architecture.
* `--debug`: Enables debug output.
* `--dest <path>`: Specifies the destination path for installation. Defaults to `/usr/local/bin`.
* `--fat`: Download the fat v3 Lando binary that comes with official plugins built-in.
* `--no-setup`: Skips running Lando's built-in setup script.
* `--version <version>`: Specifies the version of Lando to install. Defaults to `stable`.
* `--help`: Displays the help message.
* `--yes`: Skips all interactive prompts and installs with defaults
Options:
--arch installs for this arch [default: x64]
--dest installs in this directory [default: ~/.lando/bin]
--fat installs fat cli 3.21+ <4 only, not recommended
--no-setup installs without running lando setup 3.21+ <4 only
--os installs for this os [default: linux]
--syslink installs symlink in /usr/local/bin [default: auto]
--version installs this version [default: stable]
--debug shows debug messages
-h, --help displays this message
-y, --yes runs with all defaults and no prompts, sets NONINTERACTIVE=1

Environment Variables:
NONINTERACTIVE installs without prompting for user input
CI installs in CI mode (e.g. does not prompt for user input)
```

Some notes on advanced usage:

* If you want to install without the `sudo` password requirement then set `--dest` to a location to which your user has `write` permission. Note that you may still need `sudo` for downstream setup tasks eg if you need to install Docker Engine.
* If you are running in `CI` then `--syslink` will be assumed
* If you have an existing installation of `lando` in `/usr/local/bin` and can write to that location then `--syslink` will be assumed
* If you want to customize the behavior of `lando setup` use `--no-setup` and then manually invoke [`lando setup`](https://docs.lando.dev/cli/setup.html) after install is complete.
* If you run in a non-tty environment eg GitHub Actions then `--yes` will be assumed
* If you use `--yes` it is equivalent to setting `NONINTERACTIVE=1`

#### Environment Variables

If you do not wish to download the script you can set options with environment variables and `curl` the script.

```bash
LANDO_VERSION=stable
LANDO_INSTALLER_ARCH=auto
LANDO_INSTALLER_DEBUG=0
LANDO_INSTALLER_DEST="~/.lando/bin"
LANDO_INSTALLER_FAT=0
LANDO_INSTALLER_OS=macos
LANDO_INSTALLER_SETUP=auto
LANDO_INSTALLER_SYSLINK=auto
```

#### Examples

These are equivalent commands and meant to demostrate environment variable usage vs direct invocation.

```bash
# use envvars
LANDO_VERSION=3.23.11 \
LANDO_INSTALLER_DEBUG=1 \
LANDO_INSTALLER_SYSLINK=1 \
/bin/bash -c "$(curl -fsSL https://get.lando.dev/setup-lando.sh)"

# invoke directly
bash setup-lando.sh --version "3.23.11" --debug --syslink
```
85 changes: 51 additions & 34 deletions docs/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ description: Install Lando on macOS

The macOS quickstart is to paste the below into a terminal and execute it.

```bash
```zsh
/bin/bash -c "$(curl -fsSL https://get.lando.dev/setup-lando.sh)"
```

If you are looking to customize your install then [advanced usage](#advanced) if for you.
If you are looking to customize your install then [advanced usage](#advanced) is for you.

## Advanced

Expand All @@ -26,47 +26,64 @@ chmod +x ./setup-lando.sh

# get usage info
bash setup-lando.sh --help

# example advanced invocation
# note you will need to change these values to ones that make sense for you
# consult the usage and notes below for more into
bash setup-lando.sh \
--arch=arm64 \
--dest=/Users/pirog/bin \
--fat \
--no-setup \
--os=macos \
--version=3.21.2 \
--debug \
--yes
```

### Usage

```zsh
[NONINTERACTIVE=1] [CI=1] setup-lando.sh \
[--arch <x64|arm64>] \
[--debug] \
[--dest <path>] \
[--fat ] \
[--no-setup] \
[--os <os>] \
[--version <version>] \
[--yes]
```
Usage: [NONINTERACTIVE=1] [CI=1] setup-lando.sh [options]

Options:
--arch installs for this arch [default: arm64]
--dest installs in this directory [default: ~/.lando/bin]
--fat installs fat cli 3.21+ <4 only, not recommended
--no-setup installs without running lando setup 3.21+ <4 only
--os installs for this os [default: macos]
--syslink installs symlink in /usr/local/bin [default: auto]
--version installs this version [default: stable]
--debug shows debug messages
-h, --help displays this message
-y, --yes runs with all defaults and no prompts, sets NONINTERACTIVE=1

* `--arch <x64|arm64>`: Specifies the architecture to install (x64 or arm64). Defaults to the system architecture.
* `--debug`: Enables debug output.
* `--dest <path>`: Specifies the destination path for installation. Defaults to `/usr/local/bin`.
* `--fat`: Download the fat v3 Lando binary that comes with official plugins built-in.
* `--no-setup`: Skips running Lando's built-in setup script.
* `--version <version>`: Specifies the version of Lando to install. Defaults to `stable`.
* `--help`: Displays the help message.
* `--yes`: Skips all interactive prompts and installs with defaults
Environment Variables:
NONINTERACTIVE installs without prompting for user input
CI installs in CI mode (e.g. does not prompt for user input)
```

Some notes on advanced usage:

* If you want to install without the `sudo` password requirement then set `--dest` to a location to which your user has `write` permission. Note that you may still need `sudo` for downstream setup tasks eg if you need to install Docker Desktop.
* If you are running in `CI` then `--syslink` will be assumed
* If you have an existing installation of `lando` in `/usr/local/bin` and can write to that location then `--syslink` will be assumed
* If you want to customize the behavior of `lando setup` use `--no-setup` and then manually invoke [`lando setup`](https://docs.lando.dev/cli/setup.html) after install is complete.
* If you run in a non-tty environment eg GitHub Actions then `--yes` will be assumed
* If you use `--yes` it is equivalent to setting `NONINTERACTIVE=1`

#### Environment Variables

If you do not wish to download the script you can set options with environment variables and `curl` the script.

```zsh
LANDO_VERSION=stable
LANDO_INSTALLER_ARCH=auto
LANDO_INSTALLER_DEBUG=0
LANDO_INSTALLER_DEST="~/.lando/bin"
LANDO_INSTALLER_FAT=0
LANDO_INSTALLER_OS=macos
LANDO_INSTALLER_SETUP=auto
LANDO_INSTALLER_SYSLINK=auto
```

#### Examples

These are equivalent commands and meant to demostrate environment variable usage vs direct invocation.

```zsh
# use envvars
LANDO_VERSION=3.23.11 \
LANDO_INSTALLER_DEBUG=1 \
LANDO_INSTALLER_SYSLINK=1 \
/bin/bash -c "$(curl -fsSL https://get.lando.dev/setup-lando.sh)"

# invoke directly
bash setup-lando.sh --version "3.23.11" --debug --syslink
```
Loading

0 comments on commit 392595d

Please sign in to comment.