mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Merge branch 'refs/heads/pr/5'
# Conflicts: # scripts/restore
This commit is contained in:
commit
71fe59cb4e
3 changed files with 30 additions and 32 deletions
|
@ -70,13 +70,13 @@ ynh_package_install yarn
|
||||||
|
|
||||||
# Set UTF8 encoding by default
|
# Set UTF8 encoding by default
|
||||||
sudo su -c "psql" postgres <<< \
|
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 <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
"drop database template1;"
|
"drop database template1;"
|
||||||
sudo su -c "psql" postgres <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
"create database template1 encoding='UTF8' template template0;"
|
"create database template1 encoding='UTF8' template template0;"
|
||||||
sudo su -c "psql" postgres <<< \
|
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
|
# Create DB without password
|
||||||
ynh_psql_create_db_without_password "$app"
|
ynh_psql_create_db_without_password "$app"
|
||||||
|
@ -92,11 +92,6 @@ CLONECOMMANDS
|
||||||
# Be king rewind (/var/cache/yunohost/from_file/scripts)
|
# Be king rewind (/var/cache/yunohost/from_file/scripts)
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# # Get Mastodon last version
|
|
||||||
# sudo mkdir "${final_path}/live"
|
|
||||||
# SETUP_SOURCE
|
|
||||||
# sudo chown -R $app: "${final_path}"
|
|
||||||
|
|
||||||
# Install de rbenv
|
# Install de rbenv
|
||||||
sudo su - $app <<COMMANDS
|
sudo su - $app <<COMMANDS
|
||||||
pushd ~/.rbenv
|
pushd ~/.rbenv
|
||||||
|
|
|
@ -24,7 +24,7 @@ is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
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
|
# Check $final_path
|
||||||
final_path="/opt/${app}"
|
final_path="/opt/${app}"
|
||||||
|
@ -66,38 +66,35 @@ fi
|
||||||
sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login
|
sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
sudo cp -a ./sources "$final_path"
|
sudo cp -a ./sources/. "$final_path"
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
sudo chown -R $app: "$final_path"
|
sudo chown -R $app: "$final_path"
|
||||||
sudo chmod -R a+rx /home/yunohost.backup/tmp
|
sudo chmod -R a+rx /home/yunohost.backup/tmp
|
||||||
|
|
||||||
|
|
||||||
|
sudo ls -alh "$final_path"
|
||||||
|
|
||||||
|
# Change directory for create user & database postgresql
|
||||||
|
|
||||||
# Set UTF8 encoding by default
|
# Set UTF8 encoding by default
|
||||||
sudo su -c "psql" postgres <<< \
|
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 <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
"drop database template1;"
|
"drop database template1;"
|
||||||
sudo su -c "psql" postgres <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
"create database template1 encoding='UTF8' template template0;"
|
"create database template1 encoding='UTF8' template template0;"
|
||||||
sudo su -c "psql" postgres <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
"update pg_database set datistemplate='true' where datname='template1';"
|
"update pg_database set datistemplate='true' where datname='template1';"
|
||||||
|
|
||||||
# Copy postgresql dump
|
# Create user for db postgresql
|
||||||
sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
|
|
||||||
|
|
||||||
# Restore db
|
|
||||||
ynh_psql_create_db_without_password "$app"
|
ynh_psql_create_db_without_password "$app"
|
||||||
sudo systemctl restart postgresql
|
|
||||||
sudo su - postgres <<COMMANDS
|
|
||||||
pg_restore --role=mastodon -U postgres --no-password < $final_path/mastodon_db.sql
|
|
||||||
COMMANDS
|
|
||||||
|
|
||||||
# Delete dump after restore
|
# Setup database
|
||||||
# rm $final_path/mastodon_db.sql
|
sudo su - $app <<SCOMMANDS
|
||||||
|
cd ~/live
|
||||||
# Create symlink for ruby
|
RAILS_ENV=production bin/bundle exec rails db:setup
|
||||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
|
SCOMMANDS
|
||||||
|
|
||||||
# Restore Mastodon
|
# Restore Mastodon
|
||||||
sudo su - $app <<RCOMMANDS
|
sudo su - $app <<RCOMMANDS
|
||||||
|
@ -106,16 +103,22 @@ RAILS_ENV=production bin/bundle exec rails db:migrate
|
||||||
RAILS_ENV=production bin/bundle exec rails assets:precompile
|
RAILS_ENV=production bin/bundle exec rails assets:precompile
|
||||||
RCOMMANDS
|
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
|
# Restore nginx configuration files
|
||||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
sudo cp -a ./nginx.conf "$nginx_conf"
|
||||||
# Restore crontab
|
# Restore crontab
|
||||||
sudo cp -a ./cron.conf "$crontab_conf"
|
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 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 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 chown root: /etc/systemd/system/mastodon-streaming.service
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|
|
@ -44,7 +44,7 @@ git fetch
|
||||||
git pull https://github.com/tootsuite/mastodon.git master
|
git pull https://github.com/tootsuite/mastodon.git master
|
||||||
git checkout $(git tag | tail -n 1)
|
git checkout $(git tag | tail -n 1)
|
||||||
bin/bundle install
|
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:clean
|
||||||
RAILS_ENV=production bundle exec rails assets:precompile
|
RAILS_ENV=production bundle exec rails assets:precompile
|
||||||
RAILS_ENV=production bundle exec rails db:migrate
|
RAILS_ENV=production bundle exec rails db:migrate
|
||||||
|
|
Loading…
Reference in a new issue