livestream-archiver/package.sh
RTSDA 2c3c86e07d Add LICENSE, improve README, and update project documentation
- Add MIT LICENSE file
- Make README more generic and comprehensive
- Add installation and troubleshooting sections
- Include systemd service integration docs
- Update with build and deployment instructions
2025-08-16 18:57:27 -04:00

94 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
# Package source code for deployment to ARM server
echo "📦 Creating source package for ARM deployment..."
# Create package directory
mkdir -p package
# Copy source files
echo "📋 Copying source files..."
cp -r src/ package/
cp Cargo.toml package/
cp Cargo.lock package/
cp livestream-archiver.service package/
cp README.md package/
cp DEPLOY.md package/
# Create deployment script for the server
cat > package/build-and-deploy.sh << 'EOF'
#!/bin/bash
echo "🔧 Building on ARM server..."
# Install Rust if not present
if ! command -v cargo &> /dev/null; then
echo "📥 Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/env
fi
# Build release
echo "📦 Building release binary..."
cargo build --release
if [ $? -ne 0 ]; then
echo "❌ Build failed!"
exit 1
fi
# Stop existing service if running
echo "🛑 Stopping existing service..."
sudo systemctl stop livestream-archiver 2>/dev/null || true
# Create directories
echo "📁 Creating directories..."
sudo mkdir -p /home/rockvilleav/livestream-archiver
sudo mkdir -p /home/rockvilleav/Sync/Livestreams
sudo mkdir -p /media/archive/jellyfin/livestreams
# Install binary
echo "📦 Installing binary..."
sudo cp target/release/livestream_archiver /home/rockvilleav/livestream-archiver/
sudo chmod +x /home/rockvilleav/livestream-archiver/livestream_archiver
# Install service
echo "⚙️ Installing systemd service..."
sudo cp livestream-archiver.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable livestream-archiver
# Set permissions
echo "🔐 Setting permissions..."
sudo chown -R rockvilleav:rockvilleav /home/rockvilleav/livestream-archiver
sudo chown -R rockvilleav:rockvilleav /home/rockvilleav/Sync/Livestreams
# Start service
echo "🚀 Starting service..."
sudo systemctl start livestream-archiver
# Show status
echo "📊 Service status:"
sudo systemctl status livestream-archiver --no-pager
echo "✅ Deployment complete!"
echo "📊 To check logs: sudo journalctl -u livestream-archiver -f"
echo "🔄 To restart: sudo systemctl restart livestream-archiver"
EOF
chmod +x package/build-and-deploy.sh
# Create the tar.gz package (without macOS extended attributes)
echo "📦 Creating tar.gz package..."
COPYFILE_DISABLE=1 tar --no-xattrs -czf livestream-archiver-source.tar.gz -C package .
# Clean up
rm -rf package
echo "✅ Package created: livestream-archiver-source.tar.gz"
echo ""
echo "📤 To deploy:"
echo "1. scp -P 8443 livestream-archiver-source.tar.gz rockvilleav@remote.rockvilletollandsda.church:/tmp/"
echo "2. ssh -p 8443 rockvilleav@remote.rockvilletollandsda.church"
echo "3. cd /tmp && tar -xzf livestream-archiver-source.tar.gz"
echo "4. ./build-and-deploy.sh"