-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor of gem structure; Dramatically more object-oriented now
- Loading branch information
Showing
25 changed files
with
252 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Update our load path to make loading internal files easier | ||
libdir = File.expand_path('../lib/', File.dirname( __FILE__ ) ) | ||
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) | ||
|
||
require 'server/colorizer' # Bring in our string colors | ||
require 'server/log' # Initialize our logs | ||
|
||
$Log.debug("libdir > #{libdir}") | ||
|
||
$Log.debug("ARGV: #{ARGV}") | ||
|
||
Signal.trap("INT") { exit 1 } | ||
|
||
require 'server' | ||
|
||
# Server.start(ARGV) | ||
Server.init | ||
|
||
$Log.debug( "Server runtime path: #{Server.runtime_path}" ) | ||
|
||
$Log.debug( 'Requiring CLI' ) | ||
require 'server/cli' | ||
|
||
$Log.debug( "Running server" ) | ||
|
||
Server::CLI.start(ARGV) | ||
# Server::CLI.explain |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,20 @@ | ||
#!/usr/bin/env ruby | ||
module Server | ||
|
||
require 'thor' | ||
require 'highline/import' | ||
require_relative 'classes/installed' | ||
require_relative 'classes/conf' | ||
require_relative 'classes/sys' | ||
require_relative 'workflows/web' | ||
require_relative 'workflows/db' | ||
class << self | ||
|
||
class Server < Thor | ||
include Workflows | ||
attr_accessor :settings | ||
attr_reader :runtime_path | ||
|
||
desc "build", "Build a general server type" | ||
def build | ||
choose do |menu| | ||
|
||
menu.prompt = "What type of server is this going to be?" | ||
|
||
menu.choice(:web) { Workflows::Web.start! } | ||
menu.choice(:db) { Workflows::Db.start! } | ||
autoload :CLI, 'server/cli' | ||
autoload :Conf, 'server/conf' | ||
autoload :Installed, 'server/installed' | ||
autoload :Sys, 'server/sys' | ||
|
||
def init | ||
@settings = { :setting_one => "foo", :setting_two => "bar" } | ||
@runtime_path = File.expand_path('..', File.dirname( __FILE__ ) ) | ||
end | ||
end | ||
|
||
desc "install", "Installs and configures packages" | ||
def install | ||
puts "Installing" | ||
end | ||
|
||
desc "configure", "Change the configuration of an existing package" | ||
def configure | ||
puts "Configuring" | ||
end | ||
|
||
desc "server", "Change general server/machine settings" | ||
def server | ||
puts "Server settings" | ||
end | ||
|
||
desc "ssh", "Manage authorized SSH keys" | ||
def ssh | ||
puts "SSH keys" | ||
end | ||
|
||
desc "stats", "View statistics for this machine" | ||
def stats | ||
puts "Machine stats" | ||
end | ||
|
||
desc "info", "Displays information about this machine" | ||
def info | ||
puts "Nginx path: #{Conf::nginx_path}" | ||
puts "PHP-FPM path: #{Conf::phpfpm_path}" | ||
puts "Yum package manager available" if Installed::yum? | ||
puts "Brew package manager available" if Installed::brew? | ||
puts "PHP-FPM installed" if Installed::phpfpm? | ||
puts "Nginx installed" if Installed::nginx? | ||
end | ||
|
||
end | ||
|
||
Server.start(ARGV) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'thor' | ||
require 'highline/import' | ||
# require 'server/installed' | ||
# require 'server/conf' | ||
# require 'server/sys' | ||
# require 'server/workflows/web' | ||
# require 'server/workflows/db' | ||
require 'server' | ||
|
||
module Server | ||
|
||
class CLI < Thor | ||
|
||
class_option :info, :type => :boolean, :aliases => "-v", :desc => "Enable info logging" | ||
class_option :verbose, :type => :boolean, :aliases => "-vv", :desc => "Enable verbose logging" | ||
class_option :quiet, :type => :boolean, :aliases => "-q", :desc => "Silence all non-error logging" | ||
|
||
no_commands do | ||
def self.explain | ||
$Log.info( "Server runtime path: #{Server.runtime_path}" ) | ||
$Log.info( "Server settings: #{Server.settings}" ) | ||
end | ||
end | ||
|
||
desc "build", "Build a general server type" | ||
def build | ||
choose do |menu| | ||
|
||
menu.prompt = "What type of server is this going to be?" | ||
|
||
menu.choice(:web) { Workflows::Web.start! } | ||
menu.choice(:db) { Workflows::Db.start! } | ||
|
||
end | ||
end | ||
|
||
desc "install", "Installs and configures packages" | ||
def install | ||
$Log.info( "Installing" ) | ||
end | ||
|
||
desc "configure", "Change the configuration of an existing package" | ||
def configure | ||
$Log.info( "Configuring" ) | ||
end | ||
|
||
desc "server", "Change general server/machine settings" | ||
def server | ||
$Log.info( "Server settings" ) | ||
end | ||
|
||
desc "ssh", "Manage authorized SSH keys" | ||
def ssh | ||
$Log.info( "SSH keys" ) | ||
end | ||
|
||
desc "stats", "View statistics for this machine" | ||
def stats | ||
$Log.info( "Machine stats" ) | ||
end | ||
|
||
desc "info", "Displays information about this machine" | ||
def info | ||
$Log.info( "Nginx path: #{Conf::nginx_path}" ) | ||
$Log.info( "PHP-FPM path: #{Conf::phpfpm_path}" ) | ||
$Log.info( "Yum package manager available" ) if Installed::yum? | ||
$Log.info( "Brew package manager available" ) if Installed::brew? | ||
$Log.info( "PHP-FPM installed" ) if Installed::phpfpm? | ||
$Log.info( "Nginx installed" ) if Installed::nginx? | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class String | ||
|
||
def black; "\033[30m#{self}\033[0m" end | ||
def red; "\033[31m#{self}\033[0m" end | ||
def green; "\033[32m#{self}\033[0m" end | ||
def brown; "\033[33m#{self}\033[0m" end | ||
def blue; "\033[34m#{self}\033[0m" end | ||
def magenta; "\033[35m#{self}\033[0m" end | ||
def cyan; "\033[36m#{self}\033[0m" end | ||
def gray; "\033[37m#{self}\033[0m" end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Server | ||
|
||
class Conf | ||
|
||
def self.nginx_path | ||
`which nginx` | ||
end | ||
|
||
def self.phpfpm_path | ||
`which php-fpm` | ||
end | ||
|
||
def self.explain | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Server | ||
|
||
class Installed | ||
|
||
def self.yum? | ||
`which yum` != "" | ||
end | ||
|
||
def self.brew? | ||
`which brew` != "" | ||
end | ||
|
||
def self.nginx? | ||
`which nginx` != "" | ||
end | ||
|
||
def self.phpfpm? | ||
`which php-fpm` != "" | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'logger' | ||
|
||
$Log = Logger.new(STDOUT) | ||
$Log.datetime_format = '%Y-%m-%d %H:%M:%S' | ||
$Log.formatter = proc do |severity, datetime, progname, msg| | ||
# "#{datetime.strftime("%m/%d %H:%M")}: #{msg} [#{severity}] \n" | ||
case severity.downcase | ||
when "debug" | ||
prompt = "☰ ".blue | ||
when "info" | ||
prompt = "i ".green | ||
when "warn" | ||
prompt = "⚑ ".magenta | ||
when "error" | ||
prompt = "✖ ".red | ||
when "fatal" | ||
prompt = ":( ".red | ||
else | ||
prompt = "✓ ".blue | ||
end | ||
|
||
"#{prompt} #{msg.strip} \n" | ||
end | ||
|
||
# $Log.debug("This is a debug message") | ||
# $Log.info("This is an info message") | ||
# $Log.warn("This is a warning message") | ||
# $Log.error("This is an error message") | ||
# $Log.fatal("This is a fatal message") | ||
# $Log.error("Some error here") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Server | ||
|
||
class Sys | ||
|
||
def self.yum_available? | ||
`which yum` != "" | ||
end | ||
|
||
def self.brew_available? | ||
`which brew` != "" | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'highline/import' | ||
|
||
module Server | ||
|
||
module Workflows | ||
|
||
class Db | ||
|
||
def self.start! | ||
puts "Starting DB workflow" | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.