sys_admin_toolbox 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dee89d00035d2f4c9167548dded562dc400dbe65
4
+ data.tar.gz: 8f11fb42ad23038c6f34bd697923f43e1fd3817f
5
+ SHA512:
6
+ metadata.gz: 0d8ed151e065a44002a8e32d4aea5ee0a65ea9168c9df6c7ed983e60b0ea9f53d9cf3cc9df91094d466d0904f59e059eccbb4f9a822e1ca5aab3123f6aed568b
7
+ data.tar.gz: 64b1e97c6730217f9e38e12702b9e8fee51821ddbfc46ce555573b6ed6b133021705696e93211244a13d6623ea0148ac61baa7284a367b60b39ffbfc4b977f2f
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Toolbox.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 David Gersting
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Toolbox
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'Toolbox'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install Toolbox
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/Toolbox/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'SysAdminToolbox'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sys_admin_toolbox"
8
+ spec.version = SysAdminToolbox::VERSION
9
+ spec.authors = ["David Gersting"]
10
+ spec.email = ["dgersting@gmail.com"]
11
+ spec.summary = %q{Command line toolbox for common system administration tasks}
12
+ spec.description = %q{WIP}
13
+ spec.homepage = "https://github.com/dgersting/SysAdminToolbox"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_runtime_dependency 'highline', '~> 1.6'
24
+ spec.add_runtime_dependency 'open4', '~> 1.3'
25
+ end
data/bin/saToolbox ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'SysAdminToolbox'
4
+ SysAdminToolbox::App.run
@@ -0,0 +1,9 @@
1
+ module SysAdminToolbox
2
+ module Httpd
3
+ class Apache
4
+ def self.run
5
+ puts "Hello from #{__method__}!"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module SysAdminToolbox
2
+ module Httpd
3
+ def self.run
4
+ puts "Hello from #{__method__}!"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module SysAdminToolbox
2
+ module Httpd
3
+ class Nginx
4
+ def self.run
5
+ puts "Hello from #{__method__}!"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'open4'
2
+
3
+ module SysAdminToolbox
4
+ module IO
5
+ module System
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'highline/import'
2
+
3
+ module SysAdminToolbox
4
+ module IO
5
+ module User
6
+ def password(msg)
7
+ ask(msg) { |q| q.echo = false }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module SysAdminToolbox
2
+ module System
3
+ def self.setup
4
+ require "SysAdminToolbox/system/setup"
5
+ SysAdminToolbox::System::Setup.new.run
6
+ end
7
+
8
+ def self.update
9
+ require "SysAdminToolbox/system/Update"
10
+ SysAdminToolbox::System::Update.new.run
11
+ end
12
+
13
+ def self.run
14
+ SysAdminToolbox::App.clear_console
15
+ SysAdminToolbox::App.breadcrumbs ['Home','System']
16
+ choose do |menu|
17
+ menu.prompt = "What would you like to do? "
18
+ menu.choice(:Setup) { SysAdminToolbox::System.setup }
19
+ menu.choice(:Update) { SysAdminToolbox::System.update }
20
+ menu.choice(:Back) { SysAdminToolbox::App.run }
21
+ menu.choice(:Quit) { SysAdminToolbox::App.quit }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ require "SysAdminToolbox/io/user"
2
+ require "SysAdminToolbox/io/system"
3
+
4
+ module SysAdminToolbox
5
+ module System
6
+ class Setup
7
+ include SysAdminToolbox::IO::User
8
+ include SysAdminToolbox::IO::System
9
+
10
+ def run
11
+ SysAdminToolbox::App.clear_console
12
+
13
+ puts "Welcome to initial system setup!"
14
+ puts "This should only be performed on new (virgin) systems"
15
+ puts
16
+ SysAdminToolbox::App.quit if ask("Are you ready to start? (anything but 'yes' will cancel) ").downcase.strip != 'yes'
17
+
18
+
19
+ # Root user
20
+ puts "\nSecuring root account"
21
+ begin
22
+ root_password = password "Root Password: "
23
+ raise RetryableError, 'Root password must be 8-20 charecters long!' if !root_password.length.between?(8,20)
24
+
25
+ root_password2 = password "(again) "
26
+ raise RetryableError, 'Passwords do not match!' if root_password != root_password2
27
+
28
+
29
+ p = Open4::popen4("passwd --stdin root") do |pid, stdin, stdout, stderr|
30
+ stdin.puts root_password
31
+ stdin.close
32
+ end
33
+ raise SystemCallError, 'Failed to change root password!' if p.exitstatus
34
+
35
+ rescue RetryableError => e
36
+ puts "\n"+e.message
37
+ retry
38
+ rescue => e
39
+ puts "\n"+e.message
40
+ SysAdminToolbox::App.quit
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,8 @@
1
+ module SysAdminToolbox
2
+ module System
3
+ class Update
4
+ def run
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,44 @@
1
+ require "SysAdminToolbox/io/user"
2
+ require "SysAdminToolbox/system/init"
3
+ require "SysAdminToolbox/httpd/init"
4
+
5
+ module SysAdminToolbox
6
+ VERSION = "0.0.1"
7
+
8
+ # Define custom exception types
9
+ RetryableError = Class.new(StandardError)
10
+
11
+ class App
12
+ def self.run
13
+ # if Process.uid != 0
14
+ # puts "Must run as root!"
15
+ # quit
16
+ # end
17
+
18
+ clear_console
19
+ puts "Welcome to SysAdmin Toolbox (#{VERSION})"
20
+ breadcrumbs ['Home']
21
+ choose do |menu|
22
+ menu.prompt = "What would you like to do? "
23
+ menu.choice(:System) { SysAdminToolbox::System.run }
24
+ menu.choice(:HTTPD) { SysAdminToolbox::Httpd.run }
25
+ menu.choice(:PHP) { SysAdminToolbox::Php.run }
26
+ menu.choice(:Ruby) { SysAdminToolbox::Ruby.run }
27
+ menu.choice(:Quit) { SysAdminToolbox::App.quit }
28
+ end
29
+ end
30
+
31
+ def self.quit
32
+ exit
33
+ end
34
+
35
+ def self.breadcrumbs(nodes)
36
+ puts 'Location: '+nodes.join(' > ')
37
+ puts
38
+ end
39
+
40
+ def self.clear_console
41
+ system 'clear'
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys_admin_toolbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Gersting
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: open4
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ description: WIP
70
+ email:
71
+ - dgersting@gmail.com
72
+ executables:
73
+ - saToolbox
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - SysAdminToolbox.gemspec
83
+ - bin/saToolbox
84
+ - lib/SysAdminToolbox.rb
85
+ - lib/SysAdminToolbox/httpd/apache/init.rb
86
+ - lib/SysAdminToolbox/httpd/init.rb
87
+ - lib/SysAdminToolbox/httpd/nginx/init.rb
88
+ - lib/SysAdminToolbox/io/system.rb
89
+ - lib/SysAdminToolbox/io/user.rb
90
+ - lib/SysAdminToolbox/system/init.rb
91
+ - lib/SysAdminToolbox/system/setup.rb
92
+ - lib/SysAdminToolbox/system/update.rb
93
+ homepage: https://github.com/dgersting/SysAdminToolbox
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Command line toolbox for common system administration tasks
117
+ test_files: []