Sha256: 5f1f2f8970bdb516417307d74c4c74389fd389e04a59d35233768d18a9e3cb3c

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby
#/ Usage: rmails action [options]
#/
#/ Actions:
#/    --install
#/        Install all compoments of the system.
#/        You must be root to run this.
#/    --start-app
#/        Starts server of configuration app.
#/        You may have to be root to run this.
#/    --stop-app
#/        Stops server of configuration app.
#/        You may have to be root to run this.
#/ Options:
#/    --clear
#/        Truncate data in database.
#/

$stderr.sync = true

require 'optparse'
require File.expand_path('../../config/application', __FILE__)
require 'rmails/installer'
require 'rmails/runner'

# default options
install = false
start   = false
stop    = false
clear   = false


# parse arguments
file = __FILE__
ARGV.options do |opts|
  opts.on("--install")                 { |install| }
  opts.on("--start-app")               { |start|   }
  opts.on("--stop-app")                { |stop|    }
  opts.on("--clear")                   { |clear|    }
  opts.on_tail("-h", "--help")         { exec "grep ^#/<'#{file}'|cut -c4-" }
  opts.parse!
end


if (start and stop) or
   (install and (start or stop)) or
   (not install and not start and not stop)
  exec "grep ^#/<'#{file}'|cut -c4-"
end # bug that helps to have better condition

if install
  puts install
  setup = Rmails::Installer.new({:clear => clear})
  setup.run

elsif start
  app = Rmails::Runner.new
  app.start

elsif stop
  app = Rmails::Runner.new
  app.stop
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rmails-0.2.4 bin/rmails
rmails-0.2.3 bin/rmails