#!/bin/bash # called with 'complete', will complete the second word and return 0. if [ "$1" = "complete" ]; then compgen -W "read tail check start stop status restart list_options" "$2" exit 0 fi . `dirname $0`/functions option bin reserved_option /sbin/syslogd option server standard_option option listen_kernel boolean_option option listen_unix boolean_option 1 option console_level standard_option 2 option listen multiple_option option output standard_option ;# empty or filename or "buffer" option size standard_option 256 option keyid standard_option option rotate standard_option 1 option mark standard_option option cmdline reserved_option '$bin ${opt_console_level:+-c $opt_console_level} ${opt_kernel_symbols:+-k $opt_kernel_symbols} ${opt_mark:+-m $opt_mark}' function fct_end_section { local svcname=$1 local instname=$2 [ -n "$pidfile" ] || pidfile="/var/run/syslogd-${instname}.pid" cmdline="$bin ${pidfile:+-p $pidfile}" [ "$opt_listen_kernel" = 1 ] && cmdline="$cmdline -k ${opt_console_level:-4}" [ "$opt_listen_unix" != 1 ] && cmdline="$cmdline -u" [ -n "$opt_mark" ] && cmdline="$cmdline -m ${opt_mark}" [ -n "$opt_server" ] && cmdline="$cmdline -R $opt_server" if [ ${#opt_listen[@]} -gt 0 ]; then if [ ${#opt_listen[@]} = 1 -a "${opt_listen[*]}" = "#" ]; then # no address specified, just the "listen" keyword cmdline="$cmdline -l 0.0.0.0:514" else cmdline="$cmdline -l ${opt_listen[0]}" fi fi # check for unwanted 'k' suffix opt_size="${opt_size%k}" if [ "$opt_output" = "buffer" -o -z "$opt_output" -a -z "$opt_server" ]; then # use circular logging if no server nor output has been specified or # if "buffer" has been specified as the output. cmdline="$cmdline -C ${opt_size:-256} ${opt_keyid:+-K $opt_keyid}" elif [ -n "$opt_output" ]; then cmdline="$cmdline -O $opt_output -s ${opt_size:-256} -b ${opt_rotate:-1}" fi [ -n "$opt_output" -a -n "$opt_server" ] && cmdline="$cmdline -L" # We want to identify the daemon without any pidfile procname=syslogd return 0 } function do_read { if [ "$opt_output" = "buffer" -o -z "$opt_output" -a -z "$opt_server" ]; then # use circular logging if no server nor output has been specified or # if "buffer" has been specified as the output. logread ${opt_keyid:+-K $opt_keyid} elif [ -n "$opt_output" ]; then cat "$opt_output" fi } function do_tail { if [ "$opt_output" = "buffer" -o -z "$opt_output" -a -z "$opt_server" ]; then # use circular logging if no server nor output has been specified or # if "buffer" has been specified as the output. logread -f ${opt_keyid:+-K $opt_keyid} elif [ -n "$opt_output" ]; then tail -f "$opt_output" fi } load_config