File: enable.sh

package info (click to toggle)
snoopy 1.8.0-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 284 kB
  • ctags: 12
  • sloc: ansic: 158; sh: 125; makefile: 58
file content (41 lines) | stat: -rwxr-xr-x 1,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

# A script that enables snoopy logging for system wide installation.
# You have to run it as privileged user.
# $Id: enable.sh 18 2010-02-10 01:44:14Z bostjanskufca $



### Where is the library installed?
LIBDIR=$1
if [ "x$LIBDIR" == "x" ]; then
    echo "ERROR: No argument given, libdir expected"
    exit 1
fi



### Check snoopy installation
if [ ! -x $LIBDIR/snoopy.so ]; then
    echo "ERROR: $LIBDIR/snoopy.so is not installed or is not executable"
    exit 1
fi



### Check user that is running this script
touch /etc/ld.so.preload
if [ ! -w /etc/ld.so.preload ]; then
    echo 'ERROR: /etc/ld.so.preload not writable - are you running this script as a unprivileged user?'
    exit 1
fi



### Do the actual install
if [ `grep -c "^$LIBDIR/snoopy.so"   /etc/ld.so.preload` == 0 ]; then
    echo "$LIBDIR/snoopy.so" >> /etc/ld.so.preload
    echo "Snoopy enabled in /etc/ld.so.preload. Check syslog messages for output."
else
    echo "Snoopy already enabled in /etc/ld.so.preload. Check syslog messages for output."
fi