1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-12-01 05:43:04 +00:00

improvements to the auto upgrade script

* change how the channel is passed
* restart rather than stop/start when upgrading
* add safe mode for forcing a stop/start on upgrade
هذا الالتزام موجود في:
Adam Cooke
2017-06-01 14:07:25 +01:00
الأصل 42ba1bb9f2
التزام e443a3addb
2 ملفات معدلة مع 38 إضافات و12 حذوفات

عرض الملف

@@ -1,19 +1,38 @@
#!/usr/bin/env ruby
# This script will attempt to upgrade a Postal installation automatically.
# It is always recommended to upgrade Postal manaually and this script should only
# be used for development or for pro-users.
#
# It can be run as any user that has access to /opt/postal and that can run
# commands as postal.
CHANNEL = ARGV[0] || "stable"
channel = 'stable'
safe_mode = false
unless ['beta', 'stable'].include?(CHANNEL)
begin
require 'optparse'
OptionParser.new do |opts|
opts.banner = "Usage: postal auto-upgrade [options]"
opts.on("-c", "--channel CHANNEL", "The channel to pull the latest version from") do |v|
channel = v
end
opts.on("--safe", "Stop postal before running the upgrade") do |v|
safe_mode = true
end
end.parse!
rescue OptionParser::InvalidOption => e
puts e.message
exit 1
end
unless ['beta', 'stable'].include?(channel)
puts "Channel must be either 'stable' or 'beta'"
exit 1
end
puts "Upgrading from the \e[32m#{channel}\e[0m channel"
def run(command, options = {})
if system(command)
# Good.
@@ -23,8 +42,10 @@ def run(command, options = {})
end
end
puts "Stopping current Postal instance"
run "postal stop", :exit_on_failure => false
if safe_mode
puts "Stopping current Postal instance"
run "postal stop", :exit_on_failure => false
end
if File.exist?("/opt/postal/app/.git")
puts "Getting latest version of repository"
@@ -34,7 +55,7 @@ else
run "rm -Rf /opt/postal/app.backup"
run "cp -R /opt/postal/app /opt/postal/app.backup"
puts "Downloading latest version of application"
run "wget https://postal.atech.media/packages/#{CHANNEL}/latest.tgz -O - | tar zxpv -C /opt/postal/app"
run "wget https://postal.atech.media/packages/#{channel}/latest.tgz -O - | tar zxpv -C /opt/postal/app"
end
puts "Installing dependencies"
@@ -43,7 +64,12 @@ run "postal bundle /opt/postal/vendor/bundle"
puts "Upgrading database & assets"
run "postal upgrade"
puts "Starting Postal"
run "postal start"
if safe_mode
puts "Starting Postal"
run "postal start"
else
puts "Restarting Postal"
run "postal restart"
end
puts "\e[32mUpgrade complete\e[0m"