mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Fix restore 1.4 (#38)
* [fix] Remove db:setup * [enh] add install rben on restore * [enh] Remove asset:precompile and db:migrate on restore * [enh] bundle and yarn install on restore
This commit is contained in:
parent
7a6eb781f1
commit
097bd9dec8
1 changed files with 30 additions and 18 deletions
|
@ -35,30 +35,30 @@ fi
|
||||||
# Check configuration files nginx
|
# Check configuration files nginx
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
if [ -f $nginx_conf ]; then
|
if [ -f $nginx_conf ]; then
|
||||||
ynh_die "The NGINX configuration already exists at '${nginx_conf}'.
|
ynh_die "The NGINX configuration already exists at '${nginx_conf}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
# Check configuration files php-fpm
|
# Check configuration files php-fpm
|
||||||
crontab_conf="/etc/cron.d/${app}"
|
crontab_conf="/etc/cron.d/${app}"
|
||||||
if [ -f $crontab_conf ]; then
|
if [ -f $crontab_conf ]; then
|
||||||
ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'.
|
ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore services
|
# Restore services
|
||||||
web_systemd="/etc/systemd/system/${app}-web.service"
|
web_systemd="/etc/systemd/system/${app}-web.service"
|
||||||
if [ -f "${web_systemd}" ]; then
|
if [ -f "${web_systemd}" ]; then
|
||||||
ynh_die "The MASTODON WEB configuration already exists at '${web_systemd}'.
|
ynh_die "The MASTODON WEB configuration already exists at '${web_systemd}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
sidekiq_systemd="/etc/systemd/system/${app}-sidekiq.service"
|
sidekiq_systemd="/etc/systemd/system/${app}-sidekiq.service"
|
||||||
if [ -f "${sidekiq_systemd}" ]; then
|
if [ -f "${sidekiq_systemd}" ]; then
|
||||||
ynh_die "The MASTODON SIDEKIQ configuration already exists at '${sidekiq_systemd}'.
|
ynh_die "The MASTODON SIDEKIQ configuration already exists at '${sidekiq_systemd}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
streaming_systemd="/etc/systemd/system/${app}-streaming.service"
|
streaming_systemd="/etc/systemd/system/${app}-streaming.service"
|
||||||
if [ -f "${streaming_systemd}" ]; then
|
if [ -f "${streaming_systemd}" ]; then
|
||||||
ynh_die "The MASTODON STREAMING configuration already exists at '${streaming_systemd}'.
|
ynh_die "The MASTODON STREAMING configuration already exists at '${streaming_systemd}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home
|
||||||
|
|
||||||
# Return to home
|
# Return to home
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
sudo cp -a ./sources/. "$final_path"
|
sudo cp -a ./sources/. "$final_path"
|
||||||
|
|
||||||
|
@ -117,21 +117,23 @@ sudo su -c "psql" postgres <<< \
|
||||||
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';"
|
||||||
|
|
||||||
|
# Install rbenv
|
||||||
|
sudo su - $app <<COMMANDS
|
||||||
|
pushd ~/.rbenv
|
||||||
|
src/configure && make -C src
|
||||||
|
echo 'export PATH="/opt/mastodon/.rbenv/bin:/opt/mastodon/live/bin:$PATH"' >> ~/.profile
|
||||||
|
echo 'export PATH="/opt/mastodon/.rbenv/bin:/opt/mastodon/live/bin:$PATH"' >> ~/.bashrc
|
||||||
|
echo 'eval "\$(rbenv init -)"' >> ~/.profile
|
||||||
|
COMMANDS
|
||||||
|
|
||||||
# Create user for db postgresql
|
# Create user for db postgresql
|
||||||
ynh_psql_create_db_without_password "$app"
|
ynh_psql_create_db_without_password "$app"
|
||||||
|
|
||||||
# Setup database
|
# Setup database
|
||||||
sudo su - $app <<SCOMMANDS
|
#sudo su - $app <<SCOMMANDS
|
||||||
cd ~/live
|
#cd ~/live
|
||||||
RAILS_ENV=production bin/bundle exec rails db:setup
|
#RAILS_ENV=production bin/bundle exec rails db:setup
|
||||||
SCOMMANDS
|
#SCOMMANDS
|
||||||
|
|
||||||
# Restore Mastodon
|
|
||||||
sudo su - $app <<RCOMMANDS
|
|
||||||
cd ~/live
|
|
||||||
RAILS_ENV=production bin/bundle exec rails db:migrate
|
|
||||||
RAILS_ENV=production bin/bundle exec rails assets:precompile
|
|
||||||
RCOMMANDS
|
|
||||||
|
|
||||||
# copy database dump
|
# copy database dump
|
||||||
sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
|
sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
|
||||||
|
@ -150,6 +152,16 @@ ynh_secure_remove $final_path/mastodon_db.sql
|
||||||
# Create symlink for ruby
|
# Create symlink for ruby
|
||||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
|
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
|
||||||
|
|
||||||
|
# Upgrade Mastodon
|
||||||
|
sudo su - $app <<RCOMMANDS
|
||||||
|
cd ~/live
|
||||||
|
bin/bundle install
|
||||||
|
yarn install --pure-lockfile
|
||||||
|
#RAILS_ENV=production bin/bundle exec rails db:migrate
|
||||||
|
#RAILS_ENV=production bundle exec rails assets:clean
|
||||||
|
#RAILS_ENV=production bin/bundle exec rails assets:precompile
|
||||||
|
RCOMMANDS
|
||||||
|
|
||||||
# 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue