aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/backup6
-rw-r--r--scripts/install33
-rw-r--r--scripts/remove11
-rw-r--r--scripts/restore6
-rw-r--r--scripts/upgrade58
5 files changed, 77 insertions, 37 deletions
diff --git a/scripts/backup b/scripts/backup
index bc1822a..eeee720 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -74,6 +74,12 @@ ynh_backup "/etc/systemd/system/$app-sidekiq.service"
ynh_backup "/etc/systemd/system/$app-streaming.service"
#=================================================
+# BACKUP THE CRON FILE
+#=================================================
+
+ynh_backup "/etc/cron.d/$app"
+
+#=================================================
# BACKUP THE sources.list FILES
#=================================================
diff --git a/scripts/install b/scripts/install
index e82774b..1536cd5 100644
--- a/scripts/install
+++ b/scripts/install
@@ -96,7 +96,7 @@ ynh_install_app_dependencies \
`# redis ` \
redis-server redis-tools \
`# postgresql ` \
- postgresql \
+ postgresql postgresql-contrib \
`# Ruby ` \
autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \
`# ffmpeg from backports ` \
@@ -146,7 +146,7 @@ ynh_add_nginx_config
# Create a system user
adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
-chown -R "$app" "$final_path"
+chown -R "$app": "$final_path"
# TODO: try to use ynh_install_ruby from https://github.com/YunoHost-Apps/Experimental_helpers
# Install de rbenv
@@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile
# Install ruby-build
(
- exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.1
- exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1
- exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v
+ exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v
)
# Create symlink for ruby
rm /usr/bin/ruby || true
-ln -s $final_path/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
+ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true
# Yarn install on root
pushd $final_path/live
@@ -208,8 +208,8 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V
(
cd "$final_path/live"
su mastodon <<INSTALL
- $final_path/.rbenv/versions/2.5.1/bin/gem install bundler
- $final_path/live/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test --quiet
+ $final_path/.rbenv/versions/2.5.3/bin/gem install bundler
+ $final_path/live/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
yarn install --production --no-progress --non-interactive --silent
echo "SAFETY_ASSURED=1">> .env.production
RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet
@@ -222,6 +222,8 @@ INSTALL
#=================================================
# Create a dedicated systemd config
+ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service"
+ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service"
ynh_add_systemd_config "$app-web" "mastodon-web.service"
ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service"
ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service"
@@ -237,8 +239,8 @@ account = Account.create!(username: '$admin_mastodon')
user = User.create!(email: '$admin_mastodon_mail', password: '$admin_pass', account: account)
CREATEUSER
su mastodon <<SETADMIN
-RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=$admin_mastodon
-RAILS_ENV=production bin/bundle exec rails mastodon:confirm_email USER_EMAIL=$admin_mastodon_mail
+RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm
+RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin
SETADMIN
)
@@ -249,7 +251,7 @@ SETADMIN
#=================================================
# TODO:Set permissions to app files
-chown -R "$app" "$final_path"
+chown -R "$app": "$final_path"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@@ -260,6 +262,11 @@ yunohost service add "$app-web"
yunohost service add "$app-sidekiq"
yunohost service add "$app-streaming"
+# SETUP CRON JOB FOR REMOVING CACHE
+ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron
+ynh_replace_string "__USER__" "$app" ../conf/cron
+sudo cp -f ../conf/cron /etc/cron.d/$app
+
#=================================================
# SETUP SSOWAT
#=================================================
@@ -281,8 +288,8 @@ systemctl reload nginx
message="Mastodon was successfully installed :)
Please open 'https://$domain$path_url'
-The admin username is: '$admin_mastodon_mail'
-The admin password is: '$admin_pass'
+The admin username is: $admin_mastodon_mail
+The admin password is: $admin_pass
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh"
ynh_send_readme_to_admin "$message" "$admin_mastodon"
diff --git a/scripts/remove b/scripts/remove
index b92d3b9..6d6679b 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -85,15 +85,8 @@ ynh_remove_nginx_config
# SPECIFIC REMOVE
#=================================================
-
-#=================================================
-# REMOVE source.list
-#=================================================
-if [ "$(lsb_release --codename --short)" == "jessie" ]; then
- ynh_secure_remove /etc/apt/sources.list.d/backports.list
- ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list
-fi
-ynh_secure_remove /etc/apt/sources.list.d/yarn.list
+# Remove a cron file
+ynh_secure_remove "/etc/cron.d/$app"
# Delete ruby exec
#ynh_secure_remove /usr/bin/ruby
diff --git a/scripts/restore b/scripts/restore
index a25bb6f..822f8fc 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -147,6 +147,12 @@ yunohost service add $app-sidekiq
yunohost service add $app-streaming
#=================================================
+# RESTORE THE CRON FILE
+#=================================================
+
+ynh_restore_file "/etc/cron.d/$app"
+
+#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND services
diff --git a/scripts/upgrade b/scripts/upgrade
index 0429013..d337e6d 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -90,15 +90,25 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis
ynh_install_nodejs 8
-# add additional package for upgrade
-ynh_package_install pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all
+# TODO: use the same mecanism with other files
+ynh_install_app_dependencies \
+ `# debian packages ` \
+ imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \
+ `# redis ` \
+ redis-server redis-tools \
+ `# postgresql ` \
+ postgresql postgresql-contrib \
+ `# Ruby ` \
+ autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \
+ `# ffmpeg from backports ` \
+ ffmpeg \
+ `# Yarn ` \
+ yarn
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
-# Change owner of live folder
-chown -R $app: $final_path/live
# Stop Mastodon Services
# Restart Mastodon
@@ -107,7 +117,13 @@ yunohost service stop "$app-sidekiq"
yunohost service stop "$app-streaming"
# Download Mastodon
+mv "$final_path/live" "$final_path/live_back"
ynh_setup_source "$final_path/live" "app-mastodon"
+if [ -z $final_path/live_back/public/system ]; then
+ rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/."
+fi
+rsync -a "$final_path/live_back/.env.production" "$final_path/live/."
+rm -Rf "$final_path/live_back"
# Clean files which are not needed anymore
ynh_secure_remove $final_path/live/config/initializers/timeout.rb
@@ -115,7 +131,6 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb
#=================================================
# NGINX CONFIGURATION
#=================================================
-
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf"
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf"
ynh_add_nginx_config
@@ -125,27 +140,29 @@ ynh_add_nginx_config
ynh_setup_source "$final_path/.rbenv" "app-rbenv"
ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build"
+chown -R "$app": "$final_path"
+
# Install ruby 2.5.1
(
- exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.1 || true
- exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1 || true
- exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v
+ exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v
)
# Create symlink for ruby
rm /usr/bin/ruby || true
-ln -s $final_path/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
+ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true
# Preconfig CSS & JS
# 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.3/bin/gem install bundler
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
- $final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
+ $final_path/.rbenv/versions/2.5.3/bin/bundle install --deployment --without development test
else
- $final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --force --without development test
+ $final_path/.rbenv/versions/2.5.3/bin/bundle install --deployment --force --without development test
fi
yarn install --pure-lockfile
MCOMMANDS
@@ -160,15 +177,19 @@ popd
# Apply Mastodon upgrade
(
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
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails assets:clean
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails assets:precompile
popd
sudo su - $app <<COMMANDS
pushd ~/live
-RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails db:migrate
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails db:migrate
COMMANDS
)
+
+# permissions to app files
+chown -R "$app": "$final_path"
+
#=================================================
# SETUP SYSTEMD
#=================================================
@@ -185,6 +206,8 @@ ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service"
#=================================================
# Add service YunoHost
+ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service"
+ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service"
yunohost service add "$app-web"
yunohost service add "$app-sidekiq"
yunohost service add "$app-streaming"
@@ -196,6 +219,11 @@ yunohost service start "$app-streaming"
# Waiting start all services
sleep 30
+# SETUP CRON JOB FOR REMOVING CACHE
+ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron
+ynh_replace_string "__USER__" "$app" ../conf/cron
+sudo cp -f ../conf/cron /etc/cron.d/$app
+
#=================================================
# RELOAD NGINX
#=================================================