update install script

This commit is contained in:
Riley Housden 2022-08-19 22:43:49 -04:00
parent a8169108b8
commit 54c601d7ca
Signed by: InValidFire
GPG key ID: 0D6208F6DF56B4D8
3 changed files with 25 additions and 9 deletions

View file

@ -1,6 +0,0 @@
addgroup radical-bot
adduser --system --home /otp/radical-bot --ingroup radical-bot radical-bot
sudo -u radical-bot git clone https://gitdab.com/InValidFire/radical-bot.git /otp/radical-bot
sudo -u radical-bot python3.9 -m pip install -r /otp/radical-bot/requirements.txt
cp radical-bot.service /etc/systemd/system
systemd enable radical-bot

22
install.xsh Normal file
View file

@ -0,0 +1,22 @@
import os
from pathlib import Path
user = input("Enter name of server's system user: ")
root = Path(input("Enter the path of the server's root directory: "))
if not root.exists():
$(mkdir @(root))
print(f"Made server directory at {root}")
$(useradd --system @(user))
with Path("service.service").open("r") as fp:
text = fp.read()
text = text.replace("$user$", user)
text = text.replace("$root$", str(root))
text = text.replace("$ram$", str(ram))
$(cp service.service @(user).service)
with Path(f"{user}.service").open("w+") as fp:
fp.write(text)
$(cp @(user).service /etc/systemd/system)
$(cd @(root))
$(systemctl enable @(user).service)

View file

@ -4,9 +4,9 @@ After=network.target
StartLimitIntervalSec=0 StartLimitIntervalSec=0
[Service] [Service]
WorkingDirectory=/otp/radical-bot WorkingDirectory=$root$
User=radical-bot User=$user$
Group=radical-bot Group=$user$
Restart=always Restart=always
RestartSec=20 3 RestartSec=20 3
ExecStart=/usr/bin/env python3.9 main.py ExecStart=/usr/bin/env python3.9 main.py