town/scripts/tma

68 lines
1.7 KiB
Plaintext
Raw Normal View History

2024-05-06 01:53:48 +00:00
#!/bin/bash
set -e
signups="/town/var/signups/signups.db"
invites="/town/var/invites/invites.db"
users="/town/var/town.db"
bold=$(tput bold)
plain=$(tput sgr0)
which="${1}"
header() {
echo $bold
echo $1
echo $plain
}
case $which in
user)
username="${2}"
if [ "$username" == "" ]; then
echo "gimme a username"
exit
fi
header "i looked in $users and found:"
sqlite3 $users "select * from users where username='$username'"
header "their emails are:"
sqlite3 $users "select * from emails where userid in (select id from users where username='$username')"
header "i looked in $invites and found:"
sqlite3 $users "select address from emails where userid in (select id from users where username='$username')" | xargs printf "select * from invites where email='%s'" | sqlite3 $invites
header "i looked in $signups and found:"
sqlite3 $users "select address from emails where userid in (select id from users where username='$username')" | xargs printf "select * from signups where email like '%%%s%%'" | sqlite3 $signups
;;
email)
email="${2}"
if [ "$email" == "" ]; then
echo "gimme an email"
exit
fi
header "i looked in $signups and found:"
sqlite3 $signups "select * from signups where email like '%$email%'";
header "i looked in $invites and found:"
sqlite3 $invites "select * from invites where email='$email'"
header "i looked in $users and found:"
sqlite3 $users "select * from users where id in (select userid from emails where address='$email')"
;;
*)
echo "what do you want to know about?"
echo "i can tell you about: user, email"
exit 1
;;
esac