File: snoopy-enable.in

package info (click to toggle)
snoopy 2.3.1-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 1,024 kB
  • sloc: ansic: 2,916; sh: 460; makefile: 384
file content (57 lines) | stat: -rwxr-xr-x 1,421 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh



# This is a script that enables snoopy system-wide.
# You have to run this script as a privileged user.
# This script is also run when you execute "make enable".



### Where is the library installed?
#
LIBDIR="@SNOOPY_LIBDIR@"



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



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



### Do the actual installation
#
COUNT=`grep -Ec "/(lib)?snoopy.so" /etc/ld.so.preload`
if [ "$COUNT" -gt "1" ]; then
    echo
    echo "SNOOPY ERROR: Multiple instances of (lib)snoopy.so found in /etc/ld.so.preload. Unable to proceed."
    echo
    exit 1
elif [ "$COUNT" -eq "1" ]; then
    echo -n "SNOOPY: Removing from /etc/ld.so.preload: "
    cat /etc/ld.so.preload | grep -E "/(lib)?snoopy.so"
    sed -i "/\/\(lib\)\?snoopy.so/d" /etc/ld.so.preload
fi
echo "SNOOPY: Adding to /etc/ld.so.preload:     $LIBDIR/libsnoopy.so"
echo "$LIBDIR/libsnoopy.so" >> /etc/ld.so.preload
echo "SNOOPY: Hint #1: Reboot your machine to load snoopy system-wide."
echo "SNOOPY: Hint #2: Check your log files for output."
echo "SNOOPY: Enabled."