Class: SmartMachine::Grids::Phpmyadmin
- Defined in:
- lib/smart_machine/grids/phpmyadmin.rb
Instance Method Summary collapse
- #downer ⇒ Object
-
#initialize(name:) ⇒ Phpmyadmin
constructor
A new instance of Phpmyadmin.
- #uper ⇒ Object
Methods inherited from Base
#machine_has_engine_installed?, #platform_on_machine?, #user_bash
Methods included from Logger
configure_logger_for, included, #logger, logger_for
Constructor Details
#initialize(name:) ⇒ Phpmyadmin
Returns a new instance of Phpmyadmin.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/smart_machine/grids/phpmyadmin.rb', line 4 def initialize(name:) config = SmartMachine.config.grids.phpmyadmin.dig(name.to_sym) raise "phpmyadmin config for #{name} not found." unless config @image = config.dig(:image) @command = config.dig(:command) @host = config.dig(:host) @networks = Array(config.dig(:networks)) @pma_controlhost = config.dig(:pma_controlhost) mysql_config = SmartMachine.config.grids.mysql.dig(@pma_controlhost&.to_sym) raise "phpmyadmin | mysql config for #{@pma_controlhost} not found." unless mysql_config @mysql_config_root_password = mysql_config.dig(:root_password) @pma_controlport = mysql_config.dig(:port) @pma_controluser = mysql_config.dig(:username) @pma_controlpass = mysql_config.dig(:password) @pma_pmadb = "phpmyadmin" @name = name.to_s @home_dir = File.('~') end |
Instance Method Details
#downer ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/smart_machine/grids/phpmyadmin.rb', line 39 def downer @networks.each do |network| raise "Error: Could not disconnect container: #{network} - #{@name}" unless system("docker network disconnect #{network} #{@name}", out: File::NULL) end raise "Error: Could not stop container: #{@name}" unless system("docker stop '#{@name}'", out: File::NULL) raise "Error: Could not remove container: #{@name}" unless system("docker rm '#{@name}'", out: File::NULL) puts "Disconnected, Stopped & Removed container: #{@name}" end |
#uper ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/smart_machine/grids/phpmyadmin.rb', line 26 def uper raise "Error: Could not create container: #{@name}" unless system(command.compact.join(' '), out: File::NULL) raise "Error: Could not start container: #{@name}" unless system("docker start #{@name}", out: File::NULL) @networks.each do |network| raise "Error: Could not connect container: #{network} - #{@name}" unless system("docker network connect #{network} #{@name}", out: File::NULL) end raise "Error: Could not setup database: #{@name}" unless system(command_db_setup.compact.join(' '), out: File::NULL) raise "Error: Could not setup tables: #{@name}" unless system(command_db_tables_setup.compact.join(' '), out: File::NULL) puts "Created, Started & Connected container: #{@name}" end |