Finish up the installer

This commit is contained in:
Michael De Roover 2022-01-01 23:25:26 +01:00
parent 03b5e60a97
commit 0bfbf113b4
Signed by: vim
GPG Key ID: 075496E232CE04CB
2 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,6 @@
#!/usr/bin/python3
import sys
sys.path.append("/var/ubot")
from telethon import TelegramClient, events
from config import *

10
install
View File

@ -41,7 +41,7 @@ mkuser(){
addfiles(){
# Install executable and config
install -m770 -o root -g bot /var/ubot
install -dm770 -o root -g bot /var/ubot
install -m640 -o root -g bot config.py /var/ubot/config.py
install -m755 -o root -g root bin/ubot /usr/bin/ubot
@ -57,6 +57,8 @@ addfiles(){
}
# Install dependencies
[ $(which apt) ] && apt install python3-pip
[ $(which apk) ] && apk add py3-pip
pip3 install -U telethon
# Generate config if not built yet
[ ! -f config.py ] && mkconfig
@ -65,4 +67,10 @@ mkuser
# Install files if config is (now) present
[ -f config.py ] && addfiles
# Run Telethon for the first time
echo "Please log in to Telegram now."
echo "Afterwards you can hit Ctrl-C and start the ubot service."
umask 0077
su bot -s /usr/bin/ubot
return 0