auto
  3   ˆl–ß=¿JJh¥6 _¸Ëw˜´oŽþZÎ2Üe}ÁJÌ`óÂ74ÁÀ¿  6   ˆl–ßi~”d
_)Ú€Æœ¸TÅ£�þY ÙYÆ�^qá��ùÃ„m‰ŸÂÁÀ  J    #!/bin/sh
exec /usr/bin/mono $MONO_OPTIONS /usr/lib/mono/4.5/mcs.exe "$@"
 <£    #!/usr/bin/perl
# 
# fixproc [-min n] [-max n] [-check | -kill | -restart | -exist | -fix] proc ...
# 
# fixproc exit code:
# 	0	ok
# 	1	check failed
# 	2	cannot restart
# 	3	cannot kill
# 	4	fix failed	if fix is defined as kill or restart, then
# 				cannot kill or cannot restart is return instead
# 	10	fixproc error
# 
#
# Fixes a process named "proc" by performing the specified action.  The
# actions can be check, kill, restart, exist, or fix.  The action is specified
# on the command line or is read from a default database, which describes
# the default action to take for each process.  The database format and
# the meaning of each action are described below.
# 
# database format
# ---------------
# 
# name	foo			required
# cmd	/a/b/name args		required
# min	number			optional, defaults to 1
# max	number			optional, defaults to 1
# 
# check	{null, exist, shell}	optional, defaults to exist if not defined
# [shell command		shell commands needed only if check=shell
#  ...
#  shell command
#  end_shell]			keyword end_shell marks end of shell commands
# fix	{kill, restart, shell}	required
# [shell command			shell commands needed only if fix=shell
#  ...
#  shell command
#  end_shell]			keyword end_shell marks end of shell commands
# 
# Blank lines and lines beginning with "#" are ignored.
# 
#
# Example:
# 
# name	test1
# cmd	nice /home/kong/z/test1 > /dev/null &
# max	2
# fix	shell
# 	xterm&
# 	nice /home/kong/z/test1 > /dev/null &
# 	end_shell
# 
# 
# actions
# -------
# There are 5 possible actions:  kill, restart, fix, exist, check.  Fix is
# defined to be the kill action, the restart action, or a series of shell
# commands.  Check is optionally defined in the database.  If check is not
# defined, it defaults to exist.
# 
# If the action is specified on the cmd line, it is executed regardless of
# check.  The commands executed for each action type is as follow:
# 
#   switch action:
# 	kill:
# 	  kill process, wait 5 seconds, kill -9 if still exist
# 	  if still exist
# 	    return "cannot kill"
# 	  else
# 	    return "ok"
# 
# 	restart:	
# 	  execute kill
# 	  if kill returned "cannot kill"
# 	    return "cannot kill"
# 	  restart by issuing cmd to shell
# 	  if check defined
# 	    execute check
# 	    if check succeeds
# 	      return "ok"
# 	    else
# 	      return "cannot restart"
# 
# 	fix:
# 	  if fix=kill
# 	    execute kill
# 	  else if fix=restart
# 	    execute restart
# 	  else
# 	    execute shell commands
# 	    execute check
# 
# 	check:
# 	  if check defined as null
# 	    return "fixproc error"
# 	  else
# 	    execute check
# 	    if check succeeds
# 	      return (execute exist)
# 	    return "check failed"
# 
# 	exist:
# 	  if proc exists in ps && (min <= num. of processes <= max)
# 	    return "ok"
# 	  else
# 	    return "check failed"
# 
# 
# If the action is not specified on the cmd line, the default action is the
# fix action defined in the database.  Fix is only executed if check fails:
# 
# 	if fix defined
# 	  if check is not defined as null
# 	    execute check
# 	    if check succeeds
# 	      return "ok"
# 	  execute action defined for fix  
# 	else
# 	  return "fixproc error"
# 
# 
# If proc is not specified on the command line, return "fixproc error." 
# Multiple proc's can be defined on the cmd line.   When an error occurs
# when multiple proc's are specified, the first error encountered halts the
# script.
# 
# For check shell scripts, any non-zero exit code means the check has failed.
#
#
# Timothy Kong		3/1995

use File::Temp qw(tempfile);

$database_file = '/local/etc/fixproc.conf';

$debug = 0;			# specify debug level using -dN
				# currently defined: -d1

$no_error = 0;
$check_failed_error = 1;
$cannot_restart_error = 2;
$cannot_kill_error = 3;
$cannot_fix_error = 4;
$fixproc_error = 10;

$min = 1;
$max = 1;
$cmd_line_action = '';
%min = ();
%max = ();
%cmd = (