مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +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
هذا الالتزام موجود في:
@@ -16,11 +16,11 @@ fi
|
|||||||
if [ $SHOULD_SUDO == "yes" ] && [ $USER != "postal" ]; then
|
if [ $SHOULD_SUDO == "yes" ] && [ $USER != "postal" ]; then
|
||||||
run() {
|
run() {
|
||||||
HOME=/opt/postal
|
HOME=/opt/postal
|
||||||
eval "sudo -u postal $1"
|
eval "sudo -u postal $@"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
run() {
|
run() {
|
||||||
eval $1
|
eval $@
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
auto-upgrade)
|
auto-upgrade)
|
||||||
run "ruby script/auto_upgrade.rb $2"
|
run "ruby script/auto_upgrade.rb $@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
make-user)
|
make-user)
|
||||||
|
|||||||
@@ -1,19 +1,38 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# This script will attempt to upgrade a Postal installation automatically.
|
# 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
|
# It can be run as any user that has access to /opt/postal and that can run
|
||||||
# commands as postal.
|
# 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'"
|
puts "Channel must be either 'stable' or 'beta'"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts "Upgrading from the \e[32m#{channel}\e[0m channel"
|
||||||
|
|
||||||
def run(command, options = {})
|
def run(command, options = {})
|
||||||
if system(command)
|
if system(command)
|
||||||
# Good.
|
# Good.
|
||||||
@@ -23,8 +42,10 @@ def run(command, options = {})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Stopping current Postal instance"
|
if safe_mode
|
||||||
run "postal stop", :exit_on_failure => false
|
puts "Stopping current Postal instance"
|
||||||
|
run "postal stop", :exit_on_failure => false
|
||||||
|
end
|
||||||
|
|
||||||
if File.exist?("/opt/postal/app/.git")
|
if File.exist?("/opt/postal/app/.git")
|
||||||
puts "Getting latest version of repository"
|
puts "Getting latest version of repository"
|
||||||
@@ -34,7 +55,7 @@ else
|
|||||||
run "rm -Rf /opt/postal/app.backup"
|
run "rm -Rf /opt/postal/app.backup"
|
||||||
run "cp -R /opt/postal/app /opt/postal/app.backup"
|
run "cp -R /opt/postal/app /opt/postal/app.backup"
|
||||||
puts "Downloading latest version of application"
|
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
|
end
|
||||||
|
|
||||||
puts "Installing dependencies"
|
puts "Installing dependencies"
|
||||||
@@ -43,7 +64,12 @@ run "postal bundle /opt/postal/vendor/bundle"
|
|||||||
puts "Upgrading database & assets"
|
puts "Upgrading database & assets"
|
||||||
run "postal upgrade"
|
run "postal upgrade"
|
||||||
|
|
||||||
puts "Starting Postal"
|
if safe_mode
|
||||||
run "postal start"
|
puts "Starting Postal"
|
||||||
|
run "postal start"
|
||||||
|
else
|
||||||
|
puts "Restarting Postal"
|
||||||
|
run "postal restart"
|
||||||
|
end
|
||||||
|
|
||||||
puts "\e[32mUpgrade complete\e[0m"
|
puts "\e[32mUpgrade complete\e[0m"
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم