aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authormagikcypress <cyp@rouquin.me>2017-04-16 16:12:21 +0200
committermagikcypress <cyp@rouquin.me>2017-04-16 16:12:21 +0200
commit8b811b73436e64fee016e2a8f18a6e49601287cf (patch)
treeb05caf3a822484601e1357e6ed470e29ca83cb50 /scripts
parent2be310eefa3f86efba61a6df79fa70edf8cd20e8 (diff)
downloadmastodon_ynh-8b811b73436e64fee016e2a8f18a6e49601287cf.tar.gz
mastodon_ynh-8b811b73436e64fee016e2a8f18a6e49601287cf.tar.bz2
mastodon_ynh-8b811b73436e64fee016e2a8f18a6e49601287cf.zip
[enh] Create user + administrator
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.fonctions7
-rw-r--r--scripts/install24
2 files changed, 28 insertions, 3 deletions
diff --git a/scripts/.fonctions b/scripts/.fonctions
index 0a148a6..8013e27 100644
--- a/scripts/.fonctions
+++ b/scripts/.fonctions
@@ -110,6 +110,13 @@ SETUP_SOURCE () { # Download source, decompress and copu into $final_path
fi
}
+# Create user with special hack
+CREATE_USER () {
+ sudo curl -kSs https://${domain}/auth/sign_up --cookie-jar cookie | grep csrf > token || true
+ token=$(sudo cat token | sed -n '/csrf-token/s/.*name="csrf-token"\s\+content="\([^"]\+\).*/\1/p')
+ sudo curl -kSs https://${domain}/auth --data "&user[account_attributes][username]=${admin_mastodon}&user[email]=${admin_mastodon}@${domain}&user[password]=${admin_pass}&user[password_confirmation]=${admin_pass}&authenticity_token=${token}" --cookie cookie
+}
+
### REMOVE SCRIPT
REMOVE_NGINX_CONF () { # Delete nginx configuration
diff --git a/scripts/install b/scripts/install
index b78cb47..caeec25 100644
--- a/scripts/install
+++ b/scripts/install
@@ -188,8 +188,6 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Install crontab
sudo cp ../conf/crontab_mastodon /etc/cron.d/$app
sudo sed -i "s@__APP__@$app@g" /etc/cron.d/$app
-# Restart crontab
-sudo systemctl restart cron
# Private or not
if [ "$is_public" = "Yes" ];
@@ -208,4 +206,24 @@ fi
sudo yunohost app ssowatconf
# Reload Nginx
-sudo systemctl reload nginx \ No newline at end of file
+sudo systemctl reload nginx
+
+# all services start, please
+sleep 30
+
+# Mastodon need a user for creating an administator account
+# rake create user is not up for the moment
+# See PR: https://github.com/tootsuite/mastodon/pull/1482
+CREATE_USER
+
+# Create admin user
+# Create confirm email
+sudo su - $app <<ACOMMANDS
+pushd ~/live
+
+# RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=$admin_mastodon
+# RAILS_ENV=production bin/bundle exec rails mastodon:confirm_email USER_EMAIL=$admin_mastodon@$domain
+ACOMMANDS
+
+# Restart crontab
+sudo systemctl restart cron \ No newline at end of file