diff --git a/dhcp/Dockerfile b/dhcp/Dockerfile deleted file mode 100644 index 7962d2e..0000000 --- a/dhcp/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM debian:buster -RUN apt update && apt install -y isc-dhcp-server -RUN mkdir -p /var/lib/dhcp && touch /var/lib/dhcp/dhcpd.leases -COPY dhcpd.conf /etc/dhcp/dhcpd.conf -COPY run.sh /run.sh -RUN chmod +x /run.sh -ENV INTERFACE=eth0 -CMD ["/run.sh"] diff --git a/dhcp/Readme.md b/dhcp/Readme.md deleted file mode 100644 index d0e2d2c..0000000 --- a/dhcp/Readme.md +++ /dev/null @@ -1,5 +0,0 @@ -##DHCP Docker -Example run command: -``` -docker run --privileged --net host -it -e"INTERFACE=enp0s31f6" images/dhcp -``` diff --git a/linux/Readme.md b/linux/Readme.md index 6b03b23..18e9f1f 100644 --- a/linux/Readme.md +++ b/linux/Readme.md @@ -1,2 +1,18 @@ # Linux for cloning -Run `make` to build. + +## About +`images/linux` is Debian 10 system adapted for network booting and sending/receiving disk images via UDP. It is designed to work together with `images/server`. + +On boot, full system image will be downloaded, mounted read only and will become new root (see `src/etc/initramfs-tools`). User will be presented with menu allowing sending/receiving images and root shell access (see `src/scripts`). Whole environment will be read-only, except `/tmp` where writeable `tmpfs` will be mounted. + +## Installation +To build just run: +``` +sudo make +``` +This will download base system to `build/cache`, copy it to `build/rootfs` and continue build there. After successful completion of this command, a fully functional linux root filesystem will be present in `build/rootfs`. + +`debootstrap` is required to download base Linux system. When more advanced (encrypted home etc.) partition setup is used, one might need to remount the partition on which the build is taking place with `exec` and `dev` before running `make`: +``` +sudo mount -i -o remount,exec,dev /home/whatever +``` diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..01e76c4 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:buster + +RUN apt update +RUN apt install -y supervisor +RUN apt install -y isc-dhcp-server +RUN apt install -y tftpd-hpa +RUN apt install -y busybox + +# Supervisor +COPY supervisor.conf /supervisor.conf + +# DHCP server +RUN mkdir -p /var/lib/dhcp && touch /var/lib/dhcp/dhcpd.leases +COPY dhcpd.conf /etc/dhcp/dhcpd.conf + +COPY run.sh /run.sh +RUN chmod +x /run.sh +ENV INTERFACE=eth0 +CMD ["/run.sh"] diff --git a/dhcp/dhcpd.conf b/server/dhcpd.conf similarity index 100% rename from dhcp/dhcpd.conf rename to server/dhcpd.conf diff --git a/dhcp/run.sh b/server/run.sh similarity index 64% rename from dhcp/run.sh rename to server/run.sh index dc86f18..303c094 100644 --- a/dhcp/run.sh +++ b/server/run.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e + +# Inteface setup ip addr flush dev $INTERFACE ip addr add 192.168.14.2/24 dev $INTERFACE ip link set dev $INTERFACE up -dhcpd -d --no-pid $INTERFACE + +# Supervisor +supervisord -n -c /supervisor.conf diff --git a/server/supervisor.conf b/server/supervisor.conf new file mode 100644 index 0000000..12e7556 --- /dev/null +++ b/server/supervisor.conf @@ -0,0 +1,17 @@ +[supervisord] +loglevel = DEBUG + +[program:dhcp] +command = dhcpd -d --no-pid %(ENV_INTERFACE)s +autostart = true +autorestart = true + +[program:tftp] +command = in.tftpd -L -s /tftpboot +autostart = true +autorestart = true + +[program:http] +command = busybox httpd -f -p 8014 -h /tftpboot +autostart = true +autorestart = true diff --git a/tftp/Dockerfile b/tftp/Dockerfile deleted file mode 100644 index d6ce4d4..0000000 --- a/tftp/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM debian:buster -RUN apt update && apt install -y xinetd tftpd-hpa busybox -COPY tftp.xinetd.conf /etc/xinetd.d/tftp -COPY http.xinetd.conf /etc/xinetd.d/http -RUN echo "http-boot 8014/tcp" >> /etc/services -CMD ["script", "-c", "/usr/sbin/xinetd -d"] diff --git a/tftp/Readme.md b/tftp/Readme.md deleted file mode 100644 index 2270025..0000000 --- a/tftp/Readme.md +++ /dev/null @@ -1,10 +0,0 @@ -##TFTP Docker - -Starts TFTP server serving files from `/tftpboot`. - -A directory to serve files from must be bound to `/tftpboot` on run. - -Example run command: -``` -docker run --net host -v /path/to/your/files:/tftpboot images/tftp -``` diff --git a/tftp/http.xinetd.conf b/tftp/http.xinetd.conf deleted file mode 100644 index 92d68ed..0000000 --- a/tftp/http.xinetd.conf +++ /dev/null @@ -1,11 +0,0 @@ -service http-boot -{ - socket_type = stream - protocol = tcp - wait = no - user = root - server = /bin/busybox - server_args = httpd -if -h /tftpboot - port = 8014 - flags = IPv4 -} diff --git a/tftp/tftp.xinetd.conf b/tftp/tftp.xinetd.conf deleted file mode 100644 index 3443686..0000000 --- a/tftp/tftp.xinetd.conf +++ /dev/null @@ -1,13 +0,0 @@ -service tftp -{ - socket_type = dgram - protocol = udp - wait = yes - user = root - server = /usr/sbin/in.tftpd - server_args = -s /tftpboot - disable = no - per_source = 11 - cps = 100 2 - flags = IPv4 -}