Files
client/upload_bundle.sh
2026-04-17 16:52:51 -04:00

58 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Upload NDK bundle files to server
# Usage: ./upload_bundle.sh
SERVER="ubuntu@laantungir.net"
FINAL_PATH="/var/www/html/ndk"
FILES=("build/ndk-core.bundle.js" "build/ndk-core.bundle.js.map")
echo "📦 Uploading NDK bundle to server..."
echo ""
# Check if files exist
for file in "${FILES[@]}"; do
if [ ! -f "$file" ]; then
echo "❌ Error: $file not found. Run 'node build-ndk-bundle.js' first."
exit 1
fi
done
# Upload files to ubuntu home directory
for file in "${FILES[@]}"; do
filename=$(basename "$file")
size=$(du -h "$file" | cut -f1)
echo ""
echo "📤 Uploading $filename ($size)..."
scp "$file" "$SERVER:~/$filename"
if [ $? -eq 0 ]; then
echo "$filename uploaded to home directory"
else
echo "❌ Failed to upload $filename"
exit 1
fi
done
# Move files to final location with sudo and set www-data ownership
echo ""
echo "📁 Moving files to $FINAL_PATH and setting permissions..."
ssh $SERVER "sudo mkdir -p $FINAL_PATH && sudo mv ~/*.js ~/*.map $FINAL_PATH/ 2>/dev/null; sudo chown www-data:www-data $FINAL_PATH/*.js $FINAL_PATH/*.map && sudo chmod 644 $FINAL_PATH/*.js $FINAL_PATH/*.map"
if [ $? -eq 0 ]; then
echo "✅ Files moved to final location with www-data ownership"
else
echo "❌ Failed to move files to final location"
exit 1
fi
echo ""
echo "✅ All files uploaded successfully!"
echo ""
echo "🌐 Bundle available at:"
echo " https://laantungir.net/ndk/ndk-core.bundle.js"
echo " https://laantungir.net/ndk/ndk-core.bundle.js.map"
echo ""
echo "📋 Test with: test-ndk.html"