gitscope
https://dev.kronoz.win/r/marzneshin.git
tools/service-install.sh · v0.2.0
Source
1 a47eb4c Dawsh 2y ago #!/bin/bash
2 a47eb4c Dawsh 2y ago
3 2654e10 Dawsh 2y ago SERVICE_NAME="marzneshin"
4 2654e10 Dawsh 2y ago SERVICE_DESCRIPTION="Marzneshin Service"
5 2654e10 Dawsh 2y ago SERVICE_DOCUMENTATION="https://github.com/khodedawsh/marzneshin"
6 a47eb4c Dawsh 2y ago MAIN_PY_PATH="$PWD/main.py"
7 a47eb4c Dawsh 2y ago SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
8 a47eb4c Dawsh 2y ago
9 a47eb4c Dawsh 2y ago # Create the service file
10 a47eb4c Dawsh 2y ago cat > $SERVICE_FILE <<EOF
11 a47eb4c Dawsh 2y ago [Unit]
12 a47eb4c Dawsh 2y ago Description=$SERVICE_DESCRIPTION
13 a47eb4c Dawsh 2y ago Documentation=$SERVICE_DOCUMENTATION
14 a47eb4c Dawsh 2y ago After=network.target nss-lookup.target
15 a47eb4c Dawsh 2y ago
16 a47eb4c Dawsh 2y ago [Service]
17 a47eb4c Dawsh 2y ago ExecStart=/usr/bin/env python3 $MAIN_PY_PATH
18 a47eb4c Dawsh 2y ago Restart=on-failure
19 a47eb4c Dawsh 2y ago WorkingDirectory=$PWD
20 a47eb4c Dawsh 2y ago
21 a47eb4c Dawsh 2y ago [Install]
22 a47eb4c Dawsh 2y ago WantedBy=multi-user.target
23 a47eb4c Dawsh 2y ago EOF
24 a47eb4c Dawsh 2y ago
25 a47eb4c Dawsh 2y ago systemctl daemon-reload
26 a47eb4c Dawsh 2y ago
27 a47eb4c Dawsh 2y ago echo "Service file created at: $SERVICE_FILE"