diff --git a/README.md b/README.md index 36bbb02..f8bfb19 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ However, please use `docker exec -it target bash` preferrebly to interact with t When done, the container can be stopped with `docker stop target`. ## Available images & tags +- Generic (needs to be built manually, see [applications/generic](applications/generic/)) - [Home Assistant](https://ghcr.io/greenbone/vt-test-environments/home-assistant) (`home-assistant`, run with `--network host`, when requiring e.g. mDNS capabilities) - `2023.5.2` - [AlmaLinux](https://ghcr.io/greenbone/vt-test-environments/almalinux) (`almalinux`) diff --git a/applications/generic/Dockerfile b/applications/generic/Dockerfile new file mode 100644 index 0000000..22690f1 --- /dev/null +++ b/applications/generic/Dockerfile @@ -0,0 +1,30 @@ +ARG BASEIMAGE +ARG TAG + +FROM ghcr.io/greenbone/vt-test-environments/${BASEIMAGE}:${TAG} +ARG UPDATED=true +ARG TAG + +# Install dependencies +RUN apt-get update \ + && if [ "$UPDATED" = true ]; then apt-get upgrade -y; fi \ + && apt-get install -y apache2 php mariadb-server samba \ + && rm -rf /var/lib/apt/lists/* + +# Configure Apache and PHP +RUN sed -i "/^expose_php/s/=.*/= On/" /etc/php/*/apache2/php.ini \ + && sed -i "/^ServerTokens/s/ .*/ Full/" /etc/apache2/conf-enabled/security.conf \ + && echo '' > /var/www/html/index.php + +# Configure MariaDB +RUN sed -i "/^bind-address/s/= .*/= */" /etc/mysql/mariadb.conf.d/50-server.cnf \ + && service mariadb start || service mysql start \ + && echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;" | mysql + +# Configure Samba +RUN sed -i "/^\[global\]/a\ server min protocol = NT1" /etc/samba/smb.conf + +ADD init.sh / +CMD [ "/init.sh" ] + +EXPOSE 80 445 3306 diff --git a/applications/generic/README.md b/applications/generic/README.md new file mode 100644 index 0000000..16d77a1 --- /dev/null +++ b/applications/generic/README.md @@ -0,0 +1,36 @@ + +# vt-test-environments/applications/generic + +This image contains generic services to test OS detection VTs. It's based on our Debian-based test images. + +## Services installed + +- `openssh-server` (port 22, inherited from the base image) +- `apache2` (port 80) +- `php` +- `mariadb-server` (port 3306) +- `samba` (port 445) + +## Build + +The Dockerfile requires two build arguments: +- `BASEIMAGE`: The name of the base image to build upon +- `TAG`: The tag of the base image to build upon + +For example, to build the generic test image for Debian trixie (`ghcr.io/greenbone/vt-test-environments/debian:trixie`) and save under `generic:debian_trixie` run: + +``` +docker build --pull --build-arg BASEIMAGE=debian --build-arg TAG=trixie applications/generic -t generic:debian_trixie +``` + +You can use any Debian-based base image from [vt-test-environments](https://github.com/orgs/greenbone/packages?repo_name=vt-test-environments). + + +## Usage +For the example above, run: + +``` +docker run --rm -it -p 2222:22 -p 80:80 -p 445:445 -p 3306:3306 generic:debian_trixie +``` + +Note: In this example, I mapped all container ports to the host, except for port 22, which is mapped to port 2222 on the host. diff --git a/applications/generic/init.sh b/applications/generic/init.sh new file mode 100755 index 0000000..2417d3a --- /dev/null +++ b/applications/generic/init.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +source /etc/os-release +# In Debian 10 and Ubuntu 20.10 or earlier the init file is called differently +if [ "$ID" = "debian" ] && dpkg --compare-versions "$VERSION_ID" le 10 \ + || [ "$ID" = "ubuntu" ] && dpkg --compare-versions "$VERSION_ID" le 20.10 +then + service mysql start +else + service mariadb start +fi + + +for service in ssh apache2 smbd +do + service $service start +done + +echo "Ready!" + +sleep infinity