mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
Ready to Debian Stretch
This commit is contained in:
parent
d720ad3db7
commit
e8f3f0fb72
5 changed files with 56 additions and 40 deletions
|
@ -43,5 +43,3 @@ sudo su - postgres <<COMMANDS
|
||||||
pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql
|
pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql
|
||||||
COMMANDS
|
COMMANDS
|
||||||
ynh_backup "/var/lib/postgresql/${app}_db.sql" "${app}_db.sql"
|
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
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt
|
||||||
ynh_package_install redis-server redis-tools
|
ynh_package_install redis-server redis-tools
|
||||||
|
|
||||||
# Install postgresql
|
# 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
|
# Install Ruby
|
||||||
ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
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
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install source.list debian package backports & yarn
|
# Install source.list debian yarn package
|
||||||
sudo cp ../conf/backports.list /etc/apt/sources.list.d/
|
|
||||||
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||||
sudo cp ../conf/yarn.list /etc/apt/sources.list.d/
|
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
|
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.
|
# Creates the destination directory and stores its location.
|
||||||
ynh_app_setting_set $app final_path $final_path
|
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 -
|
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
|
||||||
sudo apt-get -y install nodejs
|
sudo apt-get -y install nodejs
|
||||||
|
|
||||||
# Install Yarn
|
|
||||||
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';"
|
||||||
|
|
|
@ -69,13 +69,10 @@ ynh_psql_drop_db "${app}_production"
|
||||||
ynh_psql_drop_role "${app}"
|
ynh_psql_drop_role "${app}"
|
||||||
|
|
||||||
# Remove Debian package
|
# 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
|
#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
|
#sudo apt-get remove --purge -y redis-server redis-tools
|
||||||
# Delete postgresql package
|
|
||||||
#sudo apt-get remove --purge -y postgresql postgresql-contrib
|
#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
|
#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
|
# Delete app directory and configurations
|
||||||
|
@ -89,10 +86,10 @@ REMOVE_NGINX_CONF
|
||||||
ynh_secure_remove /etc/cron.d/$app
|
ynh_secure_remove /etc/cron.d/$app
|
||||||
# Delete source.list
|
# Delete source.list
|
||||||
ynh_secure_remove /etc/apt/sources.list.d/backports.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
|
# Delete ruby exec
|
||||||
ynh_secure_remove /usr/bin/ruby
|
#ynh_secure_remove /usr/bin/ruby
|
||||||
|
|
||||||
# Remove user
|
# Remove user
|
||||||
sudo userdel -f $app
|
sudo userdel -f $app
|
||||||
|
|
|
@ -67,35 +67,46 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home
|
||||||
|
|
||||||
# Reinstall dependencies
|
# Reinstall dependencies
|
||||||
# Install debian package
|
# 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
|
# Install redis package
|
||||||
ynh_package_install redis-server redis-tools
|
ynh_package_install redis-server redis-tools
|
||||||
|
|
||||||
# Install postgresql
|
# Install postgresql
|
||||||
ynh_package_install postgresql postgresql-contrib
|
ynh_package_install postgresql postgresql-contrib postgresql-server-dev-all
|
||||||
|
|
||||||
# Install Ruby
|
# Install Ruby
|
||||||
ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
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
|
# Import debian archive pubkey, need on ARM arch
|
||||||
sudo cp ./apt_backports.list /etc/apt/sources.list.d/backports.list
|
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 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
|
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
|
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
|
# Install de Node.js
|
||||||
pushd /opt
|
pushd /opt
|
||||||
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
|
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
|
||||||
sudo apt-get -y install nodejs
|
sudo apt-get -y install nodejs
|
||||||
|
|
||||||
# Install Yarn
|
|
||||||
ynh_package_install yarn
|
|
||||||
|
|
||||||
# Return to home
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
|
@ -107,6 +118,9 @@ sudo chown -R $app: "$final_path"
|
||||||
# Debug
|
# Debug
|
||||||
sudo ls -alh "$final_path"
|
sudo ls -alh "$final_path"
|
||||||
|
|
||||||
|
# Restart postgresql
|
||||||
|
sudo systemctl restart 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';"
|
||||||
|
@ -149,18 +163,21 @@ RECOMMANDS
|
||||||
# Remove dump
|
# Remove dump
|
||||||
ynh_secure_remove $final_path/mastodon_db.sql
|
ynh_secure_remove $final_path/mastodon_db.sql
|
||||||
|
|
||||||
# Create symlink for ruby
|
# Create symlink for ruby 2.5.1
|
||||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
|
sudo rm /usr/bin/ruby || true
|
||||||
|
sudo ln -s /opt/mastodon/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
|
||||||
|
|
||||||
# Upgrade Mastodon
|
# Install Mastodon
|
||||||
sudo su - $app <<RCOMMANDS
|
sudo su - $app <<MCOMMANDS
|
||||||
cd ~/live
|
pushd ~/live
|
||||||
bin/bundle install
|
$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
|
||||||
|
|
||||||
|
pushd $final_path/live
|
||||||
yarn install --pure-lockfile
|
yarn install --pure-lockfile
|
||||||
#RAILS_ENV=production bin/bundle exec rails db:migrate
|
systemctl restart postgresql
|
||||||
#RAILS_ENV=production bundle exec rails assets:clean
|
popd
|
||||||
#RAILS_ENV=production bin/bundle exec rails assets:precompile
|
|
||||||
RCOMMANDS
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sudo sed -i "s@__PATH__@$app@g" ./nginx.conf
|
sudo sed -i "s@__PATH__@$app@g" ./nginx.conf
|
||||||
|
|
|
@ -65,7 +65,7 @@ if [[ $node_version =~ ^v4.*$ ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add additional package for upgrade
|
# 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
|
# Install ruby 2.5.1 for release 2.4.0
|
||||||
sudo su - $app <<RCOMMANDS
|
sudo su - $app <<RCOMMANDS
|
||||||
|
@ -84,10 +84,8 @@ sudo su - $app <<MCOMMANDS
|
||||||
pushd ~/live
|
pushd ~/live
|
||||||
$final_path/.rbenv/versions/2.5.1/bin/gem install bundler
|
$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
|
$final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
|
||||||
#yarn install --pure-lockfile
|
|
||||||
MCOMMANDS
|
MCOMMANDS
|
||||||
|
|
||||||
# Install package with yarn and restart postgresql
|
|
||||||
pushd $final_path/live
|
pushd $final_path/live
|
||||||
yarn install --pure-lockfile
|
yarn install --pure-lockfile
|
||||||
systemctl restart postgresql
|
systemctl restart postgresql
|
||||||
|
|
Loading…
Add table
Reference in a new issue