Created
June 3, 2017 03:04
-
-
Save tacostea/e0c3b805b1b187bf9686fd37363fcd04 to your computer and use it in GitHub Desktop.
Mastodonのユーザー数カウントするsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TMP=0とか書いて置いておけばいい | |
. ./usercount.txt | |
COUNT=$(sudo -u postgres echo $(psql -U postgres -t -c 'select count(*) from accounts where domain is null;' mastodon_production)) | |
if [ $COUNT -gt $TMP ] ; then | |
echo "TMP=$COUNT" > ./usercount.txt | |
echo "$TMP -> $COUNT" | |
#メール用の一時ファイル(消したかったらrmを後ろに突っ込んで) | |
tmptxt=./mailtmp.txt | |
echo "Subject: Newbie has commen!" > $tmptxt | |
echo "To: {宛先アドレス}" >> $tmptxt | |
echo "From: {送信元アドレス(なくてもいい)}" >> $tmptxt | |
echo "" >> $tmptxt | |
echo "User account has increased" >> $tmptxt | |
echo "$TMP -> $COUNT" >> $tmptxt | |
echo "" >> $tmptxt | |
sendmail -t < $tmptxt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment