HEX
HEX
Server: Apache/2.4.29 (Ubuntu)
System: Linux 2amigos-php74 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
User: squarehillcompany.com (1002)
PHP: 7.4.25
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhosts/yiiwheels.2amigos.us/cgi-bin/deploy.rb
#!/usr/bin/ruby

require 'cgi'

class Servlet
  CHECKOUT   = 'git clone'
  UPDATE     = 'git pull'
  URL        = 'git@github.com:2amigos/yiiwheels-docs.git'
  LOG        = "/var/www/html/yiiwheels.2amigos.us/logs/deploy.log"
  DEPLOG     = "/var/www/html/yiiwheels.2amigos.us/logs/deplog.log"
  DEPLOY_DIR = "/var/www/html/yiiwheels.2amigos.us/docroot"
  
  #--------------------------------------------------
  # Process CGI request
  def cgi_process_request
    @cgi = CGI.new('html4')
    code = 'OK'
    comment = ''

    # Assembla may test if we are alive
    if @cgi['project'].empty?
      code = 'OK'
      comment = 'Deploy agent is alive'

    # Deploy the application
    else

      tmp = `echo -n ---Start: >> #{LOG}`
      tmp = `date >> #{LOG}`

      if ! File.directory?(DEPLOY_DIR)
        Dir.chdir File.dirname(DEPLOY_DIR)
        buildlog = `#{CHECKOUT} #{URL} 2>&1`
      else
        Dir.chdir DEPLOY_DIR
        buildlog = `#{UPDATE} > #{DEPLOG}`
      end

        comment = "Deploy from URL #{URL} performed successfuly"

      if $? != 0
        code = 'NOT_FOUND'
        comment = "Unable to deploy from URL #{URL}"
      end
      tmp = `echo Request created from IP: #{CGI.new.remote_addr} >> #{LOG}`
      tmp = `echo Deploy requested from IP: #{CGI.new.remote_addr} >> #{DEPLOG}`
      tmp = `echo #{comment} >> #{LOG}`
      tmp = `echo -n ---End: >> #{LOG}`
      tmp = `date >> #{LOG}`
    end

    @cgi.out("status"     => code,
             "type"       => "text/html") {comment}
  end

end

Servlet.new.cgi_process_request