Skip to content

Commit f7a42b4

Browse files
authored
Update install.sh
1 parent 4d0f6e8 commit f7a42b4

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

custom-http-server/install.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
#!/bin/bash
2-
32
set -e
43

54
TARGET_DIR="/opt/custom_http_server"
5+
CONFIG_PATH="/etc/custom-http-server.conf"
6+
SERVICE_PATH="/etc/systemd/system/custom-http-server.service"
67

78
echo "Installing Custom HTTP Server..."
89

9-
sudo mkdir -p $TARGET_DIR
10-
sudo cp custom_http_server.py $TARGET_DIR/
11-
sudo cp custom-http-server.service /etc/systemd/system/
12-
sudo cp default-config.conf /etc/custom-http-server.conf
10+
# Detect OS
11+
OS_NAME="$(uname)"
12+
13+
# macOS adjustments
14+
if [[ "$OS_NAME" == "Darwin" ]]; then
15+
TARGET_DIR="/usr/local/custom_http_server"
16+
CONFIG_PATH="/usr/local/etc/custom-http-server.conf"
17+
fi
18+
19+
# Create target and config directories
20+
sudo mkdir -p "$TARGET_DIR"
21+
sudo mkdir -p "$(dirname "$CONFIG_PATH")"
22+
23+
# Copy application and config files
24+
sudo cp custom_http_server.py "$TARGET_DIR/"
25+
sudo cp default-config.conf "$CONFIG_PATH"
26+
27+
if [[ "$OS_NAME" == "Linux" ]]; then
28+
sudo cp custom-http-server.service "$SERVICE_PATH"
29+
sudo systemctl daemon-reload
30+
sudo systemctl enable custom-http-server
31+
sudo systemctl start custom-http-server
32+
33+
echo "✅ Installed and started custom-http-server as a systemd service."
34+
echo "Edit $CONFIG_PATH to change path or port."
35+
echo "Logs: sudo journalctl -u custom-http-server -f"
1336

14-
sudo systemctl daemon-reload
15-
sudo systemctl enable custom-http-server
16-
sudo systemctl start custom-http-server
37+
elif [[ "$OS_NAME" == "Darwin" ]]; then
38+
echo "✅ Installed on macOS."
39+
echo "To run manually: python3 $TARGET_DIR/custom_http_server.py"
40+
echo "To make it a service, create a launchd plist manually."
1741

18-
echo "Installed and started custom-http-server."
19-
echo "Edit /etc/custom-http-server.conf to change path or port."
20-
echo "Logs: sudo journalctl -u custom-http-server -f"
42+
else
43+
echo "❌ Unsupported OS: $OS_NAME"
44+
exit 1
45+
fi

0 commit comments

Comments
 (0)