-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxamp.sh
46 lines (39 loc) · 888 Bytes
/
xamp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
LOG_DIR="logs"
LOG_FILE="$LOG_DIR/server.log"
# Ensure the logs directory exists
mkdir -p "$LOG_DIR"
# Function to start the server
start_server() {
php -S $2 > "$LOG_FILE" 2>&1 &
echo "Server started on $2"
}
# Function to stop the server
stop_server() {
pkill -f "php -S $2"
echo "Server on $2 stopped"
}
# Function to show logs
show_logs() {
cat "$LOG_FILE"
}
# Function to show server status
show_status() {
if pgrep -f "php -S $2" >/dev/null; then
echo "Server on $2 is running"
else
echo "Server on $2 is not running"
fi
}
# Main script logic
if [ "$1" == "start" ]; then
start_server "$@"
elif [ "$1" == "stop" ]; then
stop_server "$@"
elif [ "$1" == "logs" ]; then
show_logs
elif [ "$1" == "status" ]; then
show_status "$@"
else
echo "Usage: ./xamp.sh [start|stop|logs|status] [host:port]"
fi