aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/backup7
-rw-r--r--scripts/install44
-rw-r--r--scripts/remove15
-rw-r--r--scripts/restore61
-rw-r--r--scripts/upgrade8
5 files changed, 82 insertions, 53 deletions
diff --git a/scripts/backup b/scripts/backup
index e4a5bba..b7ff222 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -32,7 +32,10 @@ ynh_backup "/etc/cron.d/${app}" "cron.conf"
ynh_backup "/etc/systemd/system/mastodon-web.service" "systemd_web.service"
ynh_backup "/etc/systemd/system/mastodon-sidekiq.service" "systemd_sidekiq.service"
ynh_backup "/etc/systemd/system/mastodon-streaming.service" "systemd_streaming.service"
-ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
+debian_version=$(lsb_release -c -s)
+if [[ $debian_version = jessie ]]; then
+ ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
+fi
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
# final_path on nginx
@@ -43,5 +46,3 @@ sudo su - postgres <<COMMANDS
pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql
COMMANDS
ynh_backup "/var/lib/postgresql/${app}_db.sql" "${app}_db.sql"
-# Fix backup fail on yunohost 2.6
-#ynh_secure_remove /var/lib/postgresql/mastodon_db.sql
diff --git a/scripts/install b/scripts/install
index 3d5172f..d92e0ed 100644
--- a/scripts/install
+++ b/scripts/install
@@ -47,7 +47,7 @@ ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt
ynh_package_install redis-server redis-tools
# Install postgresql
-ynh_package_install postgresql postgresql-contrib postgresql-server-dev-9.4
+ynh_package_install postgresql postgresql-contrib postgresql-server-dev-all
# Install Ruby
ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
@@ -59,14 +59,23 @@ if [[ $arch = arm* ]]; then
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
fi
-# Install source.list debian package backports & yarn
-sudo cp ../conf/backports.list /etc/apt/sources.list.d/
+# Install source.list debian yarn package
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
sudo cp ../conf/yarn.list /etc/apt/sources.list.d/
-ynh_package_update
-# Install debian package backports
+# Install source.list debian jessie package backports
+debian_version=$(lsb_release -c -s)
+if [[ $debian_version = jessie ]]; then
+sudo cp ../conf/backports.list /etc/apt/sources.list.d/
+ynh_package_update
sudo apt-get -t jessie-backports -y install ffmpeg
+else
+ynh_package_update
+ynh_package_install ffmpeg
+fi
+
+# Install Yarn
+ynh_package_install yarn
# Creates the destination directory and stores its location.
ynh_app_setting_set $app final_path $final_path
@@ -76,9 +85,6 @@ pushd /opt
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get -y install nodejs
-# Install Yarn
-ynh_package_install yarn
-
# Set UTF8 encoding by default
sudo su -c "psql" postgres <<< \
"update pg_database set datistemplate='false' where datname='template1';"
@@ -122,22 +128,26 @@ COMMANDS
# Install ruby-build
sudo su - $app <<RCOMMANDS
-/opt/mastodon/.rbenv/bin/rbenv install 2.5.0
-/opt/mastodon/.rbenv/versions/2.5.0/bin/ruby -v
+/opt/mastodon/.rbenv/bin/rbenv install 2.5.1
+/opt/mastodon/.rbenv/versions/2.5.1/bin/ruby -v
RCOMMANDS
# Create symlink for ruby
sudo rm /usr/bin/ruby || true
-sudo ln -s /opt/mastodon/.rbenv/versions/2.5.0/bin/ruby /usr/bin/ruby || true
+sudo ln -s /opt/mastodon/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
# Install Mastodon
sudo su - $app <<MCOMMANDS
pushd ~/live
-/opt/mastodon/.rbenv/versions/2.5.0/bin/gem install bundler
+/opt/mastodon/.rbenv/versions/2.5.1/bin/gem install bundler
bin/bundle install --deployment --without development test
-yarn install --production
MCOMMANDS
+# Yarn install on root
+pushd $final_path/live
+yarn install --pure-lockfile
+popd
+
# Adjust Mastodon config
pushd $final_path/live/
sudo cp -a .env.production.sample .env.production
@@ -171,9 +181,13 @@ sudo su - $app <<CCOMMANDS
pushd ~/live
echo "SAFETY_ASSURED=1">> .env.production
RAILS_ENV=production bin/bundle exec rails db:setup
-RAILS_ENV=production bin/bundle exec rails --trace assets:precompile
CCOMMANDS
+# Rails precompile on root
+pushd $final_path/live
+RAILS_ENV=production bin/bundle exec rails --trace assets:precompile
+popd
+
# init rbenv & create bundle
sudo su - $app <<BCOMMANDS
. ~/.profile
@@ -191,7 +205,7 @@ sudo cp ../conf/mastodon-streaming.service /etc/systemd/system/mastodon-streamin
sudo chown root: /etc/systemd/system/mastodon-streaming.service
sudo systemctl daemon-reload
-sudo systemctl enable /etc/systemd/system/mastodon-*.service
+sudo systemctl enable 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
diff --git a/scripts/remove b/scripts/remove
index 1b2c405..19ab132 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -23,24 +23,24 @@ domain=$(ynh_app_setting_get "$app" domain)
if [ -e "/etc/systemd/system/mastodon-web.service" ]; then
echo "Delete systemd script"
sudo systemctl stop mastodon-web.service
- ynh_secure_remove "/etc/systemd/system/mastodon-web.service"
sudo systemctl disable mastodon-web.service
+ ynh_secure_remove "/etc/systemd/system/mastodon-web.service"
fi
# Stop mastodon-sidekiq
if [ -e "/etc/systemd/system/mastodon-sidekiq.service" ]; then
echo "Delete systemd script"
sudo systemctl stop mastodon-sidekiq.service
- ynh_secure_remove "/etc/systemd/system/mastodon-sidekiq.service"
sudo systemctl disable mastodon-sidekiq.service
+ ynh_secure_remove "/etc/systemd/system/mastodon-sidekiq.service"
fi
# Stop mastodon-sidekiq
if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then
echo "Delete systemd script"
sudo systemctl stop mastodon-streaming.service
- ynh_secure_remove "/etc/systemd/system/mastodon-streaming.service"
sudo systemctl disable mastodon-streaming.service
+ ynh_secure_remove "/etc/systemd/system/mastodon-streaming.service"
fi
# Delete service on Yunohost monitoring
@@ -69,13 +69,10 @@ ynh_psql_drop_db "${app}_production"
ynh_psql_drop_role "${app}"
# Remove Debian package
-sudo apt-get remove --purge -y yarn
+#sudo apt-get remove --purge -y yarn
#sudo apt-get remove --purge -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file curl git
-# Delete redis package
#sudo apt-get remove --purge -y redis-server redis-tools
-# Delete postgresql package
#sudo apt-get remove --purge -y postgresql postgresql-contrib
-# Delete Ruby package
#sudo apt-get remove --purge -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
# Delete app directory and configurations
@@ -89,10 +86,10 @@ REMOVE_NGINX_CONF
ynh_secure_remove /etc/cron.d/$app
# Delete source.list
ynh_secure_remove /etc/apt/sources.list.d/backports.list
-ynh_secure_remove /etc/apt/sources.list.d/yarn.list
+#ynh_secure_remove /etc/apt/sources.list.d/yarn.list
# Delete ruby exec
-ynh_secure_remove /usr/bin/ruby
+#ynh_secure_remove /usr/bin/ruby
# Remove user
sudo userdel -f $app
diff --git a/scripts/restore b/scripts/restore
index 30666df..c6031de 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -67,35 +67,46 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home
# Reinstall dependencies
# Install debian package
- ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler
+ ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev
# Install redis package
ynh_package_install redis-server redis-tools
# Install postgresql
- ynh_package_install postgresql postgresql-contrib
+ ynh_package_install postgresql postgresql-contrib postgresql-server-dev-all
# 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
+ # Import debian archive pubkey, need on ARM arch
+ arch=$(uname -m)
+ if [[ $arch = arm* ]]; then
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
+ fi
+
+ # Install source.list debian yarn package
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
+ # Install source.list debian jessie package backports
+ debian_version=$(lsb_release -c -s)
+ if [[ $debian_version = jessie ]]; then
+ sudo cp ./apt_backports.list /etc/apt/sources.list.d/backports.list
+ ynh_package_update
sudo apt-get -t jessie-backports -y install ffmpeg
+ else
+ ynh_package_update
+ ynh_package_install ffmpeg
+ fi
+
+ # Install Yarn
+ ynh_package_install yarn
# Install de Node.js
pushd /opt
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get -y install nodejs
-
- # Install Yarn
- ynh_package_install yarn
-
- # Return to home
popd
# Restore sources & data
@@ -107,6 +118,9 @@ sudo chown -R $app: "$final_path"
# Debug
sudo ls -alh "$final_path"
+# Restart postgresql
+sudo systemctl restart postgresql
+
# Set UTF8 encoding by default
sudo su -c "psql" postgres <<< \
"update pg_database set datistemplate='false' where datname='template1';"
@@ -149,18 +163,21 @@ RECOMMANDS
# Remove dump
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
+# Create symlink for ruby 2.5.1
+sudo rm /usr/bin/ruby || true
+sudo ln -s /opt/mastodon/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
+
+# Install Mastodon
+sudo su - $app <<MCOMMANDS
+pushd ~/live
+$final_path/.rbenv/versions/2.5.1/bin/gem install bundler
+$final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
+MCOMMANDS
-# Upgrade Mastodon
-sudo su - $app <<RCOMMANDS
-cd ~/live
-bin/bundle install
+pushd $final_path/live
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
+systemctl restart postgresql
+popd
# Modify Nginx configuration file and copy it to Nginx conf directory
sudo sed -i "s@__PATH__@$app@g" ./nginx.conf
@@ -177,7 +194,7 @@ sudo cp ./systemd_streaming.service /etc/systemd/system/mastodon-streaming.servi
sudo chown root: /etc/systemd/system/mastodon-streaming.service
sudo systemctl daemon-reload
-sudo systemctl enable /etc/systemd/system/mastodon-*.service
+sudo systemctl enable 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
diff --git a/scripts/upgrade b/scripts/upgrade
index 2c27ab6..ca0df71 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -35,7 +35,7 @@ sudo sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Stop Mastodon Services
-sudo systemctl stop mastodon-*.service
+sudo systemctl stop mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
# Change owner of live folder
sudo chown -R $app: $final_path/live
@@ -65,7 +65,7 @@ if [[ $node_version =~ ^v4.*$ ]]; then
fi
# add additional package for upgrade
-ynh_package_install yarn pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-9.4
+ynh_package_install yarn pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all
# Install ruby 2.5.1 for release 2.4.0
sudo su - $app <<RCOMMANDS
@@ -84,7 +84,6 @@ sudo su - $app <<MCOMMANDS
pushd ~/live
$final_path/.rbenv/versions/2.5.1/bin/gem install bundler
$final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
-#yarn install --pure-lockfile
MCOMMANDS
# Install package with yarn and restart postgresql
@@ -97,6 +96,7 @@ popd
pushd $final_path/live
RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails assets:clean
RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails assets:precompile --trace
+popd
sudo su - $app <<UCOMMANDS
pushd ~/live
@@ -106,7 +106,7 @@ RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails mas
UCOMMANDS
# Restart Mastodon
-sudo systemctl start mastodon-*.service
+sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
# Waiting start all services
sleep 30