aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadd-syslog4
-rwxr-xr-xdel-syslog44
2 files changed, 32 insertions, 16 deletions
diff --git a/add-syslog b/add-syslog
index d1d0918..c3f8da1 100755
--- a/add-syslog
+++ b/add-syslog
@@ -170,7 +170,9 @@ fi
if [ -f /etc/syslog-ng.conf ]; then
config=`sed "s/#.*$//g" /etc/syslog-ng.conf`
add_blank_line /etc/syslog-ng.conf
- if ! sed "s/#.*$//g" /etc/syslog-ng.conf | grep -q "$source"; then
+ if [ -z "$source" ]; then
+ from=`echo $config | sed -n "s:\(.*source[[:space:]]\+\)\([[:alnum:]]\+\)\(.*/dev/log.*\):\2:p"`
+ elif ! sed "s/#.*$//g" /etc/syslog-ng.conf | grep -q "$source"; then
if [ -n "$facility" -o -n "$level_begin" -a -n "$logfile" ]; then
echo "source $pkg { unix-stream (\"$source\"); };" >> /etc/syslog-ng.conf
from=$pkg
diff --git a/del-syslog b/del-syslog
index 441a8f2..79d2fff 100755
--- a/del-syslog
+++ b/del-syslog
@@ -66,9 +66,14 @@ EOF
}
+# Below there are replacements on the form:
+# `echo "$1" | sed "s/\\\*/\\\\\*/g"`
+# They escape '*' because they are used inside the sed scripts and must not be
+# interpreted as a regular expression/wildcard, as part of literal names.
+
delete_destination() {
-local name=$1
+local name=`echo "$1" | sed "s/\\\*/\\\\\*/g"`
local file=$2
_del_destination_sed $name $file | sed -i -f - /etc/syslog-ng.conf
@@ -93,9 +98,9 @@ EOF
delete_filter() {
-local name=$1
+local name=`echo "$1" | sed "s/\\\*/\\\\\*/g"`
local facility=$2
-local level=$3
+local level=`echo "$3" | sed "s/\\\*/\\\\\*/g"`
_del_filter_sed $name $facility $level | sed -i -f - /etc/syslog-ng.conf
}
@@ -122,8 +127,8 @@ EOF
delete_log() {
local source=$1
-local filter=$2
-local destination=$3
+local filter=`echo "$2" | sed "s/\\\*/\\\\\*/g"`
+local destination=`echo "$3" | sed "s/\\\*/\\\\\*/g"`
_del_log_sed $source $filter $destination | sed -i -f - /etc/syslog-ng.conf
}
@@ -150,7 +155,7 @@ fi
if [ -z "$level_begin" -a -n "$level_end" ]; then
level_begin=`echo $priority_order | cut -d " " -f 1`
elif [ -n "$level_begin" -a -z "$level_end" ]; then
- level_end=$level_begin
+ level_end="$level_begin"
fi
if [ "$level_begin" = "debug" -a "$level_end" = "*" -o "$level_begin" = "*" -a "$level_end" = "emerg" ]; then
level_begin="*"
@@ -174,14 +179,14 @@ if [ -f /etc/syslog.conf ]; then
/etc/sysconfig/syslog
fi
if [ -n "$facility" -a -n "$level_begin" -a -n "$logfile" ]; then
- lvl_begin=$level_begin
- lvl_end=$level_end
+ lvl_begin="$level_begin"
+ lvl_end="$level_end"
if [ "$level_begin" = "*" -a "$level_end" = "*" -o \
"$level_begin" = "debug" -a "$level_end" = "emerge" -o "$level_end" = "panic" ]; then
lnum=`grep -n "$logfile" /etc/syslog.conf | sed "s/#.*$//g" | grep "$facility\.\*" | cut -d ":" -f 1`;
[ -n "$lnum" ] && sed -i "${lnum}d;" /etc/syslog.conf || :
- lvl_begin=debug
- lvl_end=emerg
+ lvl_begin="debug"
+ lvl_end="emerg"
fi
levels=`echo $priority_order | sed -n "s:\([^[:space:]]*$lvl_begin.*\):\1:p"`
levels=`echo $levels | sed -n "s:\(.*$lvl_end[^[:space:]]*\):\1:p"`
@@ -218,21 +223,21 @@ if [ -f /etc/syslog-ng.conf ]; then
for level in $priority_order; do
if [ -n "$level_begin" ]; then
- if echo $level | grep -q $level_begin; then
+ if echo $level | grep -q "$level_begin"; then
lvl=`echo $level | sed "s:,: :"`
c=0
for depr in $lvl; do
- lvl_start[$c]=$depr
+ lvl_start[$c]="$depr"
let c=c+1
done
fi
fi
if [ -n "$level_end" ]; then
- if echo $level | grep -q $level_end; then
+ if echo $level | grep -q "$level_end"; then
lvl=`echo $level | sed "s:,: :"`
c=0
for depr in $lvl; do
- lvl_end[$c]=$depr
+ lvl_end[$c]="$depr"
let c=c+1
done
fi
@@ -241,7 +246,16 @@ if [ -f /etc/syslog-ng.conf ]; then
# We must test all possibilities for the given range, as also
# test for deprecated name levels.
- if [ "${lvl_start[0]}" = "${lvl_end[0]}" -o "${lvl_start[0]}" = "${lvl_end[1]}" ]; then
+ if [ "$level_begin" = "*" -a "$level_end" = "*" -o \
+ "$level_begin" = "debug" -a "$level_end" = "emerg" -o "$level_end" = "panic" ]; then
+ lvl_range[0]="*"
+ lvl_range[1]="debug..emerg"
+ lvl_range[2]="debug..panic"
+ lvl_label[0]="*"
+ lvl_label[1]="*_*"
+ lvl_label[2]="debug_emerg"
+ lvl_label[3]="debug_panic"
+ elif [ "${lvl_start[0]}" = "${lvl_end[0]}" -o "${lvl_start[0]}" = "${lvl_end[1]}" ]; then
lvl_range[0]="${lvl_start[0]}"
lvl_range[1]="${lvl_end[0]}"
lvl_label[0]="${lvl_start[0]}"