File: snoopy-install.sh

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 (169 lines) | stat: -rwxr-xr-x 4,442 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash



### Configuration
#
SNOOPY_DOWNLOAD_URI_PREFIX="http://source.a2o.si/download/snoopy"
SNOOPY_INSTALL_LOGFILE="`pwd`/snoopy-install.log"



### Check if running as root
#
if [ "`id -u`" != "0" ]; then
    echo "SNOOPY INSTALL ERROR: This installation must be run as root."
    echo "Hint: 'sudo COMMAND' perhaps?"
    exit 1
fi



### Install distro-dependent build prerequisites
#
echo "SNOOPY INSTALL: Installing distro-specific packages 'gcc' and 'make'..."
if [ -f /etc/debian_version ]; then
    # Debian, Ubuntu
    # About /dev/null: http://askubuntu.com/questions/372810/how-to-prevent-script-not-to-stop-after-apt-get
    apt-get -y install gcc gzip make tar wget < "/dev/null"
elif [ -f /etc/redhat-release ]; then
    # RHEL, Fedora, CentOS
    yum install -y gcc gzip make tar wget
else
    # Check if gcc and make are present
    if ! which which &> /dev/null; then
        echo "SNOOPY INSTALL ERROR: 'which' program not found!"
        echo "SNOOPY INSTALL ERROR: Install it and rerun this installer."
        exit 1
    fi

    if ! which gcc &> /dev/null; then
        echo "SNOOPY INSTALL ERROR: GCC compiler not found!"
        echo "SNOOPY INSTALL ERROR: Install it and rerun this installer."
        exit 1
    fi

    if ! which make &> /dev/null; then
        echo "SNOOPY INSTALL ERROR: 'make' program not found!"
        echo "SNOOPY INSTALL ERROR: Install it and rerun this installer."
        exit 1
    fi

    if ! which tar &> /dev/null; then
        echo "SNOOPY INSTALL ERROR: 'tar' program not found!"
        echo "SNOOPY INSTALL ERROR: Install it and rerun this installer."
        exit 1
    fi

    if ! which gzip &> /dev/null; then
        echo "SNOOPY INSTALL ERROR: 'gzip' program not found!"
        echo "SNOOPY INSTALL ERROR: Install it and rerun this installer."
        exit 1
    fi
fi



### Start bash subshell, to evaluate potential errors
#
(
set -e
set -u



### Starting installation
#
rm -f $SNOOPY_INSTALL_LOGFILE
touch $SNOOPY_INSTALL_LOGFILE
echo "SNOOPY INSTALL: Starting installation, log file name: $SNOOPY_INSTALL_LOGFILE"



### Get last stable Snoopy release
#
echo -n "SNOOPY INSTALL: Getting latest Snoopy version: "
SNOOPY_PACKAGE_FILENAME=`wget -q -O - $SNOOPY_DOWNLOAD_URI_PREFIX/snoopy-latest-package-filename.txt`
SNOOPY_PACKAGE_DIRNAME=`echo "$SNOOPY_PACKAGE_FILENAME" | sed -e 's/\.tar.gz$//'`
echo "$SNOOPY_PACKAGE_FILENAME"



### Download Snoopy package
#
echo -n "SNOOPY INSTALL: Downloading $SNOOPY_DOWNLOAD_URI_PREFIX/$SNOOPY_PACKAGE_FILENAME... "
rm -f $SNOOPY_PACKAGE_FILENAME
wget $SNOOPY_DOWNLOAD_URI_PREFIX/$SNOOPY_PACKAGE_FILENAME >> $SNOOPY_INSTALL_LOGFILE 2>&1
echo "done."



### Untar, build and configure
#
echo -n "SNOOPY INSTALL: Unpacking $SNOOPY_PACKAGE_FILENAME... "
rm -rf $SNOOPY_PACKAGE_DIRNAME
tar -xzf $SNOOPY_PACKAGE_FILENAME
cd $SNOOPY_PACKAGE_DIRNAME
echo "done."



echo -n "SNOOPY INSTALL: Configuring... "
./configure --enable-config-file --sysconfdir=/etc --enable-filtering >> $SNOOPY_INSTALL_LOGFILE 2>&1
echo "done."

echo -n "SNOOPY INSTALL: Building... "
make         >> $SNOOPY_INSTALL_LOGFILE 2>&1
echo "done."

echo -n "SNOOPY INSTALL: Installing... "
make install >> $SNOOPY_INSTALL_LOGFILE 2>&1
echo "done."

echo -n "SNOOPY INSTALL: Enabling... "
make enable  >> $SNOOPY_INSTALL_LOGFILE 2>&1
echo "done."



### Tell the user what to do next
#
echo
echo "SNOOPY LOGGER is now installed and enabled."
echo
echo "TIP #1: If Snoopy is to be enabled for all processes, you need"
echo "        to restart your system, or at least all services on it."
echo
echo "TIP #2: If you ever need to disable Snoopy, you should use provided"
echo "        'snoopy-disable' script. Use 'snoopy-enable' to reenable it."
echo
echo "TIP #3: Snoopy output can usually be found somewhere in /var/log/*"
echo "        Check your syslog configuration for details."
echo
echo "TIP #4: Configuration file location: /etc/snoopy.ini"
echo "        See included comments for additional configuration options."
echo
echo "Snoopy wishes you a happy logging experience:)"
echo



### End bash subshell
#
)
if [ "$?" != "0" ]; then
    echo
    echo
    echo "Last 5 lines of Snoopy installation log file:"
    tail -n5 $SNOOPY_INSTALL_LOGFILE
    echo
    echo "SNOOPY INSTALL ERROR: Something weird happened!"
    echo "SNOOPY INSTALL ERROR: Please inspect log file for details ($SNOOPY_INSTALL_LOGFILE)"
    exit 1
fi



### All done
#
true