Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aa9b3a0227 | |||
| 410a33fecf | |||
| 05ebaaeedb | |||
| 84d0f63d36 | |||
| 6a4b549d9f | |||
| f3604b438b | |||
| 531831e84b | |||
| 90bb21e38b | |||
| 2f1a137342 | |||
| adf576fbe1 |
@@ -53,6 +53,12 @@ VITE_API_URL=/api
|
|||||||
# Timezone
|
# Timezone
|
||||||
TZ=UTC
|
TZ=UTC
|
||||||
|
|
||||||
|
# Runtime user mapping for Docker (optional)
|
||||||
|
# Set these to your host user's UID/GID to avoid permission issues on bind mounts.
|
||||||
|
# Run `id -u` and `id -g` on host to get values. Defaults to 1001.
|
||||||
|
PUID=1001
|
||||||
|
PGID=1001
|
||||||
|
|
||||||
# Analytics (Optional - Umami)
|
# Analytics (Optional - Umami)
|
||||||
VITE_UMAMI_URL=
|
VITE_UMAMI_URL=
|
||||||
VITE_UMAMI_WEBSITE_ID=
|
VITE_UMAMI_WEBSITE_ID=
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Log in to Container Registry
|
- name: Log in to Container Registry
|
||||||
if: github.event_name != 'pull_request' || github.event.inputs.push == 'true'
|
if: github.event_name != 'pull_request' || github.event.inputs.push == 'true'
|
||||||
|
id: login-ghcr
|
||||||
|
continue-on-error: true
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
@@ -73,7 +75,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
file: ./backend/Dockerfile
|
file: ./backend/Dockerfile
|
||||||
push: ${{ github.event_name != 'pull_request' || github.event.inputs.push == 'true' }}
|
# Always build; only push when registry login succeeded
|
||||||
|
push: ${{ (github.event_name != 'pull_request' || github.event.inputs.push == 'true') && steps.login-ghcr.outcome == 'success' }}
|
||||||
tags: ${{ steps.meta-backend.outputs.tags }}
|
tags: ${{ steps.meta-backend.outputs.tags }}
|
||||||
labels: ${{ steps.meta-backend.outputs.labels }}
|
labels: ${{ steps.meta-backend.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
@@ -86,7 +89,7 @@ jobs:
|
|||||||
VERSION=${{ steps.meta-backend.outputs.version }}
|
VERSION=${{ steps.meta-backend.outputs.version }}
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && steps.login-ghcr.outcome == 'success'
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
image-ref: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ steps.meta-backend.outputs.version }}
|
image-ref: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ steps.meta-backend.outputs.version }}
|
||||||
@@ -96,7 +99,7 @@ jobs:
|
|||||||
timeout: '10m'
|
timeout: '10m'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && steps.login-ghcr.outcome == 'success'
|
||||||
uses: github/codeql-action/upload-sarif@v3
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-backend.sarif'
|
sarif_file: 'trivy-backend.sarif'
|
||||||
@@ -120,6 +123,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Log in to Container Registry
|
- name: Log in to Container Registry
|
||||||
if: github.event_name != 'pull_request' || github.event.inputs.push == 'true'
|
if: github.event_name != 'pull_request' || github.event.inputs.push == 'true'
|
||||||
|
id: login-ghcr
|
||||||
|
continue-on-error: true
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
@@ -150,7 +155,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
file: ./frontend/Dockerfile
|
file: ./frontend/Dockerfile
|
||||||
push: ${{ github.event_name != 'pull_request' || github.event.inputs.push == 'true' }}
|
# Always build; only push when registry login succeeded
|
||||||
|
push: ${{ (github.event_name != 'pull_request' || github.event.inputs.push == 'true') && steps.login-ghcr.outcome == 'success' }}
|
||||||
tags: ${{ steps.meta-frontend.outputs.tags }}
|
tags: ${{ steps.meta-frontend.outputs.tags }}
|
||||||
labels: ${{ steps.meta-frontend.outputs.labels }}
|
labels: ${{ steps.meta-frontend.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
@@ -163,7 +169,7 @@ jobs:
|
|||||||
VERSION=${{ steps.meta-frontend.outputs.version }}
|
VERSION=${{ steps.meta-frontend.outputs.version }}
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && steps.login-ghcr.outcome == 'success'
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
image-ref: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:${{ steps.meta-frontend.outputs.version }}
|
image-ref: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:${{ steps.meta-frontend.outputs.version }}
|
||||||
@@ -173,7 +179,7 @@ jobs:
|
|||||||
timeout: '10m'
|
timeout: '10m'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && steps.login-ghcr.outcome == 'success'
|
||||||
uses: github/codeql-action/upload-sarif@v3
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-frontend.sarif'
|
sarif_file: 'trivy-frontend.sarif'
|
||||||
@@ -220,4 +226,4 @@ jobs:
|
|||||||
echo "- PR number (for pull requests)" >> $GITHUB_STEP_SUMMARY
|
echo "- PR number (for pull requests)" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Version tags (for releases)" >> $GITHUB_STEP_SUMMARY
|
echo "- Version tags (for releases)" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Short SHA with branch prefix" >> $GITHUB_STEP_SUMMARY
|
echo "- Short SHA with branch prefix" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`latest\` (for main branch)" >> $GITHUB_STEP_SUMMARY
|
echo "- \`latest\` (for main branch)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.119",
|
"version": "1.0.123",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.119",
|
"version": "1.0.123",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.850.0",
|
"@aws-sdk/client-s3": "^3.850.0",
|
||||||
"@aws-sdk/lib-storage": "^3.850.0",
|
"@aws-sdk/lib-storage": "^3.850.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.119",
|
"version": "1.0.123",
|
||||||
"description": "Backend for PicPeak event photo sharing platform",
|
"description": "Backend for PicPeak event photo sharing platform",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+26
-6
@@ -84,14 +84,14 @@ app.use((req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
// CORS configuration
|
// CORS configuration (apply only to API routes)
|
||||||
const corsOptions = {
|
const corsOptions = {
|
||||||
origin: function (origin, callback) {
|
origin: function (origin, callback) {
|
||||||
const allowedOrigins = [
|
const allowedOrigins = [
|
||||||
process.env.FRONTEND_URL || 'http://localhost:3005',
|
process.env.FRONTEND_URL || 'http://localhost:3005',
|
||||||
process.env.ADMIN_URL || 'http://localhost:3005'
|
process.env.ADMIN_URL || 'http://localhost:3005'
|
||||||
];
|
];
|
||||||
|
|
||||||
// In development, also allow localhost origins
|
// In development, also allow localhost origins
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
allowedOrigins.push(
|
allowedOrigins.push(
|
||||||
@@ -101,18 +101,22 @@ const corsOptions = {
|
|||||||
'http://localhost:3000' // Direct backend access
|
'http://localhost:3000' // Direct backend access
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow requests with no origin (like mobile apps or curl)
|
// Allow requests with no origin (like curl) and allow-listed origins
|
||||||
if (!origin || allowedOrigins.indexOf(origin) !== -1) {
|
if (!origin || allowedOrigins.indexOf(origin) !== -1) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
callback(new Error('Not allowed by CORS'));
|
// Do not error globally; just omit CORS headers on disallowed origins
|
||||||
|
callback(null, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
credentials: true
|
credentials: true
|
||||||
};
|
};
|
||||||
|
|
||||||
app.use(cors(corsOptions));
|
// Only attach CORS to API endpoints, not static assets
|
||||||
|
app.use('/api', cors(corsOptions));
|
||||||
|
// Handle preflight explicitly for API paths
|
||||||
|
app.options('/api/*', cors(corsOptions));
|
||||||
|
|
||||||
// Initialize rate limiters (they will be created dynamically)
|
// Initialize rate limiters (they will be created dynamically)
|
||||||
let generalRateLimiter;
|
let generalRateLimiter;
|
||||||
@@ -136,6 +140,22 @@ async function initializeRateLimiters() {
|
|||||||
app.use(express.json({ limit: '100mb' }));
|
app.use(express.json({ limit: '100mb' }));
|
||||||
app.use(express.urlencoded({ extended: true, limit: '100mb' }));
|
app.use(express.urlencoded({ extended: true, limit: '100mb' }));
|
||||||
|
|
||||||
|
// Request logging for API routes (with timestamps)
|
||||||
|
const apiRequestLogger = (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const started = Date.now();
|
||||||
|
const ts = new Date().toISOString();
|
||||||
|
logger.info(`[${ts}] ${req.method} ${req.originalUrl}`);
|
||||||
|
res.on('finish', () => {
|
||||||
|
const ms = Date.now() - started;
|
||||||
|
const tsDone = new Date().toISOString();
|
||||||
|
logger.info(`[${tsDone}] ${req.method} ${req.originalUrl} -> ${res.statusCode} (${ms}ms)`);
|
||||||
|
});
|
||||||
|
} catch (_) {}
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
app.use('/api', apiRequestLogger);
|
||||||
|
|
||||||
// Maintenance mode middleware - add after body parsing but before routes
|
// Maintenance mode middleware - add after body parsing but before routes
|
||||||
app.use(maintenanceMiddleware);
|
app.use(maintenanceMiddleware);
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -29,6 +29,11 @@ services:
|
|||||||
- ADMIN_URL=${ADMIN_URL:-http://localhost:3001}
|
- ADMIN_URL=${ADMIN_URL:-http://localhost:3001}
|
||||||
- TZ=${TZ:-UTC}
|
- TZ=${TZ:-UTC}
|
||||||
- STORAGE_PATH=/app/storage
|
- STORAGE_PATH=/app/storage
|
||||||
|
# Optional: run container as matching host user to avoid bind mount permission issues
|
||||||
|
- PUID=${PUID:-1001}
|
||||||
|
- PGID=${PGID:-1001}
|
||||||
|
# Use host-matching user ID/GID so bind-mounted folders are writable
|
||||||
|
user: "${PUID:-1001}:${PGID:-1001}"
|
||||||
volumes:
|
volumes:
|
||||||
- ./events:/app/events
|
- ./events:/app/events
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
@@ -122,4 +127,4 @@ volumes:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
picpeak-network:
|
picpeak-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.117",
|
"version": "1.0.123",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.117",
|
"version": "1.0.123",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.0.0",
|
"@tanstack/react-query": "^5.0.0",
|
||||||
"@tiptap/extension-character-count": "^2.26.1",
|
"@tiptap/extension-character-count": "^2.26.1",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.117",
|
"version": "1.0.123",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
+85
-28
@@ -44,7 +44,6 @@ INSTALL_METHOD="" # docker or native
|
|||||||
OS_TYPE=""
|
OS_TYPE=""
|
||||||
OS_VERSION=""
|
OS_VERSION=""
|
||||||
PACKAGE_MANAGER=""
|
PACKAGE_MANAGER=""
|
||||||
ADMIN_PASSWORD=""
|
|
||||||
ADMIN_EMAIL="admin@example.com"
|
ADMIN_EMAIL="admin@example.com"
|
||||||
DOMAIN_NAME=""
|
DOMAIN_NAME=""
|
||||||
SMTP_HOST=""
|
SMTP_HOST=""
|
||||||
@@ -78,6 +77,21 @@ run_as_user() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Prompt for admin email interactively (unless provided or unattended)
|
||||||
|
prompt_admin_email() {
|
||||||
|
if [[ -n "$ADMIN_EMAIL" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$UNATTENDED" == "true" ]]; then
|
||||||
|
ADMIN_EMAIL="admin@example.com"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
echo "Please enter the admin email address (used for the initial admin account):"
|
||||||
|
read -p "Admin email [admin@example.com]: " ADMIN_EMAIL
|
||||||
|
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}
|
||||||
|
}
|
||||||
|
|
||||||
print_banner() {
|
print_banner() {
|
||||||
echo -e "${PURPLE}"
|
echo -e "${PURPLE}"
|
||||||
echo "╔════════════════════════════════════════════════════════════════════════╗"
|
echo "╔════════════════════════════════════════════════════════════════════════╗"
|
||||||
@@ -353,7 +367,6 @@ setup_docker_installation() {
|
|||||||
local jwt_secret=$(generate_jwt_secret)
|
local jwt_secret=$(generate_jwt_secret)
|
||||||
local db_password=$(generate_password)
|
local db_password=$(generate_password)
|
||||||
local redis_password=$(generate_password)
|
local redis_password=$(generate_password)
|
||||||
[[ -z "$ADMIN_PASSWORD" ]] && ADMIN_PASSWORD=$(generate_password)
|
|
||||||
|
|
||||||
# Create .env file
|
# Create .env file
|
||||||
log_step "Creating configuration..."
|
log_step "Creating configuration..."
|
||||||
@@ -368,7 +381,6 @@ JWT_SECRET=$jwt_secret
|
|||||||
|
|
||||||
# Admin
|
# Admin
|
||||||
ADMIN_EMAIL=$ADMIN_EMAIL
|
ADMIN_EMAIL=$ADMIN_EMAIL
|
||||||
ADMIN_PASSWORD=$ADMIN_PASSWORD
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_HOST=postgres
|
DB_HOST=postgres
|
||||||
@@ -395,7 +407,7 @@ SMTP_FROM=${SMTP_USER:-noreply@localhost}
|
|||||||
|
|
||||||
# URLs
|
# URLs
|
||||||
FRONTEND_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
FRONTEND_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
||||||
ADMIN_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME/admin}
|
ADMIN_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
ENABLE_FILE_WATCHER=true
|
ENABLE_FILE_WATCHER=true
|
||||||
@@ -618,7 +630,6 @@ setup_native_installation() {
|
|||||||
|
|
||||||
# Generate secrets
|
# Generate secrets
|
||||||
local jwt_secret=$(generate_jwt_secret)
|
local jwt_secret=$(generate_jwt_secret)
|
||||||
[[ -z "$ADMIN_PASSWORD" ]] && ADMIN_PASSWORD=$(generate_password)
|
|
||||||
|
|
||||||
# Create .env file
|
# Create .env file
|
||||||
log_step "Creating configuration..."
|
log_step "Creating configuration..."
|
||||||
@@ -633,7 +644,6 @@ JWT_SECRET=$jwt_secret
|
|||||||
|
|
||||||
# Admin
|
# Admin
|
||||||
ADMIN_USERNAME=admin
|
ADMIN_USERNAME=admin
|
||||||
ADMIN_PASSWORD=$ADMIN_PASSWORD
|
|
||||||
ADMIN_EMAIL=$ADMIN_EMAIL
|
ADMIN_EMAIL=$ADMIN_EMAIL
|
||||||
|
|
||||||
# Database (native uses SQLite by default)
|
# Database (native uses SQLite by default)
|
||||||
@@ -653,7 +663,7 @@ SMTP_FROM=${SMTP_USER:-noreply@localhost}
|
|||||||
|
|
||||||
# URLs
|
# URLs
|
||||||
FRONTEND_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
FRONTEND_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
||||||
ADMIN_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME/admin}
|
ADMIN_URL=${DOMAIN_NAME:+https://$DOMAIN_NAME}
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
ENABLE_FILE_WATCHER=true
|
ENABLE_FILE_WATCHER=true
|
||||||
@@ -690,8 +700,15 @@ EOF
|
|||||||
# Start services
|
# Start services
|
||||||
log_step "Starting services..."
|
log_step "Starting services..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable picpeak-backend picpeak-workers
|
systemctl enable picpeak-backend
|
||||||
systemctl start picpeak-backend picpeak-workers
|
# Stop/remove legacy workers service if present
|
||||||
|
if systemctl list-unit-files | grep -q '^picpeak-workers.service'; then
|
||||||
|
systemctl disable picpeak-workers || true
|
||||||
|
systemctl stop picpeak-workers || true
|
||||||
|
rm -f /etc/systemd/system/picpeak-workers.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
systemctl start picpeak-backend
|
||||||
|
|
||||||
log_success "Native installation completed!"
|
log_success "Native installation completed!"
|
||||||
}
|
}
|
||||||
@@ -899,8 +916,32 @@ print_success_message() {
|
|||||||
echo
|
echo
|
||||||
echo "🔐 Admin Credentials:"
|
echo "🔐 Admin Credentials:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}"
|
# Read from ADMIN_CREDENTIALS.txt when available
|
||||||
echo -e "Password: ${CYAN}$ADMIN_PASSWORD${NC}"
|
local cred_file email_line pass_line admin_email_val admin_pass_val
|
||||||
|
if [[ "$INSTALL_METHOD" == "docker" ]]; then
|
||||||
|
cred_file="$app_dir/data/ADMIN_CREDENTIALS.txt"
|
||||||
|
else
|
||||||
|
cred_file="$NATIVE_APP_DIR/app/backend/data/ADMIN_CREDENTIALS.txt"
|
||||||
|
fi
|
||||||
|
if [[ -f "$cred_file" ]]; then
|
||||||
|
email_line=$(grep -m1 '^Email:' "$cred_file" || true)
|
||||||
|
pass_line=$(grep -m1 '^Password:' "$cred_file" || true)
|
||||||
|
admin_email_val=${email_line#Email: }
|
||||||
|
admin_pass_val=${pass_line#Password: }
|
||||||
|
if [[ -n "$admin_email_val" ]]; then
|
||||||
|
echo -e "Email: ${CYAN}$admin_email_val${NC}"
|
||||||
|
else
|
||||||
|
echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}"
|
||||||
|
fi
|
||||||
|
if [[ -n "$admin_pass_val" ]]; then
|
||||||
|
echo -e "Password: ${CYAN}$admin_pass_val${NC}"
|
||||||
|
else
|
||||||
|
echo -e "Password: ${YELLOW}(see $cred_file)${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}"
|
||||||
|
echo -e "Password: ${YELLOW}(credentials file not found)${NC}"
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
echo -e "${YELLOW}⚠️ IMPORTANT: Change the admin password on first login!${NC}"
|
echo -e "${YELLOW}⚠️ IMPORTANT: Change the admin password on first login!${NC}"
|
||||||
|
|
||||||
@@ -924,8 +965,8 @@ print_success_message() {
|
|||||||
echo "🔧 Service Commands:"
|
echo "🔧 Service Commands:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo "View logs: sudo journalctl -u picpeak-backend -f"
|
echo "View logs: sudo journalctl -u picpeak-backend -f"
|
||||||
echo "Stop: sudo systemctl stop picpeak-backend picpeak-workers"
|
echo "Stop: sudo systemctl stop picpeak-backend"
|
||||||
echo "Start: sudo systemctl start picpeak-backend picpeak-workers"
|
echo "Start: sudo systemctl start picpeak-backend"
|
||||||
echo "Status: sudo systemctl status picpeak-backend"
|
echo "Status: sudo systemctl status picpeak-backend"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -944,16 +985,31 @@ print_success_message() {
|
|||||||
|
|
||||||
update_installation() {
|
update_installation() {
|
||||||
print_header "Updating PicPeak"
|
print_header "Updating PicPeak"
|
||||||
|
|
||||||
# Detect existing installation
|
# Prefer explicit native install detection first
|
||||||
if [[ -d "$DOCKER_APP_DIR" ]] || [[ -d "/home/${SUDO_USER:-}/picpeak" ]]; then
|
native_detected=false
|
||||||
INSTALL_METHOD="docker"
|
docker_detected=false
|
||||||
update_docker_installation
|
|
||||||
elif [[ -d "$NATIVE_APP_DIR" ]]; then
|
# Native detection: app/backend exists OR systemd unit present
|
||||||
|
if [[ -d "$NATIVE_APP_DIR/app/backend" ]]; then
|
||||||
|
native_detected=true
|
||||||
|
elif command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q '^picpeak-backend.service'; then
|
||||||
|
native_detected=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Docker detection: docker app dir or user home picpeak dir exists
|
||||||
|
if [[ -d "$DOCKER_APP_DIR" ]] || [[ -n "${SUDO_USER:-}" && -d "/home/${SUDO_USER}/picpeak" ]]; then
|
||||||
|
docker_detected=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$native_detected" == true ]]; then
|
||||||
INSTALL_METHOD="native"
|
INSTALL_METHOD="native"
|
||||||
update_native_installation
|
update_native_installation
|
||||||
|
elif [[ "$docker_detected" == true ]]; then
|
||||||
|
INSTALL_METHOD="docker"
|
||||||
|
update_docker_installation
|
||||||
else
|
else
|
||||||
die "No existing PicPeak installation found"
|
die "No existing PicPeak installation found (native dir $NATIVE_APP_DIR/app/backend or docker dir $DOCKER_APP_DIR not present)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -986,7 +1042,10 @@ update_native_installation() {
|
|||||||
log_step "Updating native installation..."
|
log_step "Updating native installation..."
|
||||||
|
|
||||||
# Stop services
|
# Stop services
|
||||||
systemctl stop picpeak-backend picpeak-workers
|
systemctl stop picpeak-backend || true
|
||||||
|
if systemctl list-unit-files | grep -q '^picpeak-workers.service'; then
|
||||||
|
systemctl stop picpeak-workers || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Backup current configuration
|
# Backup current configuration
|
||||||
if [[ -f "$NATIVE_APP_DIR/app/backend/.env" ]]; then
|
if [[ -f "$NATIVE_APP_DIR/app/backend/.env" ]]; then
|
||||||
@@ -1027,7 +1086,7 @@ update_native_installation() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
systemctl restart picpeak-backend picpeak-workers
|
systemctl restart picpeak-backend
|
||||||
|
|
||||||
log_success "Native installation updated successfully!"
|
log_success "Native installation updated successfully!"
|
||||||
}
|
}
|
||||||
@@ -1121,10 +1180,6 @@ parse_arguments() {
|
|||||||
ADMIN_EMAIL="$2"
|
ADMIN_EMAIL="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--admin-password)
|
|
||||||
ADMIN_PASSWORD="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--smtp-host)
|
--smtp-host)
|
||||||
SMTP_HOST="$2"
|
SMTP_HOST="$2"
|
||||||
shift 2
|
shift 2
|
||||||
@@ -1182,7 +1237,6 @@ Options:
|
|||||||
--unattended Run without prompts
|
--unattended Run without prompts
|
||||||
--domain DOMAIN Set domain name for HTTPS
|
--domain DOMAIN Set domain name for HTTPS
|
||||||
--email EMAIL Admin email address
|
--email EMAIL Admin email address
|
||||||
--admin-password Admin password (auto-generated if not set)
|
|
||||||
--smtp-host HOST SMTP server hostname
|
--smtp-host HOST SMTP server hostname
|
||||||
--smtp-port PORT SMTP server port
|
--smtp-port PORT SMTP server port
|
||||||
--smtp-user USER SMTP username
|
--smtp-user USER SMTP username
|
||||||
@@ -1205,7 +1259,7 @@ Examples:
|
|||||||
|
|
||||||
# Fully automated Docker setup
|
# Fully automated Docker setup
|
||||||
sudo $0 --docker --unattended --domain photos.example.com \\
|
sudo $0 --docker --unattended --domain photos.example.com \\
|
||||||
--email admin@example.com --admin-password SecurePass123 \\
|
--email admin@example.com \\
|
||||||
--smtp-host smtp.gmail.com --smtp-port 587 \\
|
--smtp-host smtp.gmail.com --smtp-port 587 \\
|
||||||
--smtp-user user@gmail.com --smtp-pass app-password \\
|
--smtp-user user@gmail.com --smtp-pass app-password \\
|
||||||
--enable-ssl
|
--enable-ssl
|
||||||
@@ -1245,6 +1299,9 @@ main() {
|
|||||||
# Check system requirements
|
# Check system requirements
|
||||||
check_system_requirements
|
check_system_requirements
|
||||||
|
|
||||||
|
# Prompt for admin email (design choice: always ask unless provided)
|
||||||
|
prompt_admin_email
|
||||||
|
|
||||||
# Configure email (optional)
|
# Configure email (optional)
|
||||||
configure_email
|
configure_email
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user