Remove GIT_REPO and DB_TYPE prompts from bootstrap.sh

Always clone this repo (the full app) and always use SQLite, per updated deployment requirements. Drops now-dead mysql/fresh-scaffold branches accordingly.
This commit is contained in:
Ghassan Yusuf 2026-08-04 11:51:58 +03:00
parent a2c35c5915
commit 5c699a221c
2 changed files with 30 additions and 101 deletions

View File

@ -1,6 +1,6 @@
# webappAIO LXC Bootstrap
Spin up a fully configured development container in one step: SSH, Apache/PHP/MariaDB or SQLite, a Laravel API backend (`backend/`) + React/Vite frontend (`frontend/`), a self-hosted Mosquitto MQTT broker (Docker), [code-server](https://code-server.dev), and [Claude Code](https://docs.claude.com/en/docs/claude-code) — all from a single command pasted into a fresh Proxmox LXC.
Spin up a fully configured development container in one step: SSH, Apache/PHP/SQLite, the Laravel API backend (`backend/`) + React/Vite frontend (`frontend/`) from this repo, a self-hosted Mosquitto MQTT broker (Docker), [code-server](https://code-server.dev), and [Claude Code](https://docs.claude.com/en/docs/claude-code) — all from a single command pasted into a fresh Proxmox LXC.
## Quick start
@ -13,26 +13,18 @@ curl -fsSL https://git.innovator.bh/ghassan/webappAIO/raw/branch/main/bootstrap.
You'll be prompted for:
- Project name
- Git repository to clone (leave blank to scaffold a bare backend/frontend pair instead — see below)
- Database: `mysql` or `sqlite`
- MariaDB username/password/database (only if you chose `mysql`)
- Seeded Super Admin email/username/password
The script always clones this repo (`https://git.innovator.bh/ghassan/webappAIO.git`) — the full RBAC + 2FA + MQTT-realtime + Users-management app described in [`claude-project-prompt.md`](./claude-project-prompt.md) — and always uses SQLite. Neither is prompted for.
When it finishes you'll have a running API, a Mosquitto broker, code-server, and Claude Code installed, plus a Super Admin account ready to log in with.
### Blank `GIT_REPO` vs. cloning this repo
- **Blank** scaffolds a fresh Laravel install in `backend/` and a fresh Vite React-TS app in `frontend/`, with the core packages already required (Sanctum, `spatie/laravel-permission`, `pragmarx/google2fa-laravel`, `php-mqtt/laravel-client`) — the foundation to build the rest of [`claude-project-prompt.md`](./claude-project-prompt.md)'s architecture on top of, not the finished app.
- **`GIT_REPO=https://git.innovator.bh/ghassan/webappAIO.git`** clones this repo, which already contains the full RBAC + 2FA + MQTT-realtime + Users-management implementation described in that prompt.
## Fully unattended install
Skip every prompt by exporting variables before running the script (useful for scripted LXC provisioning):
```bash
APP_NAME=myapp \
GIT_REPO="" \
DB_TYPE=sqlite \
SUPER_ADMIN_EMAIL=admin@myapp.test \
SUPER_ADMIN_USERNAME=admin \
SUPER_ADMIN_PASSWORD='change-me' \
@ -44,11 +36,6 @@ bash bootstrap.sh
| Variable | Description | Default |
|---|---|---|
| `APP_NAME` | Project directory name under `/var/www` | `laravel-app` |
| `GIT_REPO` | Git URL to clone; blank scaffolds a bare backend/frontend pair | *(blank)* |
| `DB_TYPE` | `mysql` or `sqlite` | `sqlite` |
| `DB_USER` | MariaDB username (`mysql` only) | `laravel_user` |
| `DB_PASS` | MariaDB password (`mysql` only) | random |
| `DB_NAME` | MariaDB database name (`mysql` only) | `laravel_db` |
| `SUPER_ADMIN_EMAIL` | Seeded Super Admin email | `superadmin@example.com` |
| `SUPER_ADMIN_USERNAME` | Seeded Super Admin username | `superadmin` |
| `SUPER_ADMIN_PASSWORD` | Seeded Super Admin password | random |
@ -61,11 +48,11 @@ bash bootstrap.sh
1. **Base system**`apt update/upgrade`, installs `sudo curl git wget unzip`.
2. **SSH** — installs and enables `openssh-server`; on TurnKey Core containers enables `AllowTcpForwarding`, on other distros enables `PermitRootLogin yes` (needed for VS Code Remote-SSH / port tunneling).
3. **Docker + Mosquitto** — installs Docker Engine + Compose plugin, generates per-role Mosquitto broker credentials, brings up the `mosquitto` container (MQTT on 1883, WebSockets on 9001).
4. **Laravel + React stack** — Apache, PHP + required extensions, MariaDB or SQLite, Composer, Node.js, clones or scaffolds `backend/` (Laravel) and `frontend/` (Vite React-TS), sets permissions, configures an Apache vhost pointing at `backend/public`, generates `.env` (DB, MQTT, Super Admin, Sanctum/CORS), runs `key:generate`, `migrate`, and `db:seed`.
4. **Laravel + React stack** — Apache, PHP + SQLite extension, Composer, Node.js, clones this repo into `backend/` (Laravel) and `frontend/` (Vite React-TS), sets permissions, configures an Apache vhost pointing at `backend/public`, generates `.env` (DB, MQTT, Super Admin, Sanctum/CORS), runs `key:generate`, `migrate`, and `db:seed`.
5. **Queue worker** — installs and starts a systemd unit (`<app-name>-queue`) running `php artisan queue:work`, required for MQTT events to actually publish.
6. **code-server** — browser-based VS Code, so you can edit the app over SSH without a local editor.
7. **Claude Code**`npm install -g @anthropic-ai/claude-code`.
8. Prints a summary with the app path, DB type, container IP, Super Admin credentials, and next steps.
8. Prints a summary with the app path, container IP, Super Admin credentials, and next steps.
## After install

View File

@ -10,22 +10,15 @@
#
# All prompts can be skipped by exporting env vars before running, e.g.:
#
# APP_NAME=myapp GIT_REPO="" DB_TYPE=sqlite \
# APP_NAME=myapp SUPER_ADMIN_PASSWORD='change-me' \
# bash bootstrap.sh
#
# GIT_REPO blank scaffolds a bare Laravel (backend/) + Vite React (frontend/)
# pair with the core packages (Sanctum, spatie/laravel-permission,
# google2fa-laravel, php-mqtt/laravel-client) installed — the foundation to
# build on, not the full RBAC/2FA/Users-module app. Point GIT_REPO at this
# repo (https://git.innovator.bh/ghassan/webappAIO.git) to get that app.
# This script always clones https://git.innovator.bh/ghassan/webappAIO.git
# (the full RBAC/2FA/MQTT/Users-module app) and always uses SQLite — neither
# is prompted for.
#
# Supported env vars (all optional, will be prompted for if unset and a tty is available):
# APP_NAME Project directory name (default: laravel-app)
# GIT_REPO Git URL to clone, blank = new project (default: "")
# DB_TYPE mysql | sqlite (default: sqlite)
# DB_USER MariaDB user (only used if DB_TYPE=mysql)
# DB_PASS MariaDB password (only used if DB_TYPE=mysql)
# DB_NAME MariaDB database name (only used if DB_TYPE=mysql)
# SUPER_ADMIN_EMAIL Seeded Super Admin email (default: superadmin@example.com)
# SUPER_ADMIN_USERNAME Seeded Super Admin username (default: superadmin)
# SUPER_ADMIN_PASSWORD Seeded Super Admin password (default: random)
@ -49,7 +42,7 @@ prompt() {
local var_name="$1" prompt_text="$2" default_value="${3:-}" silent="${4:-no}"
# A var counts as "provided" if it's set at all, even to an intentionally
# blank value (e.g. GIT_REPO="" means "scaffold a new project").
# blank value.
if declare -p "$var_name" &>/dev/null; then
return
fi
@ -84,19 +77,11 @@ fi
log "webappAIO LXC Bootstrap"
prompt APP_NAME "Project name (directory name) [laravel-app]: " "laravel-app"
prompt GIT_REPO "Git repository URL to clone (blank = new project): " ""
prompt DB_TYPE "Database type, mysql or sqlite [sqlite]: " "sqlite"
if [[ "$DB_TYPE" != "mysql" && "$DB_TYPE" != "sqlite" ]]; then
warn "Unrecognized DB_TYPE '$DB_TYPE', defaulting to sqlite."
# Fixed, not prompted for: this script always deploys the full webappAIO app
# against SQLite.
GIT_REPO="https://git.innovator.bh/ghassan/webappAIO.git"
DB_TYPE="sqlite"
fi
if [ "$DB_TYPE" = "mysql" ]; then
prompt DB_USER "MariaDB username [laravel_user]: " "laravel_user"
prompt DB_PASS "MariaDB password: " "$(openssl rand -hex 12)" "yes"
prompt DB_NAME "MariaDB database name [laravel_db]: " "laravel_db"
fi
prompt SUPER_ADMIN_EMAIL "Super Admin email [superadmin@example.com]: " "superadmin@example.com"
prompt SUPER_ADMIN_USERNAME "Super Admin username [superadmin]: " "superadmin"
@ -160,13 +145,8 @@ systemctl start docker
log "Installing Apache, PHP and common extensions"
apt-get install -y apache2 php php-curl php-bcmath php-json php-mbstring php-xml php-tokenizer php-zip php-gd
if [ "$DB_TYPE" = "mysql" ]; then
log "Installing MariaDB and PHP MySQL extension"
apt-get install -y mariadb-server php-mysql
else
log "Installing PHP SQLite extension"
apt-get install -y php-sqlite3
fi
log "Installing Composer"
curl -sS https://getcomposer.org/installer | php
@ -176,38 +156,9 @@ log "Installing Node.js LTS"
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
if [ "$DB_TYPE" = "mysql" ]; then
log "Creating MariaDB database and user"
mysql -e "CREATE DATABASE IF NOT EXISTS \`$DB_NAME\`;"
mysql -e "CREATE USER IF NOT EXISTS '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
mysql -e "GRANT ALL PRIVILEGES ON \`$DB_NAME\`.* TO '$DB_USER'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
fi
mkdir -p /var/www
cd /var/www
if [ -z "$GIT_REPO" ]; then
log "Scaffolding new project: $APP_NAME (backend/ + frontend/)"
mkdir -p "$APP_NAME"
composer create-project --prefer-dist laravel/laravel "$APP_NAME/backend"
cd "$APP_NAME/backend"
log "Installing core backend packages (Sanctum, RBAC, 2FA, MQTT)"
php artisan install:api --without-migration-prompt
composer require spatie/laravel-permission pragmarx/google2fa-laravel bacon/bacon-qr-code php-mqtt/laravel-client
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan vendor:publish --provider="PhpMqtt\Client\MqttClientServiceProvider"
php artisan vendor:publish --provider="PragmaRX\Google2FALaravel\ServiceProvider"
cd /var/www/"$APP_NAME"
npx --yes create-vite@latest frontend -- --template react-ts
cd frontend
npm install
npm install -D tailwindcss @tailwindcss/vite
npm install react-router-dom @tanstack/react-query axios mqtt qrcode
cd /var/www/"$APP_NAME"
else
log "Cloning $GIT_REPO into $APP_NAME"
git clone "$GIT_REPO" "$APP_NAME"
cd "$APP_NAME/backend"
@ -215,15 +166,12 @@ else
cd ../frontend
npm install
cd /var/www/"$APP_NAME"
fi
cd "/var/www/$APP_NAME/backend"
if [ "$DB_TYPE" = "sqlite" ]; then
log "Creating SQLite database file"
mkdir -p database
touch database/database.sqlite
fi
log "Setting file permissions"
chown -R www-data:www-data "/var/www/$APP_NAME"
@ -258,17 +206,11 @@ if [ ! -f .env ] && [ -f .env.example ]; then
fi
if [ -f .env ]; then
sed -i "s/^DB_CONNECTION=.*/DB_CONNECTION=$DB_TYPE/" .env
if [ "$DB_TYPE" = "mysql" ]; then
sed -i "s/^DB_DATABASE=.*/DB_DATABASE=$DB_NAME/" .env
sed -i "s/^DB_USERNAME=.*/DB_USERNAME=$DB_USER/" .env
sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=$DB_PASS/" .env
else
sed -i "s/^DB_CONNECTION=.*/DB_CONNECTION=sqlite/" .env
sed -i "s|^DB_DATABASE=.*|DB_DATABASE=$(pwd)/database/database.sqlite|" .env
sed -i "s/^DB_USERNAME=.*/DB_USERNAME=/" .env
sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=/" .env
fi
fi
# ---------------------------------------------------------------------------
# 5. Mosquitto config + matching backend secrets