diff options
Diffstat (limited to 'examples')
38 files changed, 880 insertions, 0 deletions
diff --git a/examples/code/allatonce b/examples/code/allatonce new file mode 100644 index 000000000..2857b9b62 --- /dev/null +++ b/examples/code/allatonce @@ -0,0 +1,13 @@ +# $Id$ + +define thingie { + file { "/tmp/classtest": create => true, mode => 755 } + #testing {} +} + +class testing { + thingie { "componentname": } +} + +#component {} +testing { "testingname": } diff --git a/examples/code/assignments b/examples/code/assignments new file mode 100644 index 000000000..3edcef84e --- /dev/null +++ b/examples/code/assignments @@ -0,0 +1,11 @@ +# $Id$ + +$goodness = sunos + +$subvariable = $goodness + +$yayness = "this is a string of text" + +#$sleeper = service { sleeper: +# running => "1" +#} diff --git a/examples/code/classing b/examples/code/classing new file mode 100644 index 000000000..8f9477721 --- /dev/null +++ b/examples/code/classing @@ -0,0 +1,35 @@ +# $Id$ + +# define the server as a class + +import "components" + +class base() { + # how do i handle components that don't take arguments? do they still + # require a name? + sudo { } +} + +class server inherits base { + file { "/tmp/puppetfiletest": + create => true + } +} + +class webserver(docroot) inherits server { + apache { + php => false, + docroot => $docroot, + user => http, + group => http + } +} + +class sleepserver(path) inherits server { + sleeper { + path => $path, + mode => 644 + } +} + +# see 'nodes' for how to handle nodes diff --git a/examples/code/components b/examples/code/components new file mode 100644 index 000000000..efedf75e3 --- /dev/null +++ b/examples/code/components @@ -0,0 +1,73 @@ +# $Id$ + +# i still have no 'require'-like functionality, and i should also +# have 'recommend'-like functionality... +define apache(php,docroot,user,group) { + package { apache: + version => "2.0.53" + } + service { apache: + running => true + } + + + # this definitely won't parse + if $php == "true" { + # this needs to do two things: + # - mark a dependency + # - cause this apache component to receive refresh events generated by php + #require("php") + $var = value + } + + #file { "../examples/root/etc/configfile": + # owner => $user + #} +} + +define sudo() { + package { sudo: + version => "1.6.8p7" + } + file { "/etc/sudoers": + owner => root, + group => root, + mode => "440" + } +} + +define ssh { + package { ssh: + version => "3.4.4.4" + } + service { "sshd": + running => true + } +} + +define sleeper(path,mode) { + Service { + path => "../examples/root/etc/init.d" + } + + service { sleeper: + running => true, + path => "../examples/root/etc/init.d" + } + file { $path: + mode => $mode + } + $files = ["/tmp/testness","/tmp/funtest"] + file { $files: + create => true + } +} + +#apache { "test": +# php => false, +# docroot => "/export/html", +# user => "www-data", +# group => "www-data" +#} + +#ssh { "yucko":} diff --git a/examples/code/execs b/examples/code/execs new file mode 100644 index 000000000..44f133098 --- /dev/null +++ b/examples/code/execs @@ -0,0 +1,16 @@ +$path = "/usr/bin:/bin" + +exec { "mkdir -p /tmp/fakedir": + path => $path +} + +exec { "rm -rf /tmp/fakedir": + path => $path +} + +exec { "touch /this/directory/does/not/exist": + path => $path, + returns => 1 +} + + diff --git a/examples/code/facts b/examples/code/facts new file mode 100644 index 000000000..fcfec2c0d --- /dev/null +++ b/examples/code/facts @@ -0,0 +1,22 @@ +# $Id$ + +# DISABLED + +# facts are now added to the top scope (e.g., operatingsystem and macaddress) + +# these facts have to get defined by the server onto the client before +# we can retrieve their values +#fact { "videocard": +# interpreter => "/bin/sh", +# code => "lspci | grep VGA", +# os => "Linux" +#} +$testing = "value" +$operatingsystem = fact("operatingsystem") +$fact = addfact( + name => "videocard", + interpreter => "/bin/sh", + code => "lspci | grep VGA", + os => "Linux" +) +$card = fact("videocard") diff --git a/examples/code/failers/badclassnoparam b/examples/code/failers/badclassnoparam new file mode 100644 index 000000000..a0397aacc --- /dev/null +++ b/examples/code/failers/badclassnoparam @@ -0,0 +1,10 @@ +class comp() { + file { "/etc/passwd": + mode => 644 + } +} + +# this argument is invalid, thus we should get a falure +comp { + fakearg => "yay" +} diff --git a/examples/code/failers/badclassparam b/examples/code/failers/badclassparam new file mode 100644 index 000000000..4c9ff6199 --- /dev/null +++ b/examples/code/failers/badclassparam @@ -0,0 +1,10 @@ +class comp(arg1) { + file { "/etc/passwd": + mode => 644 + } +} + +# i've specified an arg but it's an invalid one +comp { + fakearg => "yay" +} diff --git a/examples/code/failers/badcompnoparam b/examples/code/failers/badcompnoparam new file mode 100644 index 000000000..fd25c9445 --- /dev/null +++ b/examples/code/failers/badcompnoparam @@ -0,0 +1,9 @@ +define comp() { + file { "/etc/passwd": + mode => 644 + } +} + +comp { + fakearg => "yay" +} diff --git a/examples/code/failers/badcompparam b/examples/code/failers/badcompparam new file mode 100644 index 000000000..283d54014 --- /dev/null +++ b/examples/code/failers/badcompparam @@ -0,0 +1,9 @@ +define comp(arg1) { + file { "/etc/passwd": + mode => 644 + } +} + +comp { + fakearg => "yay" +} diff --git a/examples/code/failers/badtypeparam b/examples/code/failers/badtypeparam new file mode 100644 index 000000000..4634f2052 --- /dev/null +++ b/examples/code/failers/badtypeparam @@ -0,0 +1,3 @@ +file { "/etc/passwd": + fakeparam => 644 +} diff --git a/examples/code/file.bl b/examples/code/file.bl new file mode 100644 index 000000000..41d80b53d --- /dev/null +++ b/examples/code/file.bl @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/atest": create => true, mode => 755; + "/tmp/btest": create => true, mode => 755 +} + +file { + "/tmp/ctest": create => true; + "/tmp/dtest": create => true; +} diff --git a/examples/code/filedefaults b/examples/code/filedefaults new file mode 100644 index 000000000..cb005c093 --- /dev/null +++ b/examples/code/filedefaults @@ -0,0 +1,10 @@ +# $Id$ + +File { + mode => 755, + recurse => true +} + +file { "/tmp/filedefaultstest": + create => true +} diff --git a/examples/code/fileparsing b/examples/code/fileparsing new file mode 100644 index 000000000..f9766b9f6 --- /dev/null +++ b/examples/code/fileparsing @@ -0,0 +1,116 @@ +# $Id$ + +# this will eventually parse different config files + +# this creates the 'passwd' type, but it does not create any instances +filetype { "passwd": + linesplit => "\n", + escapednewlines => false +} + + +# this creates the 'PasswdUser' type, but again, no instances +filerecord { "user": + filetype => passwd, + fields => [name, password, uid, gid, gcos, home, shell], + namevar => name, + splitchar => ":" + +} + +filetype { ini: + linesplit => "\n\n" +} + +# ini files are different because we don't really care about validating fields +# or at least, we can't do it for most files... +filerecord { "initrecord": + filetype => ini, + fields => [name, password, uid, gid, gcos, home, shell], + namevar => name, + splitchar => ":" + +} + +# this won't work for multiple record types, will it? +# or at least, it requires that we specify multiple times +# ah, and it doesn't specify which of the available record types +# it works for... +passwd { user: + complete => true, # manage the whole file + path => "/etc/passwd" +} + +user { yaytest: + password => x, + uid => 10000, + gid => 10000, + home => "/home/yaytest", + gcos => "The Yaytest", + shell => "/bin/sh" +} + # there seems to be an intrinsic problem here -- i've got subtypes that only + # make sense when an instance of the super type already exists, and i need + # to associate the instances of the subtype with the instances of the supertype + # even if i created the parsers manually, I'd have the same problem + +# this is the crux of it -- i want to be able to say 'user' here without having +# to specify the file, which leaves two options: +# 1) associate the record type with a filetype instance (BAD) +# 2) once the filetype and record type are created, have another command +# that specifically creates a filetype instance and gives names for instances +# of its record types + +define syslog { + + # create a new type, with all defaults + filetype { "syslog": + escapednewlines => true + } + + filerecord { "log": + filetype => syslog, + regex => "^([^#\s]+)\s+(\S+)$", + joinchar => "\t", + fields => [logs, dest] + } + + # these two should just be supported within the filetypes + filerecord { "comment": + filetype => syslog, + regex => "^(#.*)$", + joinchar => "s", + fields => [comment] + } + + filerecord { "blank": + filetype => syslog, + regex => "^(\s*)$", + joinchar => "s", + fields => blank + } +} + +define cron { + filetype { "usercrontab": + } + + # this won't actually work, of course + filerecord { "cronjob": + filetype => crontab, + regex => "^([^#\s]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$", + joinchar => " ", + fields => [minute, hour, day, month, weekday, command], + defaults => ["*", "*", "*", "*", "*", nil], + optional => [minute, hour, day, month, weekday] + } + + crontab { "luke": + } +} + +# XXX this doesn't work in the slightest +define crontab(name,path) { + usercrontab { "${path}/${name}": + } +} diff --git a/examples/code/filerecursion b/examples/code/filerecursion new file mode 100644 index 000000000..b7d8278c2 --- /dev/null +++ b/examples/code/filerecursion @@ -0,0 +1,15 @@ +# $Id$ + +file { "/tmp/dirtest/b/a": + mode => 755, +} + +file { "/tmp/dirtest": + mode => 755, + recurse => true, +} + +file { "/tmp/dirtest/b/b": + mode => 644, +} + diff --git a/examples/code/functions b/examples/code/functions new file mode 100644 index 000000000..8e95c3a72 --- /dev/null +++ b/examples/code/functions @@ -0,0 +1,3 @@ +# $Id$ + +$yaytest = fact("operatingsystem") diff --git a/examples/code/groups b/examples/code/groups new file mode 100644 index 000000000..35505a2eb --- /dev/null +++ b/examples/code/groups @@ -0,0 +1,7 @@ +# $Id$ + +# there need to be two forms of adding to groups: +# add the current host to a group, and add a list of hosts to a +# group by name + +$group = "crap" diff --git a/examples/code/head b/examples/code/head new file mode 100644 index 000000000..0b7a6c288 --- /dev/null +++ b/examples/code/head @@ -0,0 +1,30 @@ +# $Id$ + +# this file is responsible for importing all of the files we want to actually test + +# these are all of the simple tests +import "simpletests" +import "assignments" +import "selectors" +import "iftest" +import "importing" +import "execs" +import "filedefaults" + +# facts are now imported into the top of the namespace +#import "facts" + +# obsoleted +#import "functions" + +# files we no longer need to import directly, or at all in some cases +#import "one" +#import "classing" +#import "components" +#import "file.bl" +#import "fileparsing.disabled" +#import "groups" + +# this imports the more complex files +import "allatonce" # imports classing and components +import "nodes" # imports classing and components diff --git a/examples/code/iftest b/examples/code/iftest new file mode 100644 index 000000000..bc9d9cff1 --- /dev/null +++ b/examples/code/iftest @@ -0,0 +1,21 @@ +# $Id$ +$variable = "value" + +$cooltest = $variable ? { + other => yayness, + value => goodtest +} + +if $variable == "other" { + $cooltest = "yayness" + $platform = $operatingsystem +} elsif $variable == "value" { + $cooltest = "goodtest" + $platform = $operatingsystem +} else { + $goodness = $operatingsystemrelease +} + +if "value" == "value" { + $booyah = "value" +} diff --git a/examples/code/importing b/examples/code/importing new file mode 100644 index 000000000..f02604109 --- /dev/null +++ b/examples/code/importing @@ -0,0 +1,8 @@ +# $Id$ + +#import "groups" +# testing import loops +import "importing" + +$name = "value" +$system = $operatingsystem diff --git a/examples/code/nodes b/examples/code/nodes new file mode 100644 index 000000000..42488e689 --- /dev/null +++ b/examples/code/nodes @@ -0,0 +1,20 @@ +# $Id$ + +# define nodes + +#service.setpath("../examples/root/etc/init.d") + +Service { + path => "../examples/root/etc/init.d" +} + +import "classing" + +sleepserver { + path => $operatingsystem ? { + sunos => "../examples/root/etc/configfile", + hpux => "../examples/other/etc/configfile", + default => "../examples/root/etc/configfile" + }, + schedule => true +} diff --git a/examples/code/one b/examples/code/one new file mode 100644 index 000000000..452d32f3e --- /dev/null +++ b/examples/code/one @@ -0,0 +1,8 @@ +# $Id$ + +# this service doesn't actually exist, so we noop it +# and this way, we can test noop :) +service { "funtest": + running => "0", + noop => true +} diff --git a/examples/code/relationships b/examples/code/relationships new file mode 100644 index 000000000..f2319d5e4 --- /dev/null +++ b/examples/code/relationships @@ -0,0 +1,34 @@ +# $Id$ + +#service.setpath("../examples/root/etc/init.d") +#puppet.statefile("/tmp/puppetstate") +$path = "../examples/root/etc/configfile" + path => "../examples/root/etc/init.d" + + +define files { + file { "/tmp/yaytest": + create => true, + mode => 755 + } + file { "/tmp/exists": + checksum => md5 + } +} + +define sleeper { + file { $path: + mode => 755 + } + service { sleeper: + path => "../examples/root/etc/init.d", + running => 1 + } +} + +files { } + +sleeper { + require => files["yay"], + schedule => true +} diff --git a/examples/code/selectors b/examples/code/selectors new file mode 100644 index 000000000..b1f1c63ec --- /dev/null +++ b/examples/code/selectors @@ -0,0 +1,28 @@ +# $Id$ +# + +$platform = sunos + +$funtest = $platform ? { + sunos => yayness, + aix => goodness, + default => badness +} + +# this is a comment + +$filename = "/tmp/yayness" + +$sleeper = file { $filename: + mode => $platform ? { + sunos => 644, + default => 755 + }, + create => $platform ? sunos => true +} + +# i guess it has to be solved this way... + +$platform ? sunos => file { $filename: + mode => 644 +} diff --git a/examples/code/simpletests b/examples/code/simpletests new file mode 100644 index 000000000..6a2d5c5ff --- /dev/null +++ b/examples/code/simpletests @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/atest": create => true; + "/tmp/btest": create => true +} + +file { + "/tmp/ctest": create => true; + "/tmp/dtest": create => true; +} diff --git a/examples/code/snippets/argumentdefaults b/examples/code/snippets/argumentdefaults new file mode 100644 index 000000000..b4081e9b0 --- /dev/null +++ b/examples/code/snippets/argumentdefaults @@ -0,0 +1,14 @@ +# $Id$ + +define testargs(file, mode = 755) { + file { $file: create => true, mode => $mode } +} + +testargs { "testingname": + file => "/tmp/argumenttest1" +} + +testargs { "testingother": + file => "/tmp/argumenttest2", + mode => 644 +} diff --git a/examples/code/snippets/classpathtest b/examples/code/snippets/classpathtest new file mode 100644 index 000000000..609b3bef5 --- /dev/null +++ b/examples/code/snippets/classpathtest @@ -0,0 +1,13 @@ +# $Id$ + +define component { + file { "/tmp/classtest": create => true, mode => 755 } + #testing {} +} + +class testing { + component { "componentname": } +} + +#component {} +testing { "testingname": } diff --git a/examples/code/snippets/dirchmod b/examples/code/snippets/dirchmod new file mode 100644 index 000000000..0a8268fa8 --- /dev/null +++ b/examples/code/snippets/dirchmod @@ -0,0 +1,19 @@ +# $Id$ + +file { + "/tmp/dirchmodtesta": create => directory; + "/tmp/dirchmodtesta/testing": create => true +} + +file { "/tmp/dirchmodtesta": + mode => 644, recurse => true +} + +file { + "/tmp/dirchmodtestb": create => directory; + "/tmp/dirchmodtestb/testing": create => true +} + +file { "/tmp/dirchmodtestb": + mode => 600, recurse => true +} diff --git a/examples/code/snippets/filecreate b/examples/code/snippets/filecreate new file mode 100644 index 000000000..7a4cdbb1e --- /dev/null +++ b/examples/code/snippets/filecreate @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/createatest": create => true, mode => 755; + "/tmp/createbtest": create => true, mode => 755 +} + +file { + "/tmp/createctest": create => true; + "/tmp/createdtest": create => true; +} diff --git a/examples/code/snippets/simpledefaults b/examples/code/snippets/simpledefaults new file mode 100644 index 000000000..a8f6190b1 --- /dev/null +++ b/examples/code/snippets/simpledefaults @@ -0,0 +1,5 @@ +# $Id$ + +File { mode => 755 } + +file { "/tmp/defaulttest": create => true } diff --git a/examples/code/snippets/simpleselector b/examples/code/snippets/simpleselector new file mode 100644 index 000000000..52a06c773 --- /dev/null +++ b/examples/code/snippets/simpleselector @@ -0,0 +1,38 @@ +# $Id$ + +$var = "value" + +file { "/tmp/snippetselectatest": + create => true, + mode => $var ? { + nottrue => 641, + value => 755 + } +} + +file { "/tmp/snippetselectbtest": + create => true, + mode => $var ? { + nottrue => 644, + default => 755 + } +} + +$othervar = "complex value" + +file { "/tmp/snippetselectctest": + create => true, + mode => $othervar ? { + "complex value" => 755, + default => 644 + } +} +$anothervar = Yayness + +file { "/tmp/snippetselectdtest": + create => true, + mode => $anothervar ? { + Yayness => 755, + default => 644 + } +} diff --git a/examples/code/svncommit b/examples/code/svncommit new file mode 100644 index 000000000..350cd8580 --- /dev/null +++ b/examples/code/svncommit @@ -0,0 +1,13 @@ +$path = "/usr/bin:/bin" + +file { "/tmp/svntests": + recurse => true, + checksum => md5 +} + +exec { "echo 'files have been updated'": + cwd => "/tmp/svntests", + refreshonly => true, + require => file["/tmp/svntests"], + path => $path +} diff --git a/examples/root/bin/sleeper b/examples/root/bin/sleeper new file mode 100755 index 000000000..ca38c3e53 --- /dev/null +++ b/examples/root/bin/sleeper @@ -0,0 +1,69 @@ +#!/usr/bin/ruby -w + +### +# sleep indefinitely as a debug + +require 'getoptlong' + +#----------------------------------------------------------------- +def daemonize + outfile = "/tmp/sleeperout" + if pid = fork() + Process.detach(pid) + sleep 1 + # verify that we didn't have any problems starting the daemon + if FileTest.exists?(outfile) + $stderr.puts "Sleeper failed: %s" % File.read(outfile) + File.unlink(outfile) + exit(14) + else + exit(0) + end + end + Process.setsid + Dir.chdir("/") + begin + $stdin.reopen "/dev/null" + $stdout.reopen "/dev/null", "a" + $stderr.reopen $stdin + rescue => detail + File.open(outfile, "w") { |f| + f.puts detail + } + exit(12) + end +end +#----------------------------------------------------------------- + +debug = false + +result = GetoptLong.new( + [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], + [ "--help", "-h", GetoptLong::NO_ARGUMENT ] +) + +result.each { |opt,arg| + case opt + when "--help" + puts "There is no help yet" + exit + when "--debug" + debug = true + else + raise "Invalid option '#{opt}'" + end +} + +trap(:INT) { + exit +} + +unless debug + daemonize() +end + +var = true + +while var do + sleep 600 +end diff --git a/examples/root/etc/configfile b/examples/root/etc/configfile new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/examples/root/etc/configfile diff --git a/examples/root/etc/debian-passwd b/examples/root/etc/debian-passwd new file mode 100644 index 000000000..59cdf4acf --- /dev/null +++ b/examples/root/etc/debian-passwd @@ -0,0 +1,29 @@ +root:x:0:0:root:/root:/bin/bash +daemon:x:1:1:daemon:/usr/sbin:/bin/sh +bin:x:2:2:bin:/bin:/bin/sh +sys:x:3:3:sys:/dev:/bin/sh +sync:x:4:65534:sync:/bin:/bin/sync +games:x:5:60:games:/usr/games:/bin/sh +man:x:6:12:man:/var/cache/man:/bin/sh +lp:x:7:7:lp:/var/spool/lpd:/bin/sh +mail:x:8:8:mail:/var/mail:/bin/sh +news:x:9:9:news:/var/spool/news:/bin/sh +uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh +proxy:x:13:13:proxy:/bin:/bin/sh +postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh +www-data:x:33:33:www-data:/var/www:/bin/sh +backup:x:34:34:backup:/var/backups:/bin/sh +operator:x:37:37:Operator:/var:/bin/sh +list:x:38:38:Mailing List Manager:/var/list:/bin/sh +irc:x:39:39:ircd:/var/run/ircd:/bin/sh +gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh +nobody:x:65534:65534:nobody:/nonexistent:/bin/sh +sshd:x:102:65534::/var/run/sshd:/bin/false +gdm:x:101:101:Gnome Display Manager:/var/lib/gdm:/bin/false +telnetd:x:103:103::/usr/lib/telnetd:/bin/false +nagios:x:1000:1001::/home/nagios: +messagebus:x:104:107::/var/run/dbus:/bin/false +saned:x:109:109::/home/saned:/bin/false +ganglia:x:105:110:Ganglia Monitor:/var/lib/ganglia:/bin/false +zope:x:106:111::/var/lib/zope2.7/var:/bin/false +fbgetty:x:112:112::/home/fbgetty:/bin/false diff --git a/examples/root/etc/debian-syslog.conf b/examples/root/etc/debian-syslog.conf new file mode 100644 index 000000000..8f2925960 --- /dev/null +++ b/examples/root/etc/debian-syslog.conf @@ -0,0 +1,71 @@ +# /etc/syslog.conf Configuration file for syslogd. +# +# For more information see syslog.conf(5) +# manpage. + +# +# First some standard logfiles. Log by facility. +# + +auth,authpriv.* /var/log/auth.log +*.*;auth,authpriv.none -/var/log/syslog +#cron.* /var/log/cron.log +daemon.* -/var/log/daemon.log +kern.* -/var/log/kern.log +lpr.* -/var/log/lpr.log +mail.* -/var/log/mail.log +user.* -/var/log/user.log +uucp.* /var/log/uucp.log + +# +# Logging for the mail system. Split it up so that +# it is easy to write scripts to parse these files. +# +mail.info -/var/log/mail.info +mail.warn -/var/log/mail.warn +mail.err /var/log/mail.err + +# Logging for INN news system +# +news.crit /var/log/news/news.crit +news.err /var/log/news/news.err +news.notice -/var/log/news/news.notice + +# +# Some `catch-all' logfiles. +# +*.=debug;\ + auth,authpriv.none;\ + news.none;mail.none -/var/log/debug +*.=info;*.=notice;*.=warn;\ + auth,authpriv.none;\ + cron,daemon.none;\ + mail,news.none -/var/log/messages + +# +# Emergencies are sent to everybody logged in. +# +*.emerg * + +# +# I like to have messages displayed on the console, but only on a virtual +# console I usually leave idle. +# +#daemon,mail.*;\ +# news.=crit;news.=err;news.=notice;\ +# *.=debug;*.=info;\ +# *.=notice;*.=warn /dev/tty8 + +# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, +# you must invoke `xconsole' with the `-file' option: +# +# $ xconsole -file /dev/xconsole [...] +# +# NOTE: adjust the list below, or you'll go crazy if you have a reasonably +# busy site.. +# +daemon.*;mail.*;\ + news.crit;news.err;news.notice;\ + *.=debug;*.=info;\ + *.=notice;*.=warn |/dev/xconsole + diff --git a/examples/root/etc/init.d/sleeper b/examples/root/etc/init.d/sleeper new file mode 100755 index 000000000..e7f5d3e30 --- /dev/null +++ b/examples/root/etc/init.d/sleeper @@ -0,0 +1,65 @@ +#!/bin/bash + +# $Id$ + +script=$0 +path=`echo $script | sed 's/etc..*/bin/'` + +PATH=$PATH:$path + +ps=`facter ps | cut -d ' ' -f3-` + +if [ -z "$ps" ]; then + ps="ps -ef" +fi + +function start +{ + sleeper +} + +function stop +{ + #if [ -n `which pgrep` ]; then + # pid=`pgrep sleeper` + #else + pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` + #fi + if [ -n "$pid" ]; then + kill $pid + fi +} + +function status +{ + #if [ -n `which pgrep` ]; then + # cmd="pgrep sleeper" + #else + #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" + #fi + #$cmd + $ps | grep -v grep | grep sleeper | grep ruby +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop; start + ;; + status) + output=`status` + #status + exit $? + ;; + *) + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/examples/root/etc/otherfile b/examples/root/etc/otherfile new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/examples/root/etc/otherfile |