aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormagikcypress <cyp@rouquin.me>2017-04-29 16:00:41 +0200
committermagikcypress <cyp@rouquin.me>2017-04-29 16:00:54 +0200
commit2cef464c6ba44226baf0a1f0f6a512145b3929ea (patch)
treed566f4a581a1a7062e6f5283ffca74416da64a2d
parentcc04c85f305a7d901c058d3263c5cce604eb660d (diff)
downloadmastodon_ynh-2cef464c6ba44226baf0a1f0f6a512145b3929ea.tar.gz
mastodon_ynh-2cef464c6ba44226baf0a1f0f6a512145b3929ea.tar.bz2
mastodon_ynh-2cef464c6ba44226baf0a1f0f6a512145b3929ea.zip
[fix] restore script
-rw-r--r--scripts/install13
-rw-r--r--scripts/restore40
-rw-r--r--scripts/upgrade2
3 files changed, 30 insertions, 25 deletions
diff --git a/scripts/install b/scripts/install
index ed2b1e7..5d1e75e 100644
--- a/scripts/install
+++ b/scripts/install
@@ -70,13 +70,13 @@ ynh_package_install yarn
# Set UTF8 encoding by default
sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='false' where datname='template1';"
+ "update pg_database set datistemplate='false' where datname='template1';"
sudo su -c "psql" postgres <<< \
- "drop database template1;"
+ "drop database template1;"
sudo su -c "psql" postgres <<< \
- "create database template1 encoding='UTF8' template template0;"
+ "create database template1 encoding='UTF8' template template0;"
sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='true' where datname='template1';"
+ "update pg_database set datistemplate='true' where datname='template1';"
# Create DB without password
ynh_psql_create_db_without_password "$app"
@@ -92,11 +92,6 @@ CLONECOMMANDS
# Be king rewind (/var/cache/yunohost/from_file/scripts)
popd
-# # Get Mastodon last version
-# sudo mkdir "${final_path}/live"
-# SETUP_SOURCE
-# sudo chown -R $app: "${final_path}"
-
# Install de rbenv
sudo su - $app <<COMMANDS
pushd ~/.rbenv
diff --git a/scripts/restore b/scripts/restore
index f754d81..70b876b 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -24,7 +24,7 @@ is_public=$(ynh_app_setting_get $app is_public)
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
- || ynh_die "Path not available: ${domain}${path}"
+ || ynh_die "Path not available: ${domain}${path}"
# Check $final_path
final_path="/opt/${app}"
@@ -66,29 +66,33 @@ fi
sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login
# Restore sources & data
-sudo cp -a ./sources "$final_path"
+sudo cp -a ./sources/. "$final_path"
# Set permissions
sudo chown -R $app: "$final_path"
+sudo ls -alh "$final_path"
+
+# Change directory for create user & database postgresql
+
# Set UTF8 encoding by default
sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='false' where datname='template1';"
+ "update pg_database set datistemplate='false' where datname='template1';"
sudo su -c "psql" postgres <<< \
- "drop database template1;"
+ "drop database template1;"
sudo su -c "psql" postgres <<< \
- "create database template1 encoding='UTF8' template template0;"
+ "create database template1 encoding='UTF8' template template0;"
sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='true' where datname='template1';"
+ "update pg_database set datistemplate='true' where datname='template1';"
-# Restore db
+# Create user for db postgresql
ynh_psql_create_db_without_password "$app"
-sudo su - postgres <<COMMANDS
-pg_dump --role=mastodon -U postgres --no-password mastodon < $YNH_APP_BACKUP_DIR/mastodon_db.sql
-COMMANDS
-# Create symlink for ruby
-sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
+# Setup database
+sudo su - $app <<SCOMMANDS
+cd ~/live
+RAILS_ENV=production bin/bundle exec rails db:setup
+SCOMMANDS
# Restore Mastodon
sudo su - $app <<RCOMMANDS
@@ -97,16 +101,22 @@ RAILS_ENV=production bin/bundle exec rails db:migrate
RAILS_ENV=production bin/bundle exec rails assets:precompile
RCOMMANDS
+# restore database
+sudo pg_dump mastodon_production < $YNH_APP_BACKUP_DIR/mastodon_db.sql
+
+# Create symlink for ruby
+sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
+
# Restore nginx configuration files
sudo cp -a ./nginx.conf "$nginx_conf"
# Restore crontab
sudo cp -a ./cron.conf "$crontab_conf"
-sudo cp ../conf/mastodon-web.service /etc/systemd/system/mastodon-web.service
+sudo cp ./systemd_web.service /etc/systemd/system/mastodon-web.service
sudo chown root: /etc/systemd/system/mastodon-web.service
-sudo cp ../conf/mastodon-sidekiq.service /etc/systemd/system/mastodon-sidekiq.service
+sudo cp ./systemd_sidekiq.service /etc/systemd/system/mastodon-sidekiq.service
sudo chown root: /etc/systemd/system/mastodon-sidekiq.service
-sudo cp ../conf/mastodon-streaming.service /etc/systemd/system/mastodon-streaming.service
+sudo cp ./systemd_streaming.service /etc/systemd/system/mastodon-streaming.service
sudo chown root: /etc/systemd/system/mastodon-streaming.service
sudo systemctl daemon-reload
diff --git a/scripts/upgrade b/scripts/upgrade
index 655f22f..07b3ee7 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -44,7 +44,7 @@ git fetch
git pull https://github.com/tootsuite/mastodon.git master
git checkout $(git tag | tail -n 1)
bin/bundle install
-yarn install --production
+yarn install --pure-lockfile
RAILS_ENV=production bundle exec rails assets:clean
RAILS_ENV=production bundle exec rails assets:precompile
RAILS_ENV=production bundle exec rails db:migrate