Class: SmartCloud::Grids::Nextcloud

Inherits:
Base
  • Object
show all
Defined in:
lib/smart_cloud/grids/nextcloud.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

configure_logger_for, included, #logger, logger_for

Constructor Details

#initializeNextcloud

Returns a new instance of Nextcloud.



5
6
# File 'lib/smart_cloud/grids/nextcloud.rb', line 5

def initialize
end

Class Method Details

.downObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/smart_cloud/grids/nextcloud.rb', line 44

def self.down
	if SmartCloud::Docker.running?
		# Stopping & Removing containers - in reverse order
		print "-----> Stopping container nextcloud ... "
		if system("docker stop 'nextcloud'", out: File::NULL)
			puts "done"
			print "-----> Removing container nextcloud ... "
			if system("docker rm 'nextcloud'", out: File::NULL)
				puts "done"
			end
		end
	end
end

.upObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/smart_cloud/grids/nextcloud.rb', line 8

def self.up
	if SmartCloud::Docker.running?
		# Creating & Starting containers
		print "-----> Creating container nextcloud ... "
		if system("docker create \
			--name='nextcloud' \
			--env VIRTUAL_HOST=#{SmartCloud.credentials.nextcloud[:name]}.#{SmartCloud.config.apps_domain} \
			--env LETSENCRYPT_HOST=#{SmartCloud.credentials.nextcloud[:name]}.#{SmartCloud.config.apps_domain} \
			--env LETSENCRYPT_EMAIL=#{SmartCloud.config.sysadmin_email} \
			--env LETSENCRYPT_TEST=false \
			--env NEXTCLOUD_TRUSTED_DOMAINS=#{SmartCloud.credentials.nextcloud[:name]}.#{SmartCloud.config.apps_domain} \
			--env NC_overwriteprotocol=https \
			--env NEXTCLOUD_ADMIN_USER=#{SmartCloud.credentials.nextcloud[:admin_username]} \
			--env NEXTCLOUD_ADMIN_PASSWORD=#{SmartCloud.credentials.nextcloud[:admin_password]} \
			--env MYSQL_HOST=#{SmartCloud.credentials.nextcloud[:database_host]}:#{SmartCloud.credentials.nextcloud[:database_port]} \
			--env MYSQL_USER=#{SmartCloud.credentials.nextcloud[:database_username]} \
			--env MYSQL_PASSWORD=#{SmartCloud.credentials.nextcloud[:database_password]} \
			--env MYSQL_DATABASE=#{SmartCloud.credentials.nextcloud[:database_name]} \
			--user `id -u`:`id -g` \
			--sysctl net.ipv4.ip_unprivileged_port_start=0 \
			--volume='#{SmartCloud.config.user_home_path}/.smartcloud/grids/nextcloud/html:/var/www/html' \
			--restart='always' \
			--network='nginx-network' \
			nextcloud:18.0.2-apache", out: File::NULL)

			system("docker network connect mysql-network nextcloud")

			puts "done"
			print "-----> Starting container nextcloud ... "
			if system("docker start nextcloud", out: File::NULL)
				puts "done"
			end
		end
	end
end