aboutsummaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
author__cyp <cyp@rouquin.me>2017-04-10 16:01:13 +0200
committerGitHub <noreply@github.com>2017-04-10 16:01:13 +0200
commitea42525c1337719de22303a0e53a8b190b224c79 (patch)
tree254e856061f11cf1c8a327d00e46e73d12897190 /scripts/install
parentb2cd5cc97ad463beac1f12f8ccc02a76c97dc257 (diff)
parent4dfe2759421883575d4a63d2879d58b93bc56f6a (diff)
downloadmastodon_ynh-ea42525c1337719de22303a0e53a8b190b224c79.tar.gz
mastodon_ynh-ea42525c1337719de22303a0e53a8b190b224c79.tar.bz2
mastodon_ynh-ea42525c1337719de22303a0e53a8b190b224c79.zip
Merge branch 'master' into master
Diffstat (limited to 'scripts/install')
-rw-r--r--scripts/install40
1 files changed, 18 insertions, 22 deletions
diff --git a/scripts/install b/scripts/install
index f3c9ed4..ad88c10 100644
--- a/scripts/install
+++ b/scripts/install
@@ -9,7 +9,7 @@ source /usr/share/yunohost/helpers # Source app helpers
CLEAN_SETUP () {
# Clean installation residues that are not supported by the remove script.
# Clean hosts
- sudo sed -i '/#MASTODON/d' /etc/hosts
+ echo ""
}
TRAP_ON # Active trap to stop the script if an error is detected.
@@ -17,7 +17,6 @@ domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin_mastodon=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
-#language=$YNH_APP_ARG_LANGUAGE
app=$YNH_APP_INSTANCE_NAME
@@ -66,19 +65,15 @@ curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
sudo apt-get -y install nodejs
sudo npm install -g yarn
-## Install postgresql database
+# Create DB without password
sudo systemctl restart postgresql
-dbname=$app
-dbuser=$app
-# Generate random password
-dbpass=$(ynh_string_random)
-ynh_psql_create_db "$dbname" "$dbuser" "$dbpass"
+ynh_psql_create_db_without_password "$app"
# Download all Ruby source
sudo git clone https://github.com/rbenv/rbenv.git $final_path/.rbenv
sudo git clone https://github.com/rbenv/ruby-build.git $final_path/.rbenv/plugins/ruby-build
sudo git clone https://github.com/tootsuite/mastodon.git $final_path/live
-sudo git clone git://github.com/dcarley/rbenv-sudo.git $final_path/.rbenv/plugins/rbenv-sudo
+
sudo chown -R $app: "${final_path}"
# Install de rbenv
@@ -87,7 +82,6 @@ pushd ~/.rbenv
src/configure && make -C src
echo 'export PATH="/opt/mastodon/.rbenv/bin:/opt/mastodon/live/bin:$PATH"' >> ~/.bashrc
echo 'eval "\$(rbenv init -)"' >> ~/.bashrc
-echo "alias su='env PATH=\$PATH'" >> ~/.bashrc
COMMANDS
# Install ruby-build
@@ -110,11 +104,12 @@ MCOMMANDS
# Adjust Mastodon config
pushd $final_path/live/
sudo cp -a .env.production.sample .env.production
-sudo sed -i "s@REDIS_HOST=localhost@REDIS_HOST=127.0.0.1@g" "${final_path}/live/.env.production"
+sudo sed -i "s@REDIS_HOST=redis@REDIS_HOST=127.0.0.1@g" "${final_path}/live/.env.production"
sudo sed -i "s@DB_HOST=db@DB_HOST=/var/run/postgresql@g" "${final_path}/live/.env.production"
-sudo sed -i "s@DB_USER=mastodon@DB_USER=${dbuser}@g" "${final_path}/live/.env.production"
-sudo sed -i "s@DB_NAME=mastodon@DB_NAME=${dbname}@g" "${final_path}/live/.env.production"
-sudo sed -i "s@LOCAL_DOMAIN=domainedevotreinstance.tld@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production"
+sudo sed -i "s@DB_USER=postgres@DB_USER=${app}@g" "${final_path}/live/.env.production"
+sudo sed -i "s@DB_NAME=postgres@DB_NAME=${app}_production@g" "${final_path}/live/.env.production"
+# sudo sed -i "s@DB_PASS=@DB_PASS=${dbpass}@g" "${final_path}/live/.env.production"
+sudo sed -i "s@LOCAL_DOMAIN=example.com@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production"
sudo sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production"
sudo sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production"
@@ -125,12 +120,17 @@ sudo sed -i 's,SMTP_FROM_ADDRESS=notifications@example.com,SMTP_FROM_ADDRESS='${
# Create database
# Preconfig CSS & JS
+# Create admin user
+# Create confirm email
sudo su - $app <<ENDCOMMANDS
pushd ~/live
RAILS_ENV=production bin/bundle exec rails db:setup
RAILS_ENV=production bin/bundle exec rails assets:precompile
ENDCOMMANDS
+# 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
+
# Add Services
pushd /var/cache/yunohost/from_file/mastodon_ynh-master/scripts
@@ -142,10 +142,9 @@ sudo cp ../conf/mastodon-streaming.service /etc/systemd/system/mastodon-streamin
sudo chown root: /etc/systemd/system/mastodon-streaming.service
sudo systemctl enable /etc/systemd/system/mastodon-*.service
-sudo systemctl daemon-reload
-sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
+# sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
# # debug
-sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
+# sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
# Add service YunoHost
sudo yunohost service add mastodon-web
@@ -159,7 +158,7 @@ sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.con
# Install crontab
sudo cp ../conf/crontab_mastodon /etc/cron.d/$app
-sudo sed -i "s@__AP__@$app@g" /etc/cron.d/$app
+sudo sed -i "s@__APP__@$app@g" /etc/cron.d/$app
# Private or not
if [ "$is_public" = "Yes" ];
@@ -177,10 +176,7 @@ fi
# Reload SSOwat configuration
sudo yunohost app ssowatconf
-# Reload Nginx and regenerate SSOwat conf
+# Reload Nginx
sudo systemctl reload nginx || true
# debug
sudo systemctl status nginx
-
-# Nettoyer hosts
-sudo sed -i '/#MASTODON/d' /etc/hosts