Hi, wanted to share install script.
Installation script for OpenVAS/Greenbone 20.08 on Ubuntu 20.04
Thank you MaKyOtOx
Hi, wanted to share install script.
Thank you MaKyOtOx
Thank you for sharing.
Thanks for the script - but I have following error after install postgresql
yarn is already the newest version (1.22.5-1). 0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded. Reading package lists... Done Building dependency tree Reading state information... Done postgresql is already the newest version (12+214ubuntu0.1). postgresql-contrib is already the newest version (12+214ubuntu0.1). postgresql-server-dev-all is already the newest version (214ubuntu0.1). 0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded. postgres@cv002250:~$
After that the script stops. When i input “exit” the script is continue but not working anymore
postgres@cv002250:~$ exit logout createuser: error: could not connect to database template1: FATAL: role "root" does not exist createdb: error: could not connect to database template1: FATAL: role "root" does not exist psql: error: FATAL: role "root" does not exist ./gistfile1.sh: 32: create: not found ./gistfile1.sh: 33: grant: not found ./gistfile1.sh: 34: create: not found ./gistfile1.sh: 35: q: not found administrator@cv002250:~$
What is the right way - or what I doing wrong?
Hi, please comment on gist on github. I am not the author. I just share public information that helped me. Mine setup went well. I recommend running one command at a time manually. That way you can debug it and learn how it works.
Humm, not totally sure what’s going on here although the messages about postgresql already being installed suggest that the script was run on a machine that was already in use for other things. I wrote the original script that this was based on was meant to be run on a fresh Ubuntu 20.04 install.
In other words, boot from an Ubuntu Server install disk to a blank machine or VM; accept all the defaults, then download and run the script, follow the post-install instructions about rebooting and updating the scripts from the readme and you should end up with a working GVM instance that you can access with a web browser pointed at the IP address of the machine (i.e., https://“ip-address-of-machine”).
Hey Kev. Yes, I did exactly this! Fresh VM with the 20.04 ISO. I got gistfile.txt with wget, changed to root with
sudo -s and run
root@secscan01:~# bash gistfile1.txt
The script stops with the prompt
postgres@secscan01:~$ … if I type exit, this happens:
postgres@secscan01:~$ exit logout createuser: error: could not connect to database template1: FATAL: role "root" does not exist createdb: error: could not connect to database template1: FATAL: role "root" does not exist psql: error: FATAL: role "root" does not exist gistfile1.txt: line 32: create: command not found gistfile1.txt: line 33: grant: command not found gistfile1.txt: line 34: create: command not found gistfile1.txt: line 35: q: command not found
There is an issue with sudo -Hiu
root@secscan01:~# sed -n 28,35p gistfile1.txt sudo -Hiu postgres createuser gvm createdb -O gvm gvmd psql gvmd create role dba with superuser noinherit; grant dba to gvm; create extension "uuid-ossp"; \q
It is working by hand, but not in a script.
Or to make it more clear: the script jumps into the user postgres and stops waiting for input. If you hit exit, the next commands (createuser gvm…) are run in the context of root. Back in the days I found a solution to use sudo or su to switch to another user WITHIN a script and run some commands… was something with
<<EOT commands, commands EOT, but I do not find it atm.
Ah, I guess I have it…
#/bin/bash whoami useradd -m -s /bin/bash test su - test whoami echo "" echo "++++++++++++++++++++++" echo "+ vs. +" echo "++++++++++++++++++++++" echo "" whoami sudo -i -u test bash << EOF whoami EOF
My proposal would be like this (and repeat it for every su or sudo usage):
root@secscan01:~# sed -n 28,37p gistfile1.txt sudo -i -u postgres bash << EOF createuser gvm createdb -O gvm gvmd psql gvmd create role dba with superuser noinherit; grant dba to gvm; create extension "uuid-ossp"; \q exit EOF
My last hint: I guess (and I believe you) it works, if you copy and past the entire script into a root shell (gnome-terminal or putty) on the server. In that case all the new lines after su or sudo are pasted into the new spawned sessions. That’s the way how I do it at the moment.
But it is not working as, say unattended, bash script in a file, since su and sudo spawns new processes and the lines after that are not called in them. If someone wants to have that, the script has to be modified.
Nevertheless: you did a really great job with that script
Humm, Okay, so it looks like there might be an issue with the gist file that vudududu references. On line 28 it appears to hop over into the postgres user but then stops executing because it’s waiting for that user to do something. Typing exit drops it back into the root user and it carries on with the subsequent commands. They fail because the things that were supposed to be done as the postgres user weren’t done. I’d agree that posting a comment on the gist over on GitHub is probably the way to go here.
The author points to a project I have over there as one of the things that they based it on so you could give that a try too. It’s at https://github.com/yu210148/gvm_install. I haven’t gone through the gist to see how and where they differ so I don’t know what the author of it was going for when they wrote it but at a glance, it looks like there are a couple of places further down where it might run into a similar issue to the one you mentioned. For example, on line 48 it does an
su to enter a shell for the gvm user. The next line is
mkdir /tmp/gvm-source which I believe is intended to execute as the user
gvm. However, unless I’m missing something–entirely possible–it would enter the shell for the
gvm user then sit there waiting for that user to do something and not execute line 49 until that shell was terminated.