summaryrefslogtreecommitdiffstats
path: root/lib/puppet/storage.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-07-11 18:14:20 +0000
committerLuke Kanies <luke@madstop.com>2005-07-11 18:14:20 +0000
commit96f3980a57f8fd24aff801420a0813bad9bb20d7 (patch)
treecaffb500e987998c29fb773869b58c335d71d382 /lib/puppet/storage.rb
parent649d59a24cf03387e58fa1d4a151fcf34e409777 (diff)
downloadpuppet-96f3980a57f8fd24aff801420a0813bad9bb20d7.tar.gz
puppet-96f3980a57f8fd24aff801420a0813bad9bb20d7.tar.xz
puppet-96f3980a57f8fd24aff801420a0813bad9bb20d7.zip
adding Puppet#recmkdir utility function, and making sure Log and Storage create their own files and directories as necessary
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@354 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/storage.rb')
-rw-r--r--lib/puppet/storage.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
index 53b3b5a6e..28d593db0 100644
--- a/lib/puppet/storage.rb
+++ b/lib/puppet/storage.rb
@@ -35,6 +35,21 @@ module Puppet
end
def Storage.store
+ unless FileTest.directory?(File.dirname(Puppet[:statefile]))
+ begin
+ Puppet.recmkdir(Puppet[:statefile])
+ Puppet.info "Creating state directory %s" %
+ File.basename(Puppet[:statefile])
+ rescue => detail
+ Puppet.err "Could not create state file: %s" % detail
+ return
+ end
+ end
+
+ unless FileTest.exist?(Puppet[:statefile])
+ Puppet.info "Creating state file %s" % Puppet[:statefile]
+ end
+
File.open(Puppet[:statefile], File::CREAT|File::WRONLY, 0600) { |file|
@@state.each { |klass, thash|
thash.each { |key,value|