install script

This commit is contained in:
godot 2024-10-28 13:32:24 +01:00
parent 8501ef3903
commit 24c5758118
3 changed files with 67 additions and 3 deletions

27
disbot.service Normal file
View File

@ -0,0 +1,27 @@
[Unit]
Description=Discord bot
After=syslog.target
[Service]
Type=simple
User=disbot
Group=disbot
ProtectControlGroups=true
ProtectHome=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=full
PrivateDevices=true
PrivateUsers=true
WorkingDirectory=/opt/disbot/
ExecStart=/opt/disbot/env/bin/python3 /opt/disbot/disbot.py
Restart=on-failure
[Install]
WantedBy=multi-user.target

View File

@ -3,9 +3,11 @@ aiohttp==3.10.10
aiosignal==1.3.1
attrs==24.2.0
discord.py==2.4.0
frozenlist==1.4.1
frozenlist==1.5.0
idna==3.10
logging==0.4.9.6
multidict==6.1.0
propcache==0.2.0
yarl==1.15.5
yarl==1.16.0

35
script.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
printf "Better to run as root, because of permisions handeling.\n"
sleep 2
apt update
apt upgrade
apt install python3 python3.11-venv screen pip git vim
groupadd disbot
useradd --system --shell /usr/sbin/nologin --home /opt/disbot -g disbot disbot
mkdir /opt/disbot/
# python virtual enviroment
mkdir /opt/disbot/env/
python3 -m venv /opt/disbot/env/
source /opt/disbot/env/bin/activate
pip install -r req.txt
deactivate
mv mainbank.json disbot.py /opt/disbot/
chown -r disbot:disbot /opt/disbot/
#systemD
mv disbot.service /etc/systemd/system/
systemctl daemon-reload
systemctl start disbot.service
systemctl enable disbot.service