Skip to content

Commit c9014a9

Browse files
Working on updater
1 parent e153973 commit c9014a9

File tree

1 file changed

+78
-40
lines changed

1 file changed

+78
-40
lines changed

vasctl

+78-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /bin/bash
22

3+
#Version
34
version="1.0"
45

56
#root init vasctl
@@ -18,54 +19,91 @@ if [ "$1" = "" ] || [ "$1" = "-h" ]; then
1819
echo "Debian: # vasctl install debian"
1920
echo "Arch: # vasctl install arch"
2021
echo ""
21-
echo "First installation"
22-
echo "$ get-waterfox download >>> Download the current Waterfox Tarball >>> -d"
23-
echo "# get-waterfox install >>> Install the Waterfox Tarball & create all links etc >>> -i"
22+
echo "Daemon control"
23+
echo "Start all daemons: # vasctl start debian >>> -r"
24+
echo "Stop all daemons : # vasctl stop >>> -x"
2425
echo ""
25-
echo "General commands"
26-
echo "# get-waterfox update >>> Update Waterfox >>> -u"
27-
echo "$ get-waterfox cleanup >>> Delete old waterfox tarball >>> -C"
28-
echo "$ get-waterfox checkupdate >>> Shows if a Waterfox update is available >>> -c"
29-
echo "$ get-waterfox version >>> Print version of get-waterfox >>> -v"
30-
echo ""
31-
echo "Remove Waterfox"
32-
echo "# get-waterfox remove >>> Remove Waterfox complete >>> -r"
26+
echo "Update OpenVAS"
27+
echo "# vasctl update >>> -u"
3328
echo ""
3429
echo "Use '-h' to show this help"
35-
echo "Please run the commands this way: init; download; install"
30+
echo "Please run the commands this way: install; update; start; stop"
3631
exit
3732
fi
3833

3934
#Install
4035
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
41-
echo "Installing vasctl $version for Debian!"
42-
echo "[INFO] Updating apt ..."
43-
apt update
44-
echo "[INFO] Installing packages ..."
45-
apt install openvas -y
36+
#Debian
37+
if [ "$2" = "debian" ]; then
38+
echo "Installing OpenVAS for Debian!"
39+
echo "[INFO] Updating apt ..."
40+
apt update
41+
echo "[INFO] Installing packages ..."
42+
echo "[INFO] Please choose yes for UNIX socket later ..."
43+
read -n 1 -s -p "[INFO] Press any key to continue .."
44+
echo ""
45+
apt install openvas -y
46+
fi
47+
#Arch
48+
if [ "$2" = "arch" ]; then
49+
echo "Installing OpenVAS for Arch!"
50+
echo "kb_location = /var/lib/redis/redis.sock" > /etc/openvas/openvassd.conf
51+
fi
52+
echo "[INFO] Configuring the environment ..."
53+
echo $(cat /etc/redis.conf) >> /etc/redis.vasctl.bk
54+
echo "unixsocket /var/lib/redis/redis.sock" > /etc/redis.conf
55+
echo "unixsocketperm 700" >> /etc/redis.conf
56+
echo "port 0" >> /etc/redis.conf
57+
echo "timeout 0" >> /etc/redis.conf
58+
echo "databases 128" >> /etc/redis.conf
59+
systemctl start openvas-scanner.service
60+
openvasmd --create-user=admin --role=Admin
61+
echo "[INFO] Generating random password for user 'Admin' ..."
62+
randompass="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')"
63+
openvasmd --user=admin --new-password=$randompass
64+
echo "[!ALERT!] CHOOSEN PASSWORD: $randompass <-- write it down!"
65+
echo "[INFO] Installation done!"
4666
exit
4767
fi
4868

49-
echo "" > /etc/redis.vasctl.bk
50-
echo $(cat /etc/redis.conf) >> /etc/redis.vasctl.bk
51-
echo "unixsocket /var/lib/redis/redis.sock" > /etc/redis.conf
52-
echo "unixsocketperm 700" >> /etc/redis.conf
53-
echo "port 0" >> /etc/redis.conf
54-
echo "timeout 0" >> /etc/redis.conf
55-
echo "databases 128" >> /etc/redis.conf
56-
echo "kb_location = /var/lib/redis/redis.sock" > /etc/openvas/openvassd.conf
57-
systemctl start redis.service
58-
openvas-manage-certs -a
59-
greenbone-nvt-sync
60-
greenbone-scapdata-sync
61-
greenbone-certdata-sync
62-
systemctl start openvas-scanner.service
63-
openvasmd --rebuild --progress
64-
echo "[INFO] Setting up user stuff ..."
65-
openvasmd --create-user=admin --role=Admin
66-
echo "[INFO] Generating random password for session ..."
67-
randompass="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')"
68-
openvasmd --user=admin --new-password=$randompass
69-
systemctl start openvasmd.service
70-
openvasmd -p 9390 -a 127.0.0.1
71-
gsad -f --listen=127.0.0.1 --mlisten=127.0.0.1 --mport=9390
69+
#Run
70+
if [ "$1" = "start" ] || [ "$1" = "-r" ]; then
71+
echo "[INFO] Starting Redis.service"
72+
systemctl start redis.service
73+
echo "[INFO] Starting openvasmd"
74+
openvasmd -p 9390 -a 127.0.0.1
75+
echo "[INFO] Starting gsad"
76+
gsad -f --listen=127.0.0.1 --mlisten=127.0.0.1 --mport=9390
77+
echo "[DONE] Connect to 127.0.0.1:9390"
78+
exit
79+
fi
80+
81+
#Stop
82+
if [ "$1" = "stop" ] || [ "$1" = "-x" ]; then
83+
echo "[INFO] Stopping Redis.service"
84+
systemctl stop redis.service
85+
echo "[INFO] Killing openvasmd"
86+
killall openvasmd -9
87+
echo "[INFO] Killing gsad"
88+
killall gsad -9
89+
echo "[DONE] Ready."
90+
exit
91+
fi
92+
93+
#Update
94+
if [ "$1" = "update" ] || [ "$1" = "-u" ]; then
95+
echo "[INFO] Updating please wait ..."
96+
#Debian
97+
if [ "$2" = "debian" ]; then
98+
openvas-certdata-sync
99+
fi
100+
#Arch
101+
if [ "$2" = "arch" ]; then
102+
openvas-manage-certs -a
103+
greenbone-nvt-sync
104+
greenbone-scapdata-sync
105+
greenbone-certdata-sync
106+
fi
107+
echo "[INFO] Ready."
108+
exit
109+
fi

0 commit comments

Comments
 (0)