-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
109 lines (78 loc) · 4.6 KB
/
install.sh
File metadata and controls
109 lines (78 loc) · 4.6 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
set -e
clear
cat << "EOF"
█████████ █████████ ██████ ██████ ███████████ ███ █████████ ███
███░░░░░███ ███░░░░░███ ░░██████ ██████ ░░███░░░░░░█ ███ ███░░░░░███ ░░███
░███ ░░░ ░███ ░███ ░███░█████░███ ░███ █ ░ ████████ █████ ████ ███ ░███ ░░░ ██████ ████████ █████ █████ ██████ ████████ ░░███
░░█████████ ░███████████ ░███░░███ ░███ ░███████ ░░███░░███░░███ ░███ ░███ ░░█████████ ███░░███░░███░░███░░███ ░░███ ███░░███░░███░░███ ░███
░░░░░░░░███ ░███░░░░░███ ░███ ░░░ ░███ ░███░░░█ ░███ ░███ ░███ ░███ ░███ ░░░░░░░░███░███████ ░███ ░░░ ░███ ░███ ░███████ ░███ ░░░ ░███
███ ░███ ░███ ░███ ░███ ░███ ░███ ░ ░███ ░███ ░███ ░███ ░░███ ███ ░███░███░░░ ░███ ░░███ ███ ░███░░░ ░███ ███
░░█████████ █████ █████ █████ █████ █████ ██ ░███████ ░░███████ ░░███░░█████████ ░░██████ █████ ░░█████ ░░██████ █████ ██░
░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░ ░███░░░ ░░░░░███ ░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░
░███ ███ ░███
█████ ░░██████
░░░░░ ░░░░░░
EOF
APP="samfpy-server"
REPO="https://github.com/Harrylevesque/SAMFpy-Server.git"
BRANCH="main"
DIR="$HOME/$APP"
PORT=8189
echo "Installing dependencies..."
if command -v apt >/dev/null; then
sudo apt update
sudo apt install -y git python3 python3-venv python3-pip
elif command -v dnf >/dev/null; then
sudo dnf install -y git python3 python3-pip
elif command -v pacman >/dev/null; then
sudo pacman -Sy git python python-pip
else
echo "Unsupported package manager"
exit 1
fi
echo "Cloning SAMFpy Server..."
if [ ! -d "$DIR" ]; then
git clone -b "$BRANCH" "$REPO" "$DIR"
fi
cd "$DIR"
echo "Creating Python virtual environment..."
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
echo "Creating runner script run.sh..."
cat <<EOL > run.sh
#!/usr/bin/env bash
cd "$DIR"
echo "Updating SAMFpy..."
git pull
source venv/bin/activate
pip install -r requirements.txt --upgrade
echo "Starting SAMFpy Server..."
exec uvicorn main:app --host 0.0.0.0 --port $PORT
EOL
chmod +x run.sh
echo "Creating systemd service..."
sudo tee /etc/systemd/system/$APP.service > /dev/null <<EOL
[Unit]
Description=SAMFpy Server
After=network.target
[Service]
User=$USER
WorkingDirectory=$DIR
ExecStart=$DIR/run.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl daemon-reload
sudo systemctl enable $APP
sudo systemctl restart $APP
echo ""
echo "SAMFpy Server installed successfully!"
echo "Server running on port $PORT"
echo ""
echo "Check status with:"
echo "sudo systemctl status $APP"