Skip to content

Commit

Permalink
add a quick script to handle auto upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Apr 26, 2017
1 parent 0f10481 commit f7e83df
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/postal
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ case "$1" in
run "bundle exec ruby script/register_lets_encrypt.rb $2"
;;

auto-upgrade)
run "ruby script/auto_upgrade.rb"
;;

bundle)
if [ -n "$2" ]; then
run "bundle install --path=$2 --without=development --jobs=4 --clean"
Expand Down
34 changes: 34 additions & 0 deletions script/auto_upgrade.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/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.

def run(command, options = {})
if system(command)
# Good.
else
puts "Failed to run: #{command}"
exit 128 unless options[:exit_on_failure] == false
end
end

puts "Stopping current MyOps instance"
run "postal stop", :exit_on_failure => false

puts "Getting latest version of repository"
run "cd /opt/postal/app && git pull"

puts "Installing dependencies"
run "postal bundle /opt/postal/app/vendor/bundle"

puts "Upgrading database & assets"
run "postal upgrade"

puts "Starting Postal"
run "postal start"

puts "\e[32mUpgrade complete\e[0m"

0 comments on commit f7e83df

Please sign in to comment.