|
|
@@ -94,21 +94,26 @@ DEFAULT_S3_BUCKET="ente-due-ren"
|
|
|
|
S3_CONFIG_DIR="/app/data/config"
|
|
|
|
S3_CONFIG_DIR="/app/data/config"
|
|
|
|
S3_CONFIG_FILE="$S3_CONFIG_DIR/s3.env"
|
|
|
|
S3_CONFIG_FILE="$S3_CONFIG_DIR/s3.env"
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$S3_CONFIG_DIR"
|
|
|
|
write_default_s3_template() {
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f "$S3_CONFIG_FILE" ]; then
|
|
|
|
|
|
|
|
log "INFO" "Loading S3 configuration overrides from $S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
|
|
|
set -a
|
|
|
|
|
|
|
|
. "$S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
set +a
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log "INFO" "S3 configuration file not found, writing template to $S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
cat > "$S3_CONFIG_FILE" << 'EOF'
|
|
|
|
cat > "$S3_CONFIG_FILE" << 'EOF'
|
|
|
|
# S3 configuration overrides for Ente on Cloudron.
|
|
|
|
# S3 configuration overrides for Ente on Cloudron.
|
|
|
|
# Uncomment and set any of the variables below to override the packaged defaults.
|
|
|
|
# Uncomment and set any of the variables below to override the packaged defaults.
|
|
|
|
# After editing this file, restart the Ente app from the Cloudron dashboard.
|
|
|
|
# After editing this file, restart the Ente app from the Cloudron dashboard.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
# Example (previous Wasabi defaults bundled with this package):
|
|
|
|
|
|
|
|
#S3_ACCESS_KEY=QZ5M3VMBUHDTIFDFCD8E
|
|
|
|
|
|
|
|
#S3_SECRET_KEY=pz1eHYjU1NwAbbruedc7swzCuszd57p1rGSFVzjv
|
|
|
|
|
|
|
|
#S3_ENDPOINT=https://s3.eu-central-2.wasabisys.com
|
|
|
|
|
|
|
|
#S3_REGION=eu-central-2
|
|
|
|
|
|
|
|
#S3_BUCKET=ente-due-ren
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Example (Cloudflare R2 — replace placeholders):
|
|
|
|
|
|
|
|
#S3_ACCESS_KEY=R2_ACCESS_KEY
|
|
|
|
|
|
|
|
#S3_SECRET_KEY=R2_SECRET_KEY
|
|
|
|
|
|
|
|
#S3_ENDPOINT=https://<ACCOUNT_ID>.r2.cloudflarestorage.com
|
|
|
|
|
|
|
|
#S3_REGION=auto
|
|
|
|
|
|
|
|
#S3_BUCKET=<bucket-name>
|
|
|
|
|
|
|
|
#
|
|
|
|
#S3_ACCESS_KEY=
|
|
|
|
#S3_ACCESS_KEY=
|
|
|
|
#S3_SECRET_KEY=
|
|
|
|
#S3_SECRET_KEY=
|
|
|
|
#S3_ENDPOINT=
|
|
|
|
#S3_ENDPOINT=
|
|
|
@@ -116,6 +121,23 @@ else
|
|
|
|
#S3_BUCKET=
|
|
|
|
#S3_BUCKET=
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
chown cloudron:cloudron "$S3_CONFIG_FILE" || true
|
|
|
|
chown cloudron:cloudron "$S3_CONFIG_FILE" || true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$S3_CONFIG_DIR"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f "$S3_CONFIG_FILE" ]; then
|
|
|
|
|
|
|
|
if ! grep -q "previous Wasabi defaults" "$S3_CONFIG_FILE" && ! grep -Eq '^[[:space:]]*[^#[:space:]]' "$S3_CONFIG_FILE"; then
|
|
|
|
|
|
|
|
log "INFO" "Refreshing S3 configuration template with example values"
|
|
|
|
|
|
|
|
write_default_s3_template
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
log "INFO" "Loading S3 configuration overrides from $S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
|
|
|
set -a
|
|
|
|
|
|
|
|
. "$S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
set +a
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log "INFO" "S3 configuration file not found, writing template to $S3_CONFIG_FILE"
|
|
|
|
|
|
|
|
write_default_s3_template
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
S3_ACCESS_KEY="${S3_ACCESS_KEY:-$DEFAULT_S3_ACCESS_KEY}"
|
|
|
|
S3_ACCESS_KEY="${S3_ACCESS_KEY:-$DEFAULT_S3_ACCESS_KEY}"
|
|
|
@@ -441,34 +463,6 @@ for webapp in photos accounts auth cast; do
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# ===============================================
|
|
|
|
|
|
|
|
# Museum log highlighter (extract OTTs from logs)
|
|
|
|
|
|
|
|
# ===============================================
|
|
|
|
|
|
|
|
prepare_ott_highlighter() {
|
|
|
|
|
|
|
|
cat > "/app/data/ente/server/ott-log-highlight.js" << 'EOF'
|
|
|
|
|
|
|
|
const readline = require('readline');
|
|
|
|
|
|
|
|
const rl = readline.createInterface({ input: process.stdin });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const shouldHighlight = (line) => {
|
|
|
|
|
|
|
|
if (!line) return false;
|
|
|
|
|
|
|
|
const lower = line.toLowerCase();
|
|
|
|
|
|
|
|
if (lower.includes('added ott')) return true;
|
|
|
|
|
|
|
|
if (lower.includes('ott"') || lower.includes(' ott ')) return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
|
|
|
|
process.stdout.write(line + '\n');
|
|
|
|
|
|
|
|
if (shouldHighlight(line)) {
|
|
|
|
|
|
|
|
const trimmed = line.trim();
|
|
|
|
|
|
|
|
process.stdout.write('============================================================\n');
|
|
|
|
|
|
|
|
process.stdout.write(`HIGHLIGHT: ${trimmed}\n`);
|
|
|
|
|
|
|
|
process.stdout.write('============================================================\n');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===============================================
|
|
|
|
# ===============================================
|
|
|
|
# Node.js Placeholder Server
|
|
|
|
# Node.js Placeholder Server
|
|
|
|
# ===============================================
|
|
|
|
# ===============================================
|
|
|
@@ -610,9 +604,7 @@ const apiHandlers = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const responsePayload = buildResponse(email);
|
|
|
|
const responsePayload = buildResponse(email);
|
|
|
|
log('============================================================');
|
|
|
|
log(`Verifying OTT ${ott} for ${email}`);
|
|
|
|
log(`HIGHLIGHT: Verifying OTT ${ott} for ${email}`);
|
|
|
|
|
|
|
|
log('============================================================');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
|
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
|
|
res.end(JSON.stringify(responsePayload));
|
|
|
|
res.end(JSON.stringify(responsePayload));
|
|
|
@@ -699,9 +691,7 @@ const apiHandlers = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ott = ('' + Math.floor(100000 + Math.random() * 900000)).slice(-6);
|
|
|
|
const ott = ('' + Math.floor(100000 + Math.random() * 900000)).slice(-6);
|
|
|
|
log('============================================================');
|
|
|
|
log(`Generated OTT ${ott} for ${email}`);
|
|
|
|
log(`HIGHLIGHT: Generated OTT ${ott} for ${email}`);
|
|
|
|
|
|
|
|
log('============================================================');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
|
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
|
|
res.end(JSON.stringify({ success: true, ott, email }));
|
|
|
|
res.end(JSON.stringify({ success: true, ott, email }));
|
|
|
@@ -873,10 +863,9 @@ if [ "$USE_PLACEHOLDER" = true ]; then
|
|
|
|
create_nodejs_placeholder
|
|
|
|
create_nodejs_placeholder
|
|
|
|
else
|
|
|
|
else
|
|
|
|
log "INFO" "Starting actual Museum server"
|
|
|
|
log "INFO" "Starting actual Museum server"
|
|
|
|
prepare_ott_highlighter
|
|
|
|
|
|
|
|
cd /app/data/ente/server
|
|
|
|
cd /app/data/ente/server
|
|
|
|
export ENVIRONMENT="${MUSEUM_ENVIRONMENT:-local}"
|
|
|
|
export ENVIRONMENT="${MUSEUM_ENVIRONMENT:-local}"
|
|
|
|
stdbuf -oL "$MUSEUM_BIN" 2>&1 | node ott-log-highlight.js | tee -a "$MUSEUM_LOG" &
|
|
|
|
stdbuf -oL "$MUSEUM_BIN" 2>&1 | tee -a "$MUSEUM_LOG" &
|
|
|
|
MUSEUM_PID=$!
|
|
|
|
MUSEUM_PID=$!
|
|
|
|
log "INFO" "Started Museum server (pipeline PID: $MUSEUM_PID)"
|
|
|
|
log "INFO" "Started Museum server (pipeline PID: $MUSEUM_PID)"
|
|
|
|
|
|
|
|
|
|
|
|