Class: Utopia::Command::Server::Update

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/utopia/command/server.rb

Overview

Update a server.

Instance Method Summary collapse

Instance Method Details

#callObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/utopia/command/server.rb', line 60

def call
	destination_root = parent.root
	
	Dir.chdir(destination_root) do
		# It's okay to call this on an existing repo, it will only update config as required to enable --shared.
		# --shared allows multiple users to access the site with the same group.
		system("git", "init", "--shared") or fail "could not initialize repository"
		
		system("git", "config", "receive.denyCurrentBranch", "ignore") or fail "could not set configuration"
		system("git", "config", "core.worktree", destination_root) or fail "could not set configuration"
		
		# Doing this invokes a lot of behaviour that isn't always ideal...
		# system("bundle", "config", "set", "--local", "deployment", "true")
		system("bundle", "config", "set", "--local", "without", "development")
		
		# In theory, to convert from non-shared to shared:
		# chgrp -R <group-name> .                   # Change files and directories' group
		# chmod -R g+w .                            # Change permissions
		# chmod g-w .git/objects/pack/*             # Git pack files should be immutable
		# chmod g+s `find . -type d`                # New files get group id of directory
	end
	
	# Set some useful defaults for the environment.
	environment = Environment[]
	environment.update_environment(destination_root) do |store|
		store['VARIANT'] ||= 'production'
		store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
	end
	
	# Copy git hooks:
	system("cp", "-r", File.join(template_root, 'git', 'hooks'), File.join(destination_root, '.git')) or fail "could not copy git hooks"
	# finally set everything in the .git directory to be group writable
	# This failed for me and I had to do sudo chown http:http .git -R first.
	system("chmod", "-Rf", "g+w", File.join(destination_root, '.git')) or fail "could not update permissions of .git directory"
end

#template_rootObject



55
56
57
58
# File 'lib/utopia/command/server.rb', line 55

def template_root
	# The root directory of the template server deployment:
	File.join(SETUP_ROOT, 'server')
end