Last active
December 12, 2019 07:46
-
-
Save zunda/a60075ebf30497888e224fcce938c2e7 to your computer and use it in GitHub Desktop.
Herokuアプリのデータベースをリセットしてadminアカウントを作成して登録を閉じる
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/sh | |
set -e | |
run () { | |
echo \$ "$*" | |
eval "$*" | |
} | |
while getopts 'e:u:a:' c; do | |
case $c in | |
e) email=$OPTARG;; | |
u) username=$OPTARG;; | |
a) appname=$OPTARG;; | |
esac | |
done | |
if test -z "$appname"; then | |
appname=$HEROKU_APP | |
fi | |
if test -z "$email" || test -z "$username" || test -z "$appname"; then | |
echo Please specify all of -e email -u username -a appname | |
exit 1 | |
fi | |
echo "Resetting and creating account $username <$email> on $appname" | |
run heroku pg:reset -a $appname | |
run heroku run -a $appname rake db:migrate | |
# Create an account, capture the password and set it as a config var | |
result=`mktemp` | |
run heroku run -a $appname\ | |
tootctl accounts create $username --email $email --confirmed --role admin |\ | |
tee $result | |
password=`awk '/New password:/{print $NF}' $result` | |
rm -f $result | |
if test -z "$password"; then | |
exit 1 | |
fi | |
run heroku run -a $appname \ | |
"tootctl settings registrations close\; tootctl accounts approve $username" | |
run heroku config:set -a $appname USER_PASSWORD=$password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment