[enh] adds a plugin installer

This commit is contained in:
root 2020-04-01 13:13:52 +00:00
parent 0e2af77e47
commit 0f7709e83b
2 changed files with 94 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#!/bin/sh
domain=maubot.example.com
server_address="https://$domain"
home_server=matrix.com
install_dir=/opt/maubot
unix_user=www-data

93
plugins-install.sh Executable file
View File

@ -0,0 +1,93 @@
#!/bin/bash
panic(){ echo -e "$@"; exit 2; }
info(){ echo -e "\e[0;32m$@\e[0m"; }
which zip &>/dev/null || panic "Please install zip and unzip."
basePath=$( cd `dirname $BASH_SOURCE[0]` && pwd )
cd "$basePath"
# CONFIG MANAGEMENT
# Use a config file
[[ -f ./config ]] && source ./config
# Or set the following variables manually
# install_dir=/opt/maubot
# maubot_user=maubot
# maubot_pass=maubot
[[ -z "$install_dir" ]] || [[ -z "$maubot_user" ]] || [[ -z "$maubot_pass" ]] && panic "Please set variables"
declare -A botList
botList[https://github.com/maubot/jesaribot]="A simple bot that replies with an image when you say "jesari"."
botList[https://github.com/maubot/sed]="A bot to do sed-like replacements."
botList[https://github.com/maubot/factorial]="A bot to calculate unexpected factorials."
botList[https://github.com/maubot/media]="A bot that replies with the MXC URI of images you send it."
botList[https://github.com/maubot/dice]="A combined dice rolling and calculator bot."
botList[https://github.com/maubot/karma]="A user karma tracker bot."
botList[https://github.com/maubot/xkcd]="A bot to view xkcd comics."
botList[https://github.com/maubot/echo]="A bot that echoes pings and other stuff."
botList[https://github.com/maubot/rss]="A bot that posts RSS feed updates to Matrix."
botList[https://github.com/TomCasavant/RedditMaubot]="A bot that condescendingly corrects a user when they enter an r/subreddit without providing a link to that subreddit"
botList[https://github.com/TomCasavant/GiphyMaubot]="A bot that generates a gif (from giphy) given search terms"
botList[https://github.com/jeffcasavant/MaubotTrumpTweet]="A bot that generates a Trump tweet with the given content"
botList[https://github.com/TomCasavant/PollMaubot]="A bot that will create a simple poll for users in a room"
botList[https://github.com/dvdgsng/UrbanMaubot]="A bot that fetches definitions from [Urban Dictionary](https://www.urbandictionary.com/)."
botList[https://github.com/maubot/reminder]="A bot to remind you about things."
botList[https://github.com/maubot/translate]="A bot to translate words."
botList[https://github.com/maubot/reactbot]="A bot that responds to messages that match predefined rules."
botList[https://github.com/maubot/exec]="A bot that executes code."
botList[https://github.com/maubot/commitstrip]="A bot to view CommitStrips."
botList[https://github.com/maubot/supportportal]="A bot to manage customer support on Matrix."
botList[https://github.com/maubot/gitlab]="A GitLab client and webhook receiver."
botList[https://github.com/maubot/github]="A GitHub client and webhook receiver."
install=y
while [[ "$install" == "y" ]]; do
n=0
unset indexedArray
declare -A indexedArray
echo -e "\nAvailable bots:"
for k in ${!botList[@]}; do
echo " $n: ${botList[$k]}"
indexedArray[$n]=$k
let $(( n++ ))
done
echo
read -e -n 2 -p "Please enter a number or x to stop: " REPLY
case $REPLY in
([0-9]*)
URL=${indexedArray[$REPLY]}
[[ -z "$URL" ]] && echo "Invalid choice. Try again." && continue
zipURL="$URL/archive/master.zip"
tempDir=$(mktemp -d)
projectName=$(basename $URL)
cd "$tempDir"
info "Downloading file"
wget -q "$zipURL" &>/dev/null
info "Converting"
unzip master.zip &>/dev/null
cd "$projectName-master"
zip -r archive * &>/dev/null
mv archive.zip "$tempDir"
info "Ready to upload"
cd "$install_dir"
read -e -n 1 -i y -p "Do you want to login in maubot [Y/n]? " login
[[ "n" != ${login:-y} ]] && echo -e "Here are your config credentials: \n Username $maubot_user\n Password $maubot_pass\n Server $server_address\n" && "$install_dir/bin/mbc" login
"$install_dir/bin/mbc" upload "$tempDir/archive.zip" -s "$server_address"
rm -rf "$tempDir"
;;
(x)
install=n
;;
(*)
echo "Unknown choice '$REPLY'. Try again."
;;
esac
done