profig 0.06 → 0.07

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.
data/bin/profig CHANGED
@@ -24,12 +24,11 @@ def main()
24
24
  p opts
25
25
  p args
26
26
 
27
- os = :ubuntu
28
27
  dir = opts[:directory]
29
28
  dir = '/var/lib/profig/conf.d' if dir.nil?
30
29
 
31
30
  config = Profig.load_config(dir)
32
- Profig.run(os, config)
31
+ Profig.run(config)
33
32
  end
34
33
 
35
34
 
@@ -0,0 +1,32 @@
1
+
2
+ module Profig
3
+ # Handlers for various installers / package managers
4
+
5
+
6
+ def self.handle_cabal(pkg_name, opts)
7
+ cmd = "cabal install #{package_name}"
8
+ system cmd
9
+ end
10
+
11
+ def self.handle_deb(pkg_name, opts)
12
+ cmd = "apt-get install -y #{pkg_name}"
13
+ system cmd
14
+ end
15
+
16
+ def self.handle_egg(egg_name, opts)
17
+ cmd = "pip install #{egg_name}"
18
+ system cmd
19
+ end
20
+
21
+ def self.handle_gem(gem_name, opts)
22
+ cmd = "gem install #{gem_name}"
23
+ system cmd
24
+ end
25
+
26
+ def self.handle_yum(pkg_name, opts)
27
+ cmd = "yum install -y #{pkg_name}"
28
+ system cmd
29
+ end
30
+
31
+
32
+ end # module
@@ -4,7 +4,29 @@ require 'fileutils'
4
4
  module Profig
5
5
 
6
6
 
7
- def self.handle_linux_file(name, opts)
7
+ def self.handle_user(user_name, opts)
8
+ if not user_name.instance_of? String
9
+ raise 'Unknown user type'
10
+ elsif not /[a-zA-Z][a-zA-Z0-9_]+/.match user_name
11
+ raise 'Invalid user format'
12
+ end
13
+
14
+ cmd = "adduser -q --system --no-create-home"
15
+ cmd += " --disabled-password --disabled-login #{user_name}"
16
+ system cmd
17
+ end
18
+
19
+ def self.handle_group(group_name, opts)
20
+ if not group_name.instance_of? String
21
+ raise 'Unknown group definition'
22
+ end
23
+
24
+ cmd = "addgroup -q --system #{group_name}"
25
+ system(cmd)
26
+ end
27
+
28
+
29
+ def self.handle_file(name, opts)
8
30
  src = opts['source']
9
31
  owner, group = split_owner(opts['owner'])
10
32
  mode = opts['mode']
@@ -15,7 +37,7 @@ def self.handle_linux_file(name, opts)
15
37
  end
16
38
 
17
39
 
18
- def self.handle_linux_dir(name, opts)
40
+ def self.handle_dir(name, opts)
19
41
  owner, group = split_owner(opts['owner'])
20
42
  mode = opts['mode']
21
43
 
@@ -1,5 +1,5 @@
1
- require 'profig/ubuntu'
2
-
1
+ require 'profig/install'
2
+ require 'profig/linux'
3
3
 
4
4
  module Profig
5
5
 
@@ -12,7 +12,7 @@ def self.run_item_handler(handler, items)
12
12
  end
13
13
 
14
14
 
15
- def self.run(os, sections)
15
+ def self.run(sections)
16
16
  users_groups = `id -G`.split()
17
17
  if not users_groups.include? "0"
18
18
  # this should be made an exception at some point
@@ -22,9 +22,9 @@ def self.run(os, sections)
22
22
 
23
23
  sections.each do |section|
24
24
  type = section.type
25
- section_handler_name = "handle_#{type}_section_for_#{os}"
25
+ section_handler_name = "handle_#{type}_section"
26
26
  #item_handler_name = "handle_#{type}_for_#{os}"
27
- item_handler_name = "handle_#{os}_#{type}"
27
+ item_handler_name = "handle_#{type}"
28
28
 
29
29
  # first check if there's a section handler for this type
30
30
  # a section handler takes all items at once
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profig
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
9
- version: "0.06"
8
+ - 7
9
+ version: "0.07"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthew Graham
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-31 00:00:00 -05:00
17
+ date: 2011-07-30 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -29,14 +29,10 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - bin/profig
32
- - lib/profig/debian.rb
33
- - lib/profig/ubuntu.rb
34
- - lib/profig/config.rb
35
- - lib/profig/haskell.rb
36
- - lib/profig/ruby.rb
37
- - lib/profig/main.rb
38
- - lib/profig/python.rb
39
32
  - lib/profig/linux.rb
33
+ - lib/profig/main.rb
34
+ - lib/profig/config.rb
35
+ - lib/profig/install.rb
40
36
  has_rdoc: true
41
37
  homepage: http://github.com/mdg/profig
42
38
  licenses: []
@@ -1,9 +0,0 @@
1
-
2
- module Profig
3
-
4
- def self.handle_debian_deb(pkg_name, opts)
5
- cmd = "apt-get install -y #{pkg_name}"
6
- system cmd
7
- end
8
-
9
- end # module
@@ -1,11 +0,0 @@
1
-
2
- module Profig
3
-
4
-
5
- def self.handle_cabal(package_name, opts)
6
- cmd = "cabal install #{package_name}"
7
- system cmd
8
- end
9
-
10
-
11
- end # module
@@ -1,11 +0,0 @@
1
-
2
- module Profig
3
-
4
-
5
- def self.handle_egg(egg_name, opts)
6
- cmd = "pip install #{egg_name}"
7
- system cmd
8
- end
9
-
10
-
11
- end # module
@@ -1,11 +0,0 @@
1
-
2
- module Profig
3
-
4
-
5
- def self.handle_gem(gem_name, opts)
6
- cmd = "gem install #{gem_name}"
7
- system cmd
8
- end
9
-
10
-
11
- end # module
@@ -1,56 +0,0 @@
1
- require 'profig/linux'
2
- require 'profig/debian'
3
- require 'profig/haskell'
4
- require 'profig/python'
5
- require 'profig/ruby'
6
-
7
- module Profig
8
-
9
-
10
- def self.handle_ubuntu_group(group_name, opts)
11
- if not group_name.instance_of? String
12
- raise 'Unknown group definition'
13
- end
14
-
15
- cmd = "addgroup -q --system #{group_name}"
16
- system(cmd)
17
- end
18
-
19
- def self.handle_ubuntu_user(user_name, opts)
20
- if not user_name.instance_of? String
21
- raise 'Unknown user type'
22
- elsif not /[a-zA-Z][a-zA-Z0-9_]+/.match user_name
23
- raise 'Invalid user format'
24
- end
25
-
26
- cmd = "adduser -q --system --no-create-home"
27
- cmd += " --disabled-password --disabled-login #{user_name}"
28
- system cmd
29
- end
30
-
31
- def self.handle_ubuntu_cabal(pkg_name, opts)
32
- Profig.handle_cabal(pkg_name, opts)
33
- end
34
-
35
- def self.handle_ubuntu_deb(pkg_name, opts)
36
- Profig.handle_debian_deb(pkg_name, opts)
37
- end
38
-
39
- def self.handle_ubuntu_egg(egg_name, opts)
40
- Profig.handle_egg(egg_name, opts)
41
- end
42
-
43
- def self.handle_ubuntu_gem(gem_name, opts)
44
- Profig.handle_gem(gem_name, opts)
45
- end
46
-
47
- def self.handle_ubuntu_dir(name, opts)
48
- Profig.handle_linux_dir(name, opts)
49
- end
50
-
51
- def self.handle_ubuntu_file(name, opts)
52
- Profig.handle_linux_file(name, opts)
53
- end
54
-
55
-
56
- end # module