Skip to content

Commit 5cb5ed4

Browse files
committed
Added server updates scripts to update the server without destroying the container
1 parent 34179e4 commit 5cb5ed4

File tree

6 files changed

+358
-83
lines changed

6 files changed

+358
-83
lines changed

WebInterface/generate-ssl.sh

Lines changed: 0 additions & 63 deletions
This file was deleted.

WebInterface/test-db.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

WebInterface/update-webserver.bat

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
echo AI MultiBarcode Capture - Web Server Update
5+
echo =============================================
6+
echo This script updates the website files in the Docker container
7+
8+
REM Check if Docker container exists
9+
docker ps -a -q -f name=multibarcode-webinterface >nul 2>&1
10+
if errorlevel 1 (
11+
echo [ERROR] Docker container 'multibarcode-webinterface' does not exist
12+
echo Please run start-services.bat first to create the container
13+
pause
14+
exit /b 1
15+
)
16+
17+
REM Check if container is running
18+
docker ps -q -f name=multibarcode-webinterface >nul 2>&1
19+
if errorlevel 1 (
20+
echo [INFO] Container exists but is not running, starting it...
21+
docker start multibarcode-webinterface
22+
if errorlevel 1 (
23+
echo [ERROR] Failed to start container
24+
pause
25+
exit /b 1
26+
)
27+
echo [OK] Container started successfully
28+
echo Waiting for services to initialize...
29+
timeout /t 10 /nobreak >nul
30+
) else (
31+
echo [OK] Container is running
32+
)
33+
34+
echo.
35+
echo [STEP 1] Copying website files to container...
36+
37+
REM Copy main website files
38+
docker cp src\index.html multibarcode-webinterface:/var/www/html/
39+
docker cp src\css multibarcode-webinterface:/var/www/html/
40+
docker cp src\js multibarcode-webinterface:/var/www/html/
41+
docker cp src\lang multibarcode-webinterface:/var/www/html/
42+
docker cp src\lib multibarcode-webinterface:/var/www/html/
43+
44+
echo [STEP 2] Copying API files...
45+
docker cp src\api multibarcode-webinterface:/var/www/html/
46+
47+
echo [STEP 3] Copying configuration files...
48+
docker cp src\config multibarcode-webinterface:/var/www/html/
49+
50+
echo [STEP 4] Setting proper permissions...
51+
docker exec multibarcode-webinterface bash -c "chown -R www-data:www-data /var/www/html"
52+
docker exec multibarcode-webinterface bash -c "chmod -R 755 /var/www/html"
53+
54+
echo [STEP 5] Reloading Apache configuration...
55+
docker exec multibarcode-webinterface bash -c "service apache2 reload"
56+
57+
if %errorlevel% equ 0 (
58+
echo.
59+
echo =============================================
60+
echo [SUCCESS] Web server updated successfully!
61+
echo =============================================
62+
echo.
63+
echo The website has been updated with the latest files.
64+
echo You can access it at: http://localhost:3500
65+
echo.
66+
) else (
67+
echo [ERROR] Failed to reload Apache configuration
68+
pause
69+
exit /b 1
70+
)
71+
72+
echo Update completed successfully!
73+
pause

WebInterface/update-webserver.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
echo "🔄 AI MultiBarcode Capture - Web Server Update"
4+
echo "==============================================="
5+
echo "This script updates the website files in the Docker container"
6+
7+
# Check if Docker container exists
8+
if ! docker ps -a -q -f name=multibarcode-webinterface > /dev/null 2>&1; then
9+
echo "❌ Error: Docker container 'multibarcode-webinterface' does not exist"
10+
echo " Please run start-services.sh first to create the container"
11+
exit 1
12+
fi
13+
14+
# Check if container is running
15+
if ! docker ps -q -f name=multibarcode-webinterface > /dev/null 2>&1; then
16+
echo "ℹ️ Container exists but is not running, starting it..."
17+
if docker start multibarcode-webinterface; then
18+
echo "✅ Container started successfully"
19+
echo "⏳ Waiting for services to initialize..."
20+
sleep 10
21+
else
22+
echo "❌ Error: Failed to start container"
23+
exit 1
24+
fi
25+
else
26+
echo "✅ Container is running"
27+
fi
28+
29+
echo ""
30+
echo "📁 [STEP 1] Copying website files to container..."
31+
32+
# Copy main website files
33+
docker cp src/index.html multibarcode-webinterface:/var/www/html/
34+
docker cp src/css multibarcode-webinterface:/var/www/html/
35+
docker cp src/js multibarcode-webinterface:/var/www/html/
36+
docker cp src/lang multibarcode-webinterface:/var/www/html/
37+
docker cp src/lib multibarcode-webinterface:/var/www/html/
38+
39+
echo "🔌 [STEP 2] Copying API files..."
40+
docker cp src/api multibarcode-webinterface:/var/www/html/
41+
42+
echo "⚙️ [STEP 3] Copying configuration files..."
43+
docker cp src/config multibarcode-webinterface:/var/www/html/
44+
45+
echo "🔒 [STEP 4] Setting proper permissions..."
46+
docker exec multibarcode-webinterface bash -c "chown -R www-data:www-data /var/www/html"
47+
docker exec multibarcode-webinterface bash -c "chmod -R 755 /var/www/html"
48+
49+
echo "🔄 [STEP 5] Reloading Apache configuration..."
50+
if docker exec multibarcode-webinterface bash -c "service apache2 reload"; then
51+
echo ""
52+
echo "🎉 ==============================================="
53+
echo "✅ [SUCCESS] Web server updated successfully!"
54+
echo "🎉 ==============================================="
55+
echo ""
56+
echo "📝 The website has been updated with the latest files."
57+
echo "🌐 You can access it at: http://localhost:3500"
58+
echo ""
59+
else
60+
echo "❌ Error: Failed to reload Apache configuration"
61+
exit 1
62+
fi
63+
64+
echo "✅ Update completed successfully!"

0 commit comments

Comments
 (0)