konata/install.sh

45 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2021-01-02 17:57:07 +01:00
#!/bin/ash
[ $(whoami) != "root" ] && echo "Must run as root!" && exit 1
echo "Installing dependencies..."
apk add lighttpd curl jq bash youtube-dl ffmpeg
2022-04-06 01:32:04 +02:00
if [ ! -f /etc/konata.conf ]
then
2022-04-06 01:32:04 +02:00
echo "Configuring bot..."
read -p "Please enter your bot token: " token
read -p "Please enter the bot's username (without @): " bot
read -p "Please enter the domain for your bot: " domain
read -p "Do you want to use a log chat? (y/n): " logans
[ "$logans" == "y" ] && read -p "What's the log chat's chat ID? " logchat
echo "token=$token" >> /etc/konata.conf
echo "bot=$bot" >> /etc/konata.conf
2022-04-06 01:32:04 +02:00
echo "domain=$domain" >> /etc/konata.conf
2021-01-13 17:48:40 +01:00
[ ! -z $logchat ] && echo "logchat=$logchat" >> /etc/konata.conf
2022-04-06 01:32:04 +02:00
else
. /etc/konata.conf
fi
2021-01-02 17:57:07 +01:00
echo "Installing application files..."
install -m644 lighttpd.conf /etc/lighttpd/lighttpd.conf
mkdir /var/www/konata
rand=$RANDOM
2021-04-07 15:43:29 +02:00
install -m755 konata.sh /usr/local/bin/konata
2022-04-06 01:32:04 +02:00
rm /var/www/konata/*.sh
2021-04-07 15:43:29 +02:00
ln -s /usr/local/bin/konata /var/www/konata/$rand.sh
install -m644 index.html /var/www/konata/index.html
2021-01-02 17:57:07 +01:00
echo "Requesting Telegram to use our webhook..."
curl -X POST "https://api.telegram.org/bot$token/setWebhook" \
-d "url=$domain/$rand.sh"
echo ""
echo "The webhook has been set to $domain/$rand.sh."
echo "Starting lighttpd..."
service lighttpd start
rc-update add lighttpd default
echo "Started and enabled lighttpd."
2021-01-02 17:57:07 +01:00
echo "That should be everything! Enjoy your new bot!"