diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/install | 8 | ||||
| -rw-r--r-- | scripts/restore | 52 | ||||
| -rw-r--r-- | scripts/upgrade | 23 |
3 files changed, 59 insertions, 24 deletions
diff --git a/scripts/install b/scripts/install index 0c71505..1634c52 100644 --- a/scripts/install +++ b/scripts/install @@ -41,7 +41,7 @@ ynh_app_setting_set $app language $language sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login # Install debian package -ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https +ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler # Install redis package ynh_package_install redis-server redis-tools @@ -66,7 +66,7 @@ ynh_app_setting_set $app final_path $final_path # Install de Node.js pushd /opt -curl -sL https://deb.nodesource.com/setup_4.x | sudo bash - +curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - sudo apt-get -y install nodejs # Install Yarn @@ -95,9 +95,11 @@ CLONECOMMANDS # Switch branch to tagged release cd $final_path/live +url=$(curl -s https://api.github.com/repos/tootsuite/mastodon/releases/latest | sort -r | head -1 | cut -d\" -f4) +version=$(echo $url | cut -d/ -f8) sudo su - $app <<SWITCHCOMMANDS pushd ~/live -git checkout $(git tag | tail -n 1) +git checkout $version SWITCHCOMMANDS # Be king rewind (/var/cache/yunohost/from_file/scripts) diff --git a/scripts/restore b/scripts/restore index 3a2eeaf..5860e2c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,30 +35,30 @@ fi # Check configuration files nginx nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" 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." fi # Check configuration files php-fpm crontab_conf="/etc/cron.d/${app}" -if [ -f $crontab_conf ]; then - ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'. +if [ -f $crontab_conf ]; then + ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'. You should safely delete it before restoring this app." fi # Restore services web_systemd="/etc/systemd/system/${app}-web.service" 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." fi sidekiq_systemd="/etc/systemd/system/${app}-sidekiq.service" 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." fi streaming_systemd="/etc/systemd/system/${app}-streaming.service" 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." fi @@ -67,7 +67,7 @@ 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 + ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler # Install redis package ynh_package_install redis-server redis-tools @@ -89,7 +89,7 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home # Install de Node.js pushd /opt - curl -sL https://deb.nodesource.com/setup_4.x | sudo bash - + curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - sudo apt-get -y install nodejs # Install Yarn @@ -97,7 +97,7 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home # Return to home popd - + # Restore sources & data sudo cp -a ./sources/. "$final_path" @@ -117,21 +117,23 @@ sudo su -c "psql" postgres <<< \ sudo su -c "psql" postgres <<< \ "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 ynh_psql_create_db_without_password "$app" # Setup database -sudo su - $app <<SCOMMANDS -cd ~/live -RAILS_ENV=production bin/bundle exec rails db:setup -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 +#sudo su - $app <<SCOMMANDS +#cd ~/live +#RAILS_ENV=production bin/bundle exec rails db:setup +#SCOMMANDS # copy database dump 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 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 sudo cp -a ./nginx.conf "$nginx_conf" # Restore crontab diff --git a/scripts/upgrade b/scripts/upgrade index f070bbd..2a9b0fe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -40,6 +40,14 @@ sudo systemctl stop mastodon-*.service # Change owner of live folder sudo chown -R $app: $final_path/live +# upgrade Node.js v4 to v6 +node_version=$(nodejs --version) +if [[ $node_version =~ ^v4.*$ ]]; then + pushd /opt + curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - + sudo apt-get -y install nodejs +fi + # Download Mastodon sudo su - $app <<PULLCOMMANDS pushd ~/live @@ -50,11 +58,24 @@ PULLCOMMANDS # Switch branch to tagged release cd $final_path/live +url=$(curl -s https://api.github.com/repos/tootsuite/mastodon/releases/latest | sort -r | head -1 | cut -d\" -f4) +version=$(echo $url | cut -d/ -f8) sudo su - $app <<SWITCHCOMMANDS pushd ~/live -git checkout $(git tag | tail -n 1) +git checkout $version SWITCHCOMMANDS +# upgrade Node.js v4 to v6 +node_version=$(nodejs --version) +if [[ $node_version =~ ^v4.*$ ]]; then + pushd /opt + curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - + sudo apt-get -y install nodejs +fi + +# add additional package for release 1.4 +ynh_package_install pkg-config libprotobuf-dev protobuf-compiler + # Apply Mastodon upgrade sudo su - $app <<COMMANDS pushd ~/live |
