Skip to content

Instantly share code, notes, and snippets.

@jnewland
Created June 30, 2011 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnewland/1055451 to your computer and use it in GitHub Desktop.
Save jnewland/1055451 to your computer and use it in GitHub Desktop.
#!/bin/bash
prog="remote_syslog"
config="/etc/log_files.yml"
pid_dir="/var/run"
EXTRAOPTIONS=""
pid_file="$pid_dir/$prog.pid"
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
RETVAL=0
is_running(){
[ -e $pid_file ]
}
start(){
echo -n $"Starting $prog: "
unset HOME MAIL USER USERNAME
$prog -c $config -P $pid_dir "$EXTRAOPTIONS"
RETVAL=$?
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $prog: "
if (is_running); then
kill `cat $pid_file`
RETVAL=$?
echo
return $RETVAL
else
echo "$pid_file not found"
fi
}
status(){
echo -n $"Checking for $pid_file: "
if (is_running); then
echo "found"
else
echo "not found"
fi
}
reload(){
restart
}
restart(){
stop
start
}
condrestart(){
is_running && restart
return 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=1
esac
exit $RETVAL
module Moonshine
module RemoteSyslog
def remote_syslog
gem 'remote_syslog', :ensure => :installed
file '/etc/init.d/remote_syslog',
:ensure => :present,
:content => template(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'remote_syslog.init.d'), binding),
:mode => '755'
service 'remote_syslog',
:ensure => :running,
:enable => true,
:require => [package('remote_syslog'), file('/etc/init.d/remote_syslog')],
:subscribe => file('/etc/log_files.yml')
file '/etc/log_files.yml',
:ensure => :present,
:mode => '644',
:content => remote_syslog_config
end
def remote_syslog_config
config = configuration[:remote_syslog]
new_config = {}
config.each_pair do |k,v|
if config[k].respond_to?(:keys)
new_config[k] = config[k].to_hash
else
new_config[k] = config[k]
end
end
new_config.to_hash.to_yaml
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment