-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_shell.sh
69 lines (58 loc) · 2.16 KB
/
docker_shell.sh
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
#!/bin/bash
chmod a+rwx /tmp
chmod a+t /tmp
if [ ! -e "/opt/nessus/sbin/nessuscli" ]; then
echo "Decompressing the Nessus file archive"
tar xvzf /opt+nessus.tar.gz
echo "Decompression completed"
fi
if [ $NESSUS_BACKUP_FILE == "" ] || [ $NESSUS_BACKUP_FILE == "NONE" ]; then
echo "First installation"
echo "Starting Nessus ..."
supervisord -c /etc/supervisord.conf
exit 0
fi
if [ ! -e "/home/nessus/.git" ] && [ $NESSUS_BACKUP_GIT != "" ]; then
echo "Cloning the backup repository"
git clone $NESSUS_BACKUP_GIT "/home/nessus"
echo "Cloning completed"
fi
echo "Checking the existence of /home/nessus/$NESSUS_BACKUP_FILE"
if [ ! -e "/home/nessus/$NESSUS_BACKUP_FILE" ]; then
echo "The file /home/nessus/$NESSUS_BACKUP_FILE does not exist!"
echo "Stopping ..."
exit 1
else
echo "/home/nessus/$NESSUS_BACKUP_FILE exists."
fi
if md5sum -c token.md5 < "/home/nessus/$NESSUS_BACKUP_FILE" ; then
echo "Archive already restored."
echo "Starting Nessus ..."
supervisord -c /etc/supervisord.conf
exit 0
else
# Removing files causing the error of the nessusd service already started
rm -f "/opt/nessus/var/nessus/nessusd.pid" "/opt/nessus/var/nessus/nessus-service.pid"
echo "Restoring the archive ..."
if /opt/nessus/sbin/nessuscli backup --restore "/home/nessus/$NESSUS_BACKUP_FILE" ; then
echo "Archive restored!"
echo "Checking the backup user ..."
MY_NESSUS_USER=$(/opt/nessus/sbin/nessuscli lsuser)
echo "Checking the current user ..."
if [ $MY_NESSUS_USER != $USERNAME ]; then
echo "Error : Unable to modify the password for $USERNAME!"
echo "The user of the restored backup is $MY_NESSUS_USER."
echo "Please modify 'USERNAME' to match the backup to be restored. Stopping."
exit 1
fi
echo "Creating the checksum ..."
md5sum < "/home/nessus/$NESSUS_BACKUP_FILE" > "/home/nessus/token.md5"
echo "Checksum created!"
echo "Starting Nessus ..."
supervisord -c /etc/supervisord.conf
exit 0
else
echo "Restoration error... Stopping"
exit 1
fi
fi