aboutsummaryrefslogtreecommitdiff
path: root/scripts/restore
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/restore')
-rw-r--r--scripts/restore41
1 files changed, 36 insertions, 5 deletions
diff --git a/scripts/restore b/scripts/restore
index 946a62b..3a2eeaf 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -65,6 +65,39 @@ fi
# Create user unix
sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login
+# Reinstall dependencies
+ # Install debian package
+ ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https
+
+ # Install redis package
+ ynh_package_install redis-server redis-tools
+
+ # Install postgresql
+ ynh_package_install postgresql postgresql-contrib
+
+ # Install Ruby
+ ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
+
+ # Install source.list debian package backports & yarn
+ sudo cp ./apt_backports.list /etc/apt/sources.list.d/backports.list
+ sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
+ sudo cp ./apt_yarn.list /etc/apt/sources.list.d/yarn.list
+ ynh_package_update
+
+ # Install debian package backports
+ sudo apt-get -t jessie-backports -y install ffmpeg
+
+ # Install de Node.js
+ pushd /opt
+ curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
+ sudo apt-get -y install nodejs
+
+ # Install Yarn
+ ynh_package_install yarn
+
+ # Return to home
+ popd
+
# Restore sources & data
sudo cp -a ./sources/. "$final_path"
@@ -74,8 +107,6 @@ sudo chown -R $app: "$final_path"
# Debug
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';"
@@ -102,11 +133,11 @@ RAILS_ENV=production bin/bundle exec rails db:migrate
RAILS_ENV=production bin/bundle exec rails assets:precompile
RCOMMANDS
-# copy database
+# copy database dump
sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
sudo chmod a+r $final_path/mastodon_db.sql
-# Restore database
+# Restore database dump
sudo su - $app <<RECOMMANDS
dropdb mastodon_production
createdb mastodon_production
@@ -114,7 +145,7 @@ psql mastodon_production < $final_path/mastodon_db.sql
RECOMMANDS
# Remove dump
-sudo rm $final_path/mastodon_db.sql
+ynh_secure_remove $final_path/mastodon_db.sql
# Create symlink for ruby
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true