rpanel 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/lib/rpanel/cli.rb +73 -12
  4. metadata +2 -2
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  gem.summary = %Q{Ruby tool for cpanel}
9
9
  gem.description = %Q{Ruby tools for cpanel related admin tasks}
10
10
  gem.email = "jerrodblavos@mac.com"
11
- gem.homepage = "http://github.com/jerrod/rpanel"
11
+ gem.homepage = "http://github.com/indierockmedia/rpanel"
12
12
  gem.authors = ["jayronc"]
13
13
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
14
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/rpanel/cli.rb CHANGED
@@ -4,10 +4,11 @@ require 'fileutils'
4
4
 
5
5
  module Rpanel
6
6
  class CLI
7
- IGNORE_DIRECTORIES = ['.', '..','.cpan', '.cpcpan', 'cpeasyapache', 'cprubybuild', 'cprubygemsbuild', 'domlogs', 'liquidweb', 'lost+found', 'fantasti', 'MySQL-install', 'virtfs']
7
+ IGNORE_DIRECTORIES = ['.', '..','.localized', '.cpan', '.cpcpan', 'cpeasyapache', 'cprubybuild', 'cprubygemsbuild', 'domlogs', 'liquidweb', 'lost+found', 'fantasti', 'MySQL-install', 'virtfs']
8
8
  def self.execute(stdout, arguments=[])
9
9
 
10
10
  options = {
11
+ :basedir => '/home',
11
12
  :fix_sc => nil,
12
13
  :fix_owner => nil,
13
14
  :fix_files => nil,
@@ -26,6 +27,7 @@ module Rpanel
26
27
  Options are:
27
28
  BANNER
28
29
  opts.separator ""
30
+ opts.on("-b","--base-dir=BASEDIR", String, "Set base directory. defaults to /home"){|arg| options[:basedir] = arg.strip}
29
31
  opts.on("-l", "--list", "List all accounts"){ |arg| options[:list] = true }
30
32
  opts.on("-s", "--fix-source-control",
31
33
  "Ensure .svn or .git directories are not group or world-readable") { |arg| options[:fix_sc] = true }
@@ -54,26 +56,85 @@ module Rpanel
54
56
  end
55
57
  end
56
58
 
57
- if options[:list]
58
- dirs = Dir.entries('/Users/jerrod') - IGNORE_DIRECTORIES
59
+ if options[:list] || options[:apply_all_accounts]
60
+ dirs = Dir.entries(options[:basedir]) - IGNORE_DIRECTORIES
59
61
  accounts = dirs.sort{|a,z| a.downcase <=>z.downcase}
60
- puts accounts
61
62
  end
62
63
 
64
+ if options[:list]
65
+ puts accounts
66
+ exit
67
+ end
68
+
63
69
  username = options[:username]
64
- if options[:all]
70
+ if options[:all]
65
71
  options[:fix_sc] = true
66
72
  options[:fix_owner] = true
67
73
  options[:fix_files] = true
68
74
  options[:fix_directories] = true
69
75
  end
70
- puts "-s" if options[:fix_sc]
71
- puts "-o" if options[:fix_owner]
72
- puts "-f" if options[:fix_files]
73
- puts "-d" if options[:fix_directories]
74
- puts "-u" if options[:username]
75
- puts "-a" if options[:apply_all_accounts]
76
- stdout.puts "* Checking permissions for #{username}"
76
+
77
+
78
+ if options[:fix_sc]
79
+ puts "Fixing Source Control ownership"
80
+ if accounts
81
+ accounts.each do |account|
82
+ puts "Fixing #{account} Source files"
83
+ system("find #{File.join(options[:basedir], account, 'public_html')} -type d -name '.svn' -exec chown -R #{account}:#{account} {} \\;")
84
+ system("find #{File.join(options[:basedir], account, 'public_html')} -type d -name '.svn' -exec chmod 0700 {} \\;")
85
+ system("find #{File.join(options[:basedir], account, 'public_html')} -type d -name '.svn' -exec -exec find {} -type f -print0 \\; |xargs -0 chmod 0600 ")
86
+ end
87
+ else
88
+ puts "Fixing #{options[:username]} Source files"
89
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -type d -name '.svn' -exec chown -R #{options[:username]}:#{options[:username]} {} \\;")
90
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -type d -name '.svn' -exec chmod 0700 {} \\;")
91
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -type d -name '.svn' -exec -exec find {} -type f -print0 \\; |xargs -0 chmod 0600 ") end
92
+ puts "Done with Source Control ownership"
93
+ end
94
+
95
+ if options[:fix_owner]
96
+ puts "Fixing file ownership"
97
+ if accounts
98
+ accounts.each do |account|
99
+ puts "Fixing #{account} file ownership"
100
+ system("find #{File.join(options[:basedir], account, 'public_html')} -exec chown -R #{account}:#{account} {} \\;")
101
+ end
102
+ else
103
+ puts "Fixing #{options[:username]} file ownership"
104
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -exec chown -R #{options[:username]}:#{options[:username]} {} \\;")
105
+ end
106
+ puts "Done Fixing file ownership"
107
+ end
108
+
109
+ if options[:fix_files]
110
+ puts "Fixing file permissions"
111
+ if accounts
112
+ accounts.each do |account|
113
+ puts "Fixing #{account} file permissions"
114
+ system("find #{File.join(options[:basedir], account, 'public_html')} -type f -perm 0777 -o -perm 0666 -exec chmod 0644 {} \\;")
115
+ end
116
+ else
117
+ puts "Fixing #{options[:username]} file permissions"
118
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -type f -perm 0777 -o -perm 0666 -exec chmod 0644 {} \\;")
119
+ end
120
+ puts "Done Fixing file permissions"
121
+ end
122
+
123
+ if options[:fix_directories]
124
+ puts "Fixing directories permissions"
125
+ if accounts
126
+ accounts.each do |account|
127
+ puts "Fixing #{account} directory permissions"
128
+ system("find #{File.join(options[:basedir], account, 'public_html')} -perm 0777 -type d -exec chmod 0755 {} \\;")
129
+ end
130
+ else
131
+ puts "Fixing #{options[:username]} directory permissions"
132
+ system("find #{File.join(options[:basedir], options[:username], 'public_html')} -perm 0777 -type d -exec chmod 0755 {} \\;")
133
+ end
134
+ puts "Done Fixing directories permissions"
135
+ end
136
+
137
+ stdout.puts "All Done!"
77
138
 
78
139
  # raise "Path is required!" unless File.directory?(rails_app_path) or File.directory?("#{rails_app_path}/public")
79
140
  # FileUtils::mkdir_p(config_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpanel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jayronc
@@ -33,7 +33,7 @@ files:
33
33
  - test/helper.rb
34
34
  - test/test_rpanel.rb
35
35
  has_rdoc: true
36
- homepage: http://github.com/jerrod/rpanel
36
+ homepage: http://github.com/indierockmedia/rpanel
37
37
  licenses: []
38
38
 
39
39
  post_install_message: