summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-13 15:23:57 +0000
committerLuke Kanies <luke@madstop.com>2005-04-13 15:23:57 +0000
commit5416017c05e44fc635ad14ffdf1ac1163a4cc6e5 (patch)
tree29a33a7dd1389abde8d92219a17beead01ba1f47 /bin
parent54e9b5e3561977ea063417da12c46aad2a4c1332 (diff)
downloadpuppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.tar.gz
puppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.tar.xz
puppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.zip
reorganizing
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@95 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'bin')
-rwxr-xr-xbin/blinker89
-rwxr-xr-xbin/sleeper97
2 files changed, 186 insertions, 0 deletions
diff --git a/bin/blinker b/bin/blinker
new file mode 100755
index 000000000..d54041dc5
--- /dev/null
+++ b/bin/blinker
@@ -0,0 +1,89 @@
+#!/usr/local/bin/ruby -w
+
+# $Id$
+
+require 'blink'
+require 'facter'
+
+# collect enough information to make some simple decisions
+begin
+ facts = Facter.retrieve('OperatingSystem','OperatingSystemRelease','Hostname')
+rescue => error
+ puts "Could not retrieve facts: %s" % error
+ exit(47)
+end
+
+# set up how our environment will behave
+args = Hash.new
+
+args[:debug] = 1
+
+args[:depthfirst] = 1
+args[:opinstances] = 1
+
+Blink.init(args)
+
+# and now build a simple component, consisting of a process
+# that depends on a file
+component = Blink::Component.new(:name => "sleeper")
+
+# add our testing directory to the search path for services
+Blink::Objects::Service.addpath(
+ File.expand_path("~/svn/blink/examples/root/etc/init.d")
+)
+
+# here's the process itself
+sleeper = Blink::Objects::Service.new(
+ :running => 1,
+ :name => "sleeper"
+)
+
+# add it to the component
+component.push(sleeper)
+
+#groupselector = Blink::Selector.new(
+ # proc { facts['Hostname'] == 'culain' } => 'luke',
+ # proc { facts['Hostname'] == 'kirby' } => 'sysadmin'
+#)
+
+# and the file that our component depends on
+configfile = Blink::Objects::BFile.new(
+ :path => File.expand_path("~/svn/blink/examples/root/etc/configfile"),
+ :owner => "luke",
+ :group => "sysadmin",
+ :mode => 0644
+)
+ #:check => "md5"
+
+component.push(configfile)
+
+# i guess i should call subscribe on the object triggering the event,
+# not the one responding....
+# except that really, the one responding is merely listening to events
+# that pass through it...
+# XXX okay, i need to decide whether i use generic components and lose
+# the actual dependency information, or whether i use literal dependency
+# information
+configfile.subscribe(
+ :event => :inode_changed,
+ :object => sleeper
+) { |me,object,event|
+ puts "#{me} restarting because of #{event} from #{object}"
+ me.callop("stop")
+ me.callop("start")
+}
+
+component.retrieve()
+
+#unless component.insync?
+# component.sync()
+#end
+
+puts sleeper.insync?()
+sleeper.sync()
+sleeper.retrieve()
+puts sleeper.insync?()
+
+#other.contains(test)
+
+#Blink.run
diff --git a/bin/sleeper b/bin/sleeper
new file mode 100755
index 000000000..5382383cd
--- /dev/null
+++ b/bin/sleeper
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+
+###
+# sleep indefinitely as a debug
+
+use strict;
+use Getopt::Long;
+use Pod::Usage;
+
+#-----------------------------------------------------------------
+sub daemonize
+{
+ use POSIX 'setsid';
+ $| = 1;
+ chdir '/' or die "Can't chdir to /: $!\n";
+ open STDIN, "/dev/null" or die "Can't read /dev/null: $!\n";
+ open STDOUT, "> /dev/null" or die "Can't write to /dev/null: $!\n";
+ defined(my $pid = fork()) or die "Can't fork: $!\n";
+ #print STDERR $pid, "\n";
+ exit if $pid;
+ setsid or die "Can't start a new session: $!\n";
+ open STDERR, ">&STDOUT" or die "Can't dup stdout: $!\n";
+}
+#-----------------------------------------------------------------
+
+my ($help,$opt_result,$debug,$fun);
+
+$opt_result = GetOptions
+(
+ "help" => \$help,
+ "debug" => \$debug,
+ "fun" => \$fun,
+);
+
+if (! $opt_result)
+{
+ pod2usage('-exitval' => 1, '-verbose' => 0);
+ exit(1);
+}
+
+if ($help)
+{
+ pod2usage('-exitval' => 1, '-verbose' => 2);
+ exit;
+}
+
+unless ($debug) {
+ daemonize();
+}
+
+while(1){
+ sleep 600;
+}
+
+=head1 NAME
+
+template - this is a template script and should be copied and modded
+
+=head1 SYNOPSIS
+
+template [-help]
+
+=head1 DESCRIPTION
+
+B<template> is a stub script.
+
+=head1 OPTIONS
+
+=over 4
+
+=item help
+
+Prints out help page.
+
+=back
+
+B<Example>
+
+template
+
+=head1 BUGS
+
+This script shouldn't be modified, or has apparently not been documented.
+
+=head1 SEE ALSO
+
+L<Cat>
+
+=head1 AUTHOR
+
+Luke A. Kanies, luke.kanies@cat.com
+
+=for html <hr>
+
+I<$Id: sleeper,v 1.1 2004/03/04 03:23:03 luke Exp $>
+
+=cut