Skip to content

Instantly share code, notes, and snippets.

@tacostea
Created June 3, 2017 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacostea/e0c3b805b1b187bf9686fd37363fcd04 to your computer and use it in GitHub Desktop.
Save tacostea/e0c3b805b1b187bf9686fd37363fcd04 to your computer and use it in GitHub Desktop.
Mastodonのユーザー数カウントするsh
#!/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