Sha256: 01002b8758722b73f4200eb03d51d1ac3d380d2f3db6c40f2ecb615249b13e2e

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module SmartMachine
  class Grids
    class Terminal < SmartMachine::Base
      class Wetty
        def initialize(name:, host:, ssh_host:)
          @name = name
          @host = host
          @ssh_host = ssh_host
        end

        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)

          puts "Created & Started container: #{@name}"
        end

        def downer
          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 "Stopped & Removed container: #{@name}"
        end

        private

        def command
          [
            'docker create',
            "--name='#{@name}'",
            "--env VIRTUAL_HOST=#{@host}",
            "--env VIRTUAL_PATH=/",
            "--env LETSENCRYPT_HOST=#{@host}",
            "--env LETSENCRYPT_EMAIL=#{SmartMachine.config.sysadmin_email}",
            '--env LETSENCRYPT_TEST=false',
            "--restart='always'",
            "--network='nginx-network'",
            "wettyoss/wetty --base=/ --ssh-host=#{@ssh_host} --ssh-port=2223 --force-ssh=true --title=Terminal"
          ]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smartmachine-1.3.0 lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.2.3 lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.2.1 lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.2.0 lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.2.0.dev lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.1.1 lib/smart_machine/grids/terminal/wetty.rb
smartmachine-1.1.0 lib/smart_machine/grids/terminal/wetty.rb