]>
gitweb.michael.orlitzky.com - dead/janitor.git/blob - janitize.rb
4e8c039334fbe568afc2b1086418ac931a089f10
1 # Actually run the thing.
6 # Set up the default options
7 options
= { :apache_vhost_directory => '/etc/apache2/vhosts.d',
8 :maximum_file_age => 7 }
10 # And parse any that were given on the command line.
11 OptionParser
.new
do |opts
|
12 opts
.banner
= "Usage: #{$0} [options]"
14 opts
.on('-a', '--apache_vhosts_directory VHOSTS_DIR',
15 'Apache vhost conf file directory') do |vhost_dir
|
16 options
[:apache_vhost_directory] = vhost_dir
19 opts
.on('-m', '--maximum_file_age MAX_DAYS_OLD', Integer
,
20 'Maximum file age (in days)') do |max_age
|
21 options
[:maximum_file_age] = max_age
24 opts
.on_tail("-h", "--help", "Show this message") do
32 # Print an informational header every time the program is run.
33 puts
"Command line: #{$0 + ' ' + ARGV.join(' ')}"
35 current_time
= Time
.now()
36 if current_time
.respond_to
?(:iso8601)
37 # Somehow this method is missing on some machines.
38 puts
"Time: #{current_time.iso8601}"
40 # Fall back to whatever this looks like.
41 puts
"Time: #{current_time}"
44 puts
"Apache vhost directory: #{options[:apache_vhost_directory]}"
45 puts
"Max File Age: #{options[:maximum_file_age]}"
48 j
.apache_vhosts_directory
= options
[:apache_vhost_directory]
50 temp_dirs
= j
.get_temporary_directories()
52 puts
"Temporary directories: #{temp_dirs.join(', ')}\n\n"
54 temp_dirs
.each
do |dir
|
55 j
.clean_directory(dir
, options
[:maximum_file_age])