Skip to content

Commit a949d8e

Browse files
committed
Fix review issues: harden auth gate, fix AWS VPN detection, improve docs
- Make GitHub auth a hard gate — abort setup if auth fails or is cancelled, so repo cloning is guaranteed - Fix AWS VPN Client detection on Linux (GUI app at /opt/awsvpnclient, no PATH binary) — fixes CI doctor failure - Support ARM64 for AWS CLI and VPN Client Ubuntu installs - Add --yes to gpg --dearmor calls so 1Password re-installs don't fail - Ensure unzip is present before AWS CLI install - Use dpkg -s instead of dpkg -l for reliable package detection - Guard docker compose doctor check on docker being installed - Rename misleading variable in migrate.sh - Update README with platforms up top, local run/doctor instructions - Update ARCHITECTURE.md repo structure and AGENTS.md shellcheck command
1 parent 84f5acd commit a949d8e

12 files changed

Lines changed: 89 additions & 38 deletions

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ It does **NOT** install:
8282

8383
## Commands
8484

85-
- `shellcheck -x setup.sh doctor.sh lib/migrate.sh` — Lint bash scripts
85+
- `shellcheck -x setup.sh doctor.sh lib/*.sh` — Lint bash scripts
8686
- `bash -n setup.sh` — Check for syntax errors without executing
8787
- `bash doctor.sh` — Run post-setup diagnostic checks
8888
- `date +%s` — Generate a migration timestamp

ARCHITECTURE.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,29 @@ cd <project> && bin/setup
143143
```
144144
devsetup/
145145
├── setup.sh # Main bootstrap script (bash, entry point)
146+
├── doctor.sh # Read-only diagnostic script (verifies setup.sh outcomes)
146147
├── lib/
147-
│ └── migrate.sh # Migration runner (sourced by setup.sh)
148+
│ ├── common.sh # Shared helpers: OS detection, cmd_exists, formatting
149+
│ ├── migrate.sh # Migration runner (sourced by setup.sh)
150+
│ ├── packages_setup.sh # Package manager bootstrap (brew/apt/pacman)
151+
│ ├── git_setup.sh # git and GitHub CLI installation + auth
152+
│ ├── mise_setup.sh # mise and Ruby (global default) installation
153+
│ ├── 1password_setup.sh # 1Password CLI installation
154+
│ ├── build_setup.sh # Build essentials (Xcode CLT / build-essential / base-devel)
155+
│ ├── docker_setup.sh # Docker, Docker Compose, Colima installation
156+
│ ├── aws_setup.sh # AWS CLI and AWS VPN Client installation
157+
│ ├── repos_setup.sh # ~/Work directory and repository cloning
158+
│ ├── packages_doctor.sh # Doctor checks for each corresponding setup module
159+
│ ├── git_doctor.sh
160+
│ ├── mise_doctor.sh
161+
│ ├── 1password_doctor.sh
162+
│ ├── build_doctor.sh
163+
│ ├── docker_doctor.sh
164+
│ ├── aws_doctor.sh
165+
│ ├── repos_doctor.sh
166+
│ └── migrate_doctor.sh
148167
├── migrations/ # Run-once transition scripts
149168
│ └── .gitkeep
150-
├── doctor.sh # Read-only diagnostic script (verifies setup.sh outcomes)
151169
├── .github/
152170
│ └── workflows/
153171
│ └── ci.yml # GitHub Actions: shellcheck + Ubuntu setup + doctor

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
Bootstraps a developer machine with the baseline tools required to work on Trusted projects.
44

5+
**Supported platforms:** MacOS · Ubuntu · Omarchy
6+
57
## What it installs
68

7-
- **Homebrew** (macOS) / apt updates (Ubuntu) / pacman updates (Arch)
9+
- **package management**
10+
- homebrew for MacOS
11+
- apt updates for Ubuntu
12+
- pacman/yay updates for Omarchy
813
- **git** — version control
914
- **gh** — GitHub CLI (+ authenticates with GitHub)
1015
- **mise** — version manager for Ruby, Node, etc.
@@ -32,34 +37,37 @@ cd <project> && bin/setup
3237

3338
## Re-running
3439

35-
The script is idempotent. Run it again at any time to ensure your tools are up to date and apply new migrations:
40+
The script is idempotent. Run it again at any time to ensure your tools are up to date and apply new migrations.
41+
42+
Locally from the cloned repo at `~/Work/devsetup`:
43+
44+
```bash
45+
bash ~/Work/devsetup/setup.sh
46+
```
47+
48+
Via curl (fetches latest from GitHub):
3649

3750
```bash
3851
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trusted/devsetup/main/setup.sh)"
3952
```
4053

41-
## Migrations
4254

43-
One-time environment changes are tracked as migration scripts in `migrations/`. They run automatically at the end of setup and are only executed once per machine.
55+
## Diagnosing your environment
4456

45-
To re-run a specific migration:
57+
Run `doctor.sh` at any time to check that all expected tools are installed and no migrations are pending. It never changes anything — only reports:
4658

4759
```bash
48-
./setup.sh --rerun <timestamp>
60+
bash ~/Work/devsetup/doctor.sh
4961
```
5062

51-
## Supported platforms
52-
53-
- macOS (Homebrew)
54-
- Ubuntu / Debian (apt)
55-
- Omarchy (pacman/yay)
63+
## Migrations
5664

57-
## Diagnosing your environment
65+
One-time environment changes are tracked as migration scripts in `migrations/`. They run automatically at the end of setup and are only executed once per machine.
5866

59-
Run `doctor.sh` at any time to check that all expected tools are installed and no migrations are pending. It never changes anything — only reports:
67+
To re-run a specific migration:
6068

6169
```bash
62-
bash doctor.sh
70+
bash ~/Work/devsetup/setup.sh --rerun <timestamp>
6371
```
6472

6573
## How it works

lib/1password_setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ else
1717
ubuntu)
1818
# Official 1Password CLI installation for Debian/Ubuntu
1919
curl -sS https://downloads.1password.com/linux/keys/1password.asc | \
20-
sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg 2>/dev/null
20+
sudo gpg --yes --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg 2>/dev/null
2121
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | \
2222
sudo tee /etc/apt/sources.list.d/1password.list > /dev/null
2323
sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/
2424
curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | \
2525
sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol > /dev/null
2626
sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22
2727
curl -sS https://downloads.1password.com/linux/keys/1password.asc | \
28-
sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg 2>/dev/null
28+
sudo gpg --yes --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg 2>/dev/null
2929
sudo apt-get update -qq
3030
sudo apt-get install -y -qq 1password-cli
3131
;;

lib/aws_doctor.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ case "$OS" in
3636
fi
3737
;;
3838
ubuntu|arch)
39-
if cmd_exists awsvpnclient; then
39+
# AWS VPN Client is a GUI app installed to /opt/awsvpnclient (no PATH binary)
40+
if [ -d "/opt/awsvpnclient" ]; then
4041
check_pass "AWS VPN Client is installed"
4142
else
4243
check_fail "AWS VPN Client is not installed"

lib/aws_setup.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ else
1919
brew install awscli
2020
;;
2121
ubuntu)
22-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip
22+
# Ensure unzip is available (not always present on minimal Ubuntu installs)
23+
if ! cmd_exists unzip; then
24+
sudo apt-get install -y -qq unzip
25+
fi
26+
aws_arch="x86_64"
27+
if [ "$(uname -m)" = "aarch64" ]; then
28+
aws_arch="aarch64"
29+
fi
30+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${aws_arch}.zip" -o /tmp/awscliv2.zip
2331
unzip -qo /tmp/awscliv2.zip -d /tmp/aws-install
2432
sudo /tmp/aws-install/aws/install
2533
rm -rf /tmp/awscliv2.zip /tmp/aws-install
@@ -53,17 +61,19 @@ case "$OS" in
5361
fi
5462
;;
5563
ubuntu)
56-
if cmd_exists awsvpnclient; then
64+
# AWS VPN Client is a GUI app installed to /opt/awsvpnclient (no PATH binary)
65+
if [ -d "/opt/awsvpnclient" ]; then
5766
fmt_ok "AWS VPN Client already installed"
5867
else
5968
fmt_install "AWS VPN Client"
60-
curl -fsSL "https://d20adtppz83p9s.cloudfront.net/GTK/latest/awsvpnclient_amd64.deb" -o /tmp/awsvpnclient.deb
69+
vpn_arch="$(dpkg --print-architecture)"
70+
curl -fsSL "https://d20adtppz83p9s.cloudfront.net/GTK/latest/awsvpnclient_${vpn_arch}.deb" -o /tmp/awsvpnclient.deb
6171
sudo apt-get install -y -qq /tmp/awsvpnclient.deb
6272
rm -f /tmp/awsvpnclient.deb
6373
fi
6474
;;
6575
arch)
66-
if cmd_exists awsvpnclient; then
76+
if [ -d "/opt/awsvpnclient" ]; then
6777
fmt_ok "AWS VPN Client already installed"
6878
else
6979
fmt_install "AWS VPN Client"

lib/build_doctor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ case "$OS" in
2525
fi
2626
;;
2727
ubuntu)
28-
if dpkg -l build-essential > /dev/null 2>&1; then
28+
if dpkg -s build-essential > /dev/null 2>&1; then
2929
check_pass "build-essential is installed"
3030
else
3131
check_fail "build-essential is not installed"

lib/build_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ case "$OS" in
1818
fi
1919
;;
2020
ubuntu)
21-
if dpkg -l build-essential > /dev/null 2>&1; then
21+
if dpkg -s build-essential > /dev/null 2>&1; then
2222
fmt_ok "build-essential already installed"
2323
else
2424
fmt_install "build-essential"

lib/docker_doctor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fi
2727

2828
fmt_header "Docker Compose"
2929

30-
if docker compose version > /dev/null 2>&1; then
30+
if cmd_exists docker && docker compose version > /dev/null 2>&1; then
3131
version_output="$(docker compose version --short 2>&1)"
3232
check_pass "Docker Compose is installed: $version_output"
3333
else

lib/git_setup.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,23 @@ fmt_header "GitHub Authentication"
5959
if gh auth status > /dev/null 2>&1; then
6060
fmt_ok "Already authenticated with GitHub"
6161
elif [ "${CI:-}" = "true" ]; then
62-
echo " Skipping interactive GitHub auth (CI environment detected)."
63-
echo " Set GH_TOKEN to authenticate gh in CI."
62+
echo ""
63+
echo "ERROR: Not authenticated with GitHub in CI."
64+
echo "Set GH_TOKEN or GITHUB_TOKEN in your workflow environment."
65+
exit 1
6466
else
6567
echo " GitHub CLI needs to be authenticated."
6668
echo " This will open a browser window for GitHub login."
6769
echo ""
6870
gh auth login --web --git-protocol https
71+
72+
# Verify authentication succeeded before continuing
73+
if ! gh auth status > /dev/null 2>&1; then
74+
echo ""
75+
echo "ERROR: GitHub authentication failed or was cancelled."
76+
echo "Setup cannot continue without GitHub access."
77+
echo "Run this script again and complete the authentication step."
78+
exit 1
79+
fi
80+
fmt_ok "Authenticated with GitHub"
6981
fi

0 commit comments

Comments
 (0)