mumbullet/scripts/dev-server.sh

113 lines
2.5 KiB
Bash

#!/usr/bin/env bash
set -e
# Script to manage MumBullet development server
# Usage: ./scripts/dev-server.sh [start|stop|restart|status]
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
COMPOSE_FILE="$PROJECT_DIR/dev-compose.yml"
DEV_CONFIG="$PROJECT_DIR/dev-config.json"
# Check if Docker is running
check_docker() {
if ! docker info > /dev/null 2>&1; then
echo "Error: Docker is not running. Please start Docker and try again."
exit 1
fi
}
# Start the development server
start_server() {
echo "Starting Mumble development server..."
docker-compose -f "$COMPOSE_FILE" up -d
echo "Development server started at localhost:64738"
echo "Server password: devpass"
echo "Admin password: devsecret"
echo ""
echo "Run the bot with:"
echo "dart run bin/mumbullet.dart --config $DEV_CONFIG"
}
# Stop the development server
stop_server() {
echo "Stopping Mumble development server..."
docker-compose -f "$COMPOSE_FILE" down
echo "Development server stopped"
}
# Restart the development server
restart_server() {
echo "Restarting Mumble development server..."
docker-compose -f "$COMPOSE_FILE" restart
echo "Development server restarted"
}
# Check the status of the development server
server_status() {
echo "Mumble development server status:"
docker-compose -f "$COMPOSE_FILE" ps
}
# Create development config if it doesn't exist
ensure_dev_config() {
if [ ! -f "$DEV_CONFIG" ]; then
echo "Creating development configuration file..."
cat > "$DEV_CONFIG" << EOF
{
"mumble": {
"server": "localhost",
"port": 64738,
"username": "MumBullet",
"password": "devpass",
"channel": "Music"
},
"bot": {
"command_prefix": "!",
"default_permission_level": 0,
"max_queue_size": 50,
"cache_directory": "./dev-cache",
"max_cache_size_gb": 5
},
"dashboard": {
"port": 8080,
"admin_username": "admin",
"admin_password": "admin"
}
}
EOF
echo "Created development configuration at $DEV_CONFIG"
fi
# Ensure cache directory exists
mkdir -p "$PROJECT_DIR/dev-cache"
}
# Main script logic
check_docker
ensure_dev_config
case "$1" in
start)
start_server
;;
stop)
stop_server
;;
restart)
restart_server
;;
status)
server_status
;;
*)
echo "Usage: $0 [start|stop|restart|status]"
echo ""
echo " start - Start the Mumble development server"
echo " stop - Stop the Mumble development server"
echo " restart - Restart the Mumble development server"
echo " status - Show the Mumble development server status"
exit 1
;;
esac
exit 0