From fcb8e932f148c5fa8a148c5a2a2b0f1c776e7a4e Mon Sep 17 00:00:00 2001 From: MickLesk Date: Thu, 2 Apr 2026 21:04:56 +0200 Subject: [PATCH] fix(netboot-xyz): rename install script to match naming convention --- install/ente-install.sh | 141 ++++++++++++++---- ....xyz-install.sh => netboot-xyz-install.sh} | 0 json/ente.json | 16 +- 3 files changed, 120 insertions(+), 37 deletions(-) rename install/{netboot.xyz-install.sh => netboot-xyz-install.sh} (100%) diff --git a/install/ente-install.sh b/install/ente-install.sh index 6b838598..cee18d79 100644 --- a/install/ente-install.sh +++ b/install/ente-install.sh @@ -336,37 +336,62 @@ msg_ok "Configured Caddy" msg_info "Creating helper scripts" cat <<'SETUP' >/usr/local/bin/ente-setup #!/usr/bin/env bash +<<<<<<< HEAD set -e LOCAL_IP=$(hostname -I | awk '{print $1}') -DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')" -DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')" - echo "=== Ente First-Time Setup ===" echo "" read -r -p "Enter your account email: " EMAIL if [ -z "$EMAIL" ]; then echo "Error: Email is required"; exit 1; fi +======= +echo "Searching for verification codes in museum logs..." +journalctl -u ente-museum --no-pager | grep -oP 'SendEmailOTT.*ott:\s*\K\d+' | tail -5 +if [[ $? -ne 0 ]] || [[ -z "$(journalctl -u ente-museum --no-pager | grep -oP 'ott:\s*\K\d+' | tail -1)" ]]; then + echo "No codes found via ott pattern. Showing recent relevant logs:" + journalctl -u ente-museum --no-pager -n 50 | grep -i "verification\|verify\|code\|ott" | tail -20 +fi +EOF +chmod +x /usr/local/bin/ente-get-verification + +cat <<'SETUPEOF' >/usr/local/bin/ente-setup +#!/usr/bin/env bash +LOCAL_IP=$(hostname -I | awk '{print $1}') +DB_NAME="ente_db" +DB_USER="ente" + +echo "=== Ente First-Time Setup ===" +echo "" +read -r -p "Enter your account email: " EMAIL + +if [[ -z "$EMAIL" ]]; then + echo "Error: Email is required." + exit 1 +fi +>>>>>>> bb7e2e03 (fix(postiz,ente,lobehub): address testing feedback) echo "" echo "Step 1/4: Register your account" echo " Open the web UI: http://${LOCAL_IP}:3000" +<<<<<<< HEAD echo " Create an account with: $EMAIL" +======= +echo " Create an account with: ${EMAIL}" +>>>>>>> bb7e2e03 (fix(postiz,ente,lobehub): address testing feedback) echo "" read -r -p "Press ENTER after you submitted the signup form..." echo "" echo "Step 2/4: Getting verification code from logs..." +<<<<<<< HEAD for i in $(seq 1 10); do OTT=$(journalctl -u ente-museum --no-pager -n 100 2>/dev/null | grep -oP "Skipping sending email to ${EMAIL}.*Verification code: \K[0-9]+" | tail -1) if [ -n "$OTT" ]; then break; fi sleep 1 done -if [ -z "$OTT" ]; then - OTT=$(journalctl -u ente-museum --no-pager -n 200 2>/dev/null | grep -oP 'ott:\s*\K\d+' | tail -1) -fi if [ -z "$OTT" ]; then echo "Could not auto-detect code. Searching all recent codes..." - journalctl -u ente-museum --no-pager -n 200 | grep -i "Verification code\|ott" | tail -5 + journalctl -u ente-museum --no-pager -n 200 | grep "Verification code" | tail -5 echo "" echo "Enter the code shown above in the web UI, then press ENTER." read -r -p "Press ENTER after verification..." @@ -377,7 +402,9 @@ else read -r -p "Press ENTER after you verified the code..." fi -USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")' ORDER BY user_id LIMIT 1;") +DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')" +DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')" +USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users ORDER BY user_id LIMIT 1;") if [ -z "$USER_ID" ]; then echo "Error: No verified users found in database." echo "Make sure you completed the verification step in the web UI." @@ -388,11 +415,55 @@ echo "Found user ID: $USER_ID" echo "" echo "Step 3/4: Whitelisting admin in museum.yaml..." if grep -q "^internal:" /opt/ente/server/museum.yaml; then - if ! grep -qF "$EMAIL" /opt/ente/server/museum.yaml; then - sed -i "/admins:/a\\ - $EMAIL" /opt/ente/server/museum.yaml - fi + sed -i "/^ admin:/d" /opt/ente/server/museum.yaml + sed -i "/^internal:/a\\ admin: $USER_ID" /opt/ente/server/museum.yaml else - printf '\ninternal:\n admins:\n - %s\n' "$EMAIL" >> /opt/ente/server/museum.yaml + printf '\ninternal:\n admin: %s\n' "$USER_ID" >> /opt/ente/server/museum.yaml +fi +systemctl restart ente-museum +sleep 2 +echo "Done." + +echo "" +echo "Step 4/4: Adding account to Ente CLI & upgrading subscription..." +mkdir -p /opt/ente_data/photos +export ENTE_CLI_SECRETS_PATH=/opt/ente/cli-config/secrets.txt +printf 'photos\n/opt/ente_data/photos\n' | ente account add +ente admin update-subscription -a "$EMAIL" -u "$EMAIL" --no-limit True +echo "" +echo "=== Setup Complete ===" +echo "You can now use Ente Photos/Auth with unlimited storage." +SETUP +chmod +x /usr/local/bin/ente-setup +======= +sleep 3 +CODE=$(journalctl -u ente-museum --no-pager -n 100 | grep -oP 'ott:\s*\K\d+' | tail -1) +if [[ -n "$CODE" ]]; then + echo " Your verification code: ${CODE}" + echo " Enter this code in the web UI to complete registration." +else + echo " Could not find code automatically. Check manually:" + echo " journalctl -u ente-museum --no-pager | grep -i ott" +fi +echo "" +read -r -p "Press ENTER after you verified the code..." + +USER_ID=$(su -c "psql -t -d ${DB_NAME} -c \"SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")';\"" postgres 2>/dev/null | xargs) +echo "Found user ID: ${USER_ID}" + +echo "" +echo "Step 3/4: Whitelisting admin in museum.yaml..." +if grep -q "internal:" /opt/ente/server/museum.yaml; then + if ! grep -qF "$EMAIL" /opt/ente/server/museum.yaml; then + sed -i "/admins:/a\\ - ${EMAIL}" /opt/ente/server/museum.yaml + fi +else + cat <>/opt/ente/server/museum.yaml + +internal: + admins: + - ${EMAIL} +ADMEOF fi systemctl restart ente-museum sleep 2 @@ -400,43 +471,47 @@ echo "Done." echo "" echo "Step 4/4: Upgrading subscription..." -PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};" 2>/dev/null -ROWS=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};" 2>/dev/null) -if [ "$ROWS" = "0" ]; then - PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');" 2>/dev/null +if [[ -n "$USER_ID" ]]; then + su -c "psql -d ${DB_NAME} -c \"UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};\"" postgres 2>/dev/null + ROWS=$(su -c "psql -t -d ${DB_NAME} -c \"SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};\"" postgres 2>/dev/null | xargs) + if [[ "$ROWS" == "0" ]]; then + su -c "psql -d ${DB_NAME} -c \"INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');\"" postgres 2>/dev/null + fi + echo "Subscription upgraded to unlimited storage." +else + echo "Warning: Could not find user ID. Try running: ente-upgrade-subscription ${EMAIL}" fi -echo "Subscription upgraded to unlimited storage." + echo "" -echo "=== Setup Complete ===" -echo "You can now use Ente Photos/Auth with unlimited storage." +echo "=== Setup complete ===" echo "Access Ente Photos at: http://${LOCAL_IP}:3000" -SETUP +SETUPEOF chmod +x /usr/local/bin/ente-setup cat <<'EOF' >/usr/local/bin/ente-upgrade-subscription #!/usr/bin/env bash if [ -z "$1" ]; then - echo "Usage: ente-upgrade-subscription " - echo "Example: ente-upgrade-subscription user@example.com" - exit 1 + echo "Usage: ente-upgrade-subscription " + echo "Example: ente-upgrade-subscription user@example.com" + exit 1 fi EMAIL="$1" -DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')" -DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')" +DB_NAME="ente_db" echo "Upgrading subscription for: $EMAIL" -USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")' ORDER BY user_id LIMIT 1;") -if [ -z "$USER_ID" ]; then - echo "Error: User not found in database." - exit 1 +USER_ID=$(su -c "psql -t -d ${DB_NAME} -c \"SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")';\"" postgres 2>/dev/null | xargs) +if [[ -z "$USER_ID" ]]; then + echo "Error: User not found in database." + exit 1 fi -PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};" 2>/dev/null -ROWS=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};" 2>/dev/null) -if [ "$ROWS" = "0" ]; then - PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');" 2>/dev/null +su -c "psql -d ${DB_NAME} -c \"UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};\"" postgres 2>/dev/null +ROWS=$(su -c "psql -t -d ${DB_NAME} -c \"SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};\"" postgres 2>/dev/null | xargs) +if [[ "$ROWS" == "0" ]]; then + su -c "psql -d ${DB_NAME} -c \"INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');\"" postgres 2>/dev/null fi echo "Done. Subscription upgraded to unlimited storage for: $EMAIL" EOF chmod +x /usr/local/bin/ente-upgrade-subscription +>>>>>>> bb7e2e03 (fix(postiz,ente,lobehub): address testing feedback) msg_ok "Created helper scripts" diff --git a/install/netboot.xyz-install.sh b/install/netboot-xyz-install.sh similarity index 100% rename from install/netboot.xyz-install.sh rename to install/netboot-xyz-install.sh diff --git a/json/ente.json b/json/ente.json index 8a7a9eaf..620d694f 100644 --- a/json/ente.json +++ b/json/ente.json @@ -33,19 +33,27 @@ }, "notes": [ { +<<<<<<< HEAD "text": "First-Start: Run `ente-setup` — it guides you through account creation, verification, and admin configuration", "type": "warning" }, - { - "text": "To upgrade subscription later: `ente-upgrade-subscription user@example.com`", - "type": "info" - }, { "text": "For CLI admin docs see https://ente.io/help/self-hosting/administration/cli", "type": "info" }, { "text": "Museum config: `cat /opt/ente/server/museum.yaml`", +======= + "text": "First-Start: Run `ente-setup` — it guides you through account creation, verification, and admin configuration.", + "type": "info" + }, + { + "text": "To upgrade subscription later: `ente-upgrade-subscription user@example.com`", + "type": "info" + }, + { + "text": "To see Museum config: `cat /opt/ente/server/museum.yaml`", +>>>>>>> bb7e2e03 (fix(postiz,ente,lobehub): address testing feedback) "type": "info" } ]