File: nessus-update-plugins.in

package info (click to toggle)
nessus-plugins 2.2.8-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 15,508 kB
  • ctags: 251
  • sloc: sh: 8,346; ansic: 4,452; pascal: 3,089; perl: 704; makefile: 172; php: 1
file content (206 lines) | stat: -rw-r--r-- 3,803 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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh
#
# nessus-update-plugins
#
# This script will retrieve all the newest plugins from 
# www.nessus.org using the utility 'nessus-fetch'.
# 
# 
# Author  : Renaud Deraison <deraison@cvs.nessus.org>
# License : GPL (but for two lines of script, does it matter ?)
# 
#
# usage : nessus-update-plugins [-v[v]] [-h]
# 
#
# -v        : be verbose
# -vv       : be more verbose (debug)
#


#
# The command we use to retrieve the plugins
#


#-------------- DO NOT EDIT THIS FILE BEYOND THAT POINT ---------------------#



gzip=@GZIP@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
datadir=@datadir@
sysconfdir=@sysconfdir@
sharedstatedir=@sharedstatedir@
localstatedir=@localstatedir@
libdir=@libdir@
includedir=@includedir@
oldincludedir=@oldincludedir@
infodir=@infodir@
mandir=@mandir@

pluginsdir="$libdir/nessus/plugins"



case `id` in uid=0*) ;; 
   *euid=0*) ;;
   *)
    echo "only root should use nessus-update-plugins"
        exit 1
	esac
	

if [ ! -x "$bindir/nessus-fetch" ]; then
 echo "nessus-fetch(1) (part of nessus-core) is not installed on your system"
 echo "Hint (for Debian users): have you installed the nessusd package?"
 echo "Aborting"
 exit 1
fi

if [ ! -x "$gzip" ]; then
 echo "gzip is not installed on your system"
 echo "Aborting"
fi

if [ ! -r "$sysconfdir/nessus/nessusd.conf" ]; then
	if [ ! -e "$sysconfdir/nessus/nessusd.conf" ]; then
	echo "$sysconfdir/nessus/nessusd.conf does not exist!"
	echo "Do you have the nessus daemon installed?"
	else
	echo "I cannot read $sysconfdir/nessus/nessusd.conf."
	echo "Are you root?"
	fi
	exit 1
fi
newdir=`awk '/plugins_folder/ {print $3}' $sysconfdir/nessus/nessusd.conf`
test -n "$newdir" && pluginsdir="$newdir"




help_screen()
{
 echo "nessus-update-plugins 2.0.0, by Renaud Deraison <deraison@cvs.nessus.org>"
 echo
 echo
 echo "Usage : nessus-update-plugins [-v[v] [-h]"
 echo
 echo "-v              : be verbose"
 echo "-vv             : be more verbose (debug)"
 echo "-h              : this help screen"
 echo
 echo "Default action  : update the nessusd plugins"
 exit 0
}



opts=`getopt "vh" $*`

for i in $opts
do
 case $i in
 -h)
   help_screen
   ;;
   
  -v)
   if [ -z "$verbose" ];
    then
      verbose="y"
     else
       set -x
   fi
   ;;
 esac
done
 

if [ -z "$verbose" ];
then
 tar="-xf"	
else
 tar="-xvf"
fi



if [ ! -d $pluginsdir ] ; then
	echo "Plugindir $pluginsdir is not a directory!"
	exit 1
fi


	
cwd=`pwd`
tmpdir=$TEMPDIR
test -z "$tmpdir" &&
{
 tmpdir=$TMPDIR
 test -z "$tmpdir" && tmpdir=/tmp
}


mkdir -m 0700 "$tmpdir/nessus-update-plugins-$$" || {
	echo "Could not create temporary directory ($tmpdir/nessus-update-plugins-$$)"
	exit 1
}
cd "$tmpdir/nessus-update-plugins-$$"
$bindir/nessus-fetch --plugins-md5 || { 
	echo "Could not retrieve the plugins MD5"
	echo "Aborting"
	exit 1
	}

test -s "$pluginsdir/MD5" && {
	if [ -x /usr/bin/diff ];
	then 
	 diff "$pluginsdir/MD5"  all-2.0.tar.gz.md5 > /dev/null && {
	 cd "$cwd"
	 rm -rf "$tmpdir/nessus-update-plugins-$$"
	 exit 0
	}
	fi
}


$bindir/nessus-fetch --plugins || {
	echo "Could not retrieve the Nessus plugins"
	echo "Aborting"
	exit 1 
	}
	

# Check the archive signature
test -x $sbindir/nessus-check-signature && {
	$sbindir/nessus-check-signature all-2.0.tar.gz all-2.0.sig || {
		echo "Aborting"
		exit 1
		}
	}

rm -f all-2.0.sig
	
cd "$pluginsdir/"
$gzip -cd "$tmpdir/nessus-update-plugins-$$/all-2.0.tar.gz" | tar $tar - 
rm -f "$pluginsdir/MD5"
mv "$tmpdir/nessus-update-plugins-$$/all-2.0.tar.gz.md5" "$pluginsdir/MD5"

cd "$cwd"
rm -rf "$tmpdir/nessus-update-plugins-$$"

chown -R 0:0 "$pluginsdir/"


# HUP nessusd
test -f @localstatedir@/nessus/nessusd.pid && {
    pid=`cat @localstatedir@/nessus/nessusd.pid`
    kill -1 $pid 2>/dev/null
}

exit 0