ossp-pkg/rc/rc.example
##
## rc.example - rcfile template
##
## This file examines different ways of writing run commands for a ##
## program. If used in production, this file would be different. It ##
## would have a name like 'rc.helloworld' and contain run commands ##
## for the 'helloworld' program. It would also have only one ##
## notation. A sample is repeated in this document using rc (native), ##
## XML, and ASN.1 notation. The same rcfile semantics are repeated ##
## only to show what is possible through the abstract syntax offered ##
## by OSSP rc. ##
## ##
## To learn what regular expressions to use with the example ##
## example syntaxes in this document, refer to the rc.conf file ##
## included with the original OSSP rc distribution. It has the ##
## corresponding regular expressions settings. ##
## ##
# Generic run commands for example daemon. Using #
# default symbols and conventional identifiers. #
%confvars
sftpd_enable="yes"
sftpd_anonymous="yes"
sftpd_flags=""
%common
timeStamp # Function from rc.func library
%start -p 200 -u root
/usr/local/sbin/sftpd -c
%stop -p 200 -u root
kill -TERM `cat /var/sftp/run/sftpd.pid`
%reload -u root
kill -HUP `cat /var/sftp/run/sftpd.pid`
%restart -u root
@stop # Reference to term section
sleep ${nSleep} # Variable nSleep defined at the command line
@start # Reference to start section
%status -c /usr/bin/perl
print STDERR "Sftpd status report";
for ...
%init # Empty section body to prevent %default from running, in
# case the user types rc 'rcfile' 'init' on the command line
%go -u root
@start # A section with just one reference is an alias
%error # We have a rc error
logger -p local0.notice "OSSP rc error"
# Very rough representation of built-in rc language
+logit DAEMON CRITICAL;
+outconsole ${rc_errstring}; # rc_errcode is also available
+outconsole "Runcommand-level error in line ";
+lineno SCRIPT; # Not +lineno ABSOLUTE;
+outconsole " of rcfile ";
+rcfilename;
%default # Gets hit if no other section label matches
$HOME/bin/popup "Missing section in rc.sftpd!" # Run custom app
@error # Reference to error section
# End stock syntax example rcfile
# Generic run commands for example daemon. Using #
# custom symbols and unconventional identifiers. #
!confvars
sftpd_enable="yes"
sftpd_anonymous="yes"
sftpd_flags=""
!prependwith
timeStamp # Function from rc.func library
!run -p 200 -u root
/usr/local/sbin/sftpd -c
!term -p 200 -u root
kill -TERM `cat /var/sftp/run/sftpd.pid`
!hangup -u root
kill -HUP `cat /var/sftp/run/sftpd.pid`
!termrun -u root
&term # Reference to term section
sleep ${nSleep} # Variable nSleep defined at the command line
&start # Reference to start section
!printstat -c /usr/bin/perl
print STDERR "Sftpd status report";
for ...
!runit # Empty section body to prevent !missing from running, in
# case the user types rc 'rcfile' 'runit' on the command line
!doit -u root
&run # A section with just one reference is an alias
!problem # We have a rc error
logger -p local0.notice "OSSP rc error"
# Very rough representation of built-in rc language
+logit DAEMON CRITICAL;
+outconsole ${rc_errstring}; # rc_errcode is also available
+outconsole "Runcommand-level error in line ";
+lineno SCRIPT; # Not +lineno ABSOLUTE;
+outconsole " of rcfile ";
+rcfilename;
!missing # Gets hit if no other section label matches
$HOME/bin/popup "Missing section in rc.sftpd!" # Run custom app
@error # Reference to error section
# End custom syntax example rcfile
# Generic run commands for example daemon. Using an #
# XML-like syntax and conventional identifiers. #
<config>
<set name=sftpd_enable>"yes"</set>
<set name=sftpd_anonymous>"yes"</set>
<set name=sftpd_flags>""</set>
</config>
<common>
timeStamp # Function from rc.func library
</common>
<start pri=200 user=root>
/usr/local/sbin/sftpd -c
</start>
<stop pri=200 user=root>
kill -TERM `cat /var/sftp/run/sftpd.pid`
</stop>
<reload user=root>
kill -HUP `cat /var/sftp/run/sftpd.pid`
</reload>
<restart user=root>
<refer name=stop> # Reference to term section
sleep ${nSleep} # Variable nSleep defined at the command line
<refer name=start> # Reference to start section
</restart>
<status pri=100 interpreter=/usr/bin/perl>
print STDERR "Sftpd status report";
for ...
</status>
<init user=root> # Empty section body to prevent <default> from running, in
# case the user types rc 'rcfile' 'init' on the command line
<go user=root>
<refer name=start> # A section with just one reference is an alias
</go>
<error> # We have a rc error
logger -p local0.notice "OSSP rc error"
# Very rough representation of built-in rc language
+logit DAEMON CRITICAL;
+outconsole ${rc_errstring}; # rc_errcode is also available
+outconsole "Runcommand-level error in line ";
+lineno SCRIPT; # Not +lineno ABSOLUTE;
+outconsole " of rcfile ";
+rcfilename;
</error>
<default> # Gets hit if no other section label matches
$HOME/bin/popup "Missing section in rc.sftpd!" # Run custom app
<refer name=error> # Reference to error section
</default>
# End XML-like syntax example rcfile
# Generic run commands for example daemon. Using a #
# ASN.1-like syntax and conventional identifiers. #
config CONFIG
BEGIN
sftpd_enable STRING ::= "yes"
sftpd_anonymous STRING ::= "yes"
sftpd_flags STRING ::= ""
END
common COMMON
BEGIN
timeStamp # Function from rc.func library
END
start SECTION ::= {
priority INTEGER ::= 200
user STRING ::= "root"
}
BEGIN
/usr/local/sbin/sftpd -c
END
stop SECTION ::= {
priority INTEGER ::= 200
user STRING ::= "root"
}
BEGIN
kill -TERM `cat /var/sftp/run/sftpd.pid`
END
reload SECTION ::= {
user STRING ::= "root"
}
BEGIN
kill -HUP `cat /var/sftp/run/sftpd.pid`
END
restart SECTION ::= {
user STRING ::= "root"
}
BEGIN
stop REFER # Reference to term section
sleep ${nSleep} # Variable nSleep defined at the command line
start REFER # Reference to start section
END
status SECTION ::= {
priority INTEGER ::= 100
interpreter STRING ::= "/usr/bin/perl"
}
BEGIN
print STDERR "Sftpd status report";
for ...
END
init SECTION ::= {} # Empty section body to prevent default from running, in
BEGIN # case the user types rc 'rcfile' 'init' on the command line
END
go SECTION ::= {
user STRING ::= "root"
}
BEGIN
start REFER # A section with just one reference is an alias
END
error ERROR # We have a rc error
BEGIN
logger -p local0.notice "OSSP rc error"
# Very rough representation of built-in rc language
+logit DAEMON CRITICAL;
+outconsole ${rc_errstring}; # rc_errcode is also available
+outconsole "Runcommand-level error in line ";
+lineno SCRIPT; # Not +lineno ABSOLUTE;
+outconsole " of rcfile ";
+rcfilename;
END
default DEFAULT # Gets hit if no other section label matches
BEGIN
$HOME/bin/popup "Missing section in rc.sftpd!" # Run custom app
error REFER # Reference to error section
END
# End ASN.1-like syntax example rcfile