From 6091057bcbcbc88b8b9954479d91fda8e118838c Mon Sep 17 00:00:00 2001 From: Florent Gluck <florent.gluck@hesge.ch> Date: Mon, 22 Jul 2024 02:41:17 +0200 Subject: [PATCH] ongoing work on fully working live_exam_os generator --- live_exam_os/Dockerfile | 6 ++--- live_exam_os/build_live_exam_iso | 4 +-- live_exam_os/config/Xsession | 6 +++++ live_exam_os/config/live-exam-hook | 40 +++++++++-------------------- src/client/nexus-exam/nexus-exam.go | 4 ++- 5 files changed, 26 insertions(+), 34 deletions(-) create mode 100644 live_exam_os/config/Xsession diff --git a/live_exam_os/Dockerfile b/live_exam_os/Dockerfile index 620dfeae..96bcbdda 100644 --- a/live_exam_os/Dockerfile +++ b/live_exam_os/Dockerfile @@ -8,7 +8,6 @@ RUN apt-get update && apt-get install -y \ ARG server_ip ARG server_port ARG config_dir - #ARG nexus_cert WORKDIR /live-default @@ -26,6 +25,8 @@ ADD ${config_dir}/keyboard config/includes.chroot/etc/default/ ADD ${config_dir}/nexus-exam config/includes.chroot/usr/local/bin/ ADD ${config_dir}/nexus-exam.desktop config/includes.chroot/etc/xdg/autostart/ RUN mkdir config/includes.chroot/etc/skel/ +# ADD ${config_dir}/Xsession config/includes.chroot/etc/X11/Xsession.d/99x-user_session +ADD ${config_dir}/Xsession config/includes.chroot/etc/skel/.xsessionrc #RUN echo "export NEXUS_SERVER=${server_ip}\nexport NEXUS_CERT=/etc/ssl/certs/nexus-server.pem\n" >> config/includes.chroot/etc/skel/.xsessionrc @@ -52,8 +53,7 @@ ADD ${config_dir}/isolinux_stdmenu.cfg config/includes.binary/isolinux/stdmenu.c # script hook ran at boot time (install system wide cert and firewall) ADD ${config_dir}/live-exam-hook config/includes.chroot/lib/live/config/9999-custom # update server destination from docker's variable (all others IP are banned) -RUN echo "firewall ${server_ip}\n" >> config/includes.chroot/lib/live/config/9999-custom -RUN sed s,_SERVER_PORT_,${server_port},g config/includes.chroot/lib/live/config/9999-custom > config/includes.chroot/lib/live/config/9999-custom.new && mv config/includes.chroot/lib/live/config/9999-custom.new config/includes.chroot/lib/live/config/9999-custom +RUN echo "firewall ${server_ip} ${server_port}\n" >> config/includes.chroot/lib/live/config/9999-custom # install wifi template ADD ${config_dir}/WIFI.nmconnection config/includes.chroot/etc/NetworkManager/system-connections/ diff --git a/live_exam_os/build_live_exam_iso b/live_exam_os/build_live_exam_iso index 844324f8..71b86377 100755 --- a/live_exam_os/build_live_exam_iso +++ b/live_exam_os/build_live_exam_iso @@ -61,11 +61,11 @@ error=0 echo "Building nexus-exam ..." # This script compiles and copies nexus-exam into the current dir -nexus_exam_builder/build_nexus_exam $SERVER_IP $CERT $EXAM_USER $EXAM_PWD || abort +nexus_exam_builder/build_nexus_exam $SERVER_IP:$SERVER_PORT $CERT $EXAM_USER $EXAM_PWD || abort mv nexus-exam $CONFIG_DIR || abort echo "Building nexus live exam OS image \"$ISO\" ..." -echo "Using nexus-server @ $SERVER_IP" +echo "Using nexus-server @ $SERVER_IP:$SERVER_PORT" build_docker_image diff --git a/live_exam_os/config/Xsession b/live_exam_os/config/Xsession new file mode 100644 index 00000000..3222364c --- /dev/null +++ b/live_exam_os/config/Xsession @@ -0,0 +1,6 @@ +# Set brightness at 100% +screen=`xrandr -q|grep ' connected'|head -n1|cut -d ' ' -f1` +xrandr --output $screen --brightness 0.5 + +# Disable screen blanking +xset s off diff --git a/live_exam_os/config/live-exam-hook b/live_exam_os/config/live-exam-hook index acabcf69..b413a788 100755 --- a/live_exam_os/config/live-exam-hook +++ b/live_exam_os/config/live-exam-hook @@ -10,41 +10,25 @@ ## This is free software, and you are welcome to redistribute it ## under certain conditions; see COPYING for details. -# This function is here just for reference as it is not used. -add_nexus_certs () -{ - if [ ! -e /etc/ssl/certs/nexus-server.pem ] && [ -e /usr/share/ca-certificates/nexus-server/nexus-server.crt ] - then - echo "nexus-server/nexus-server.crt" >> /etc/ca-certificates.conf - update-ca-certificates - fi -} - -disable_screen_blanking() -{ - echo "xset s off" >> /home/nexus/.xsession -} - -max_screen_brightness() -{ - brightnessctl set 100% -} +# add_nexus_certs () +# { +# if [ ! -e /etc/ssl/certs/nexus-server.pem ] && [ -e /usr/share/ca-certificates/nexus-server/nexus-server.crt ] +# then +# echo "nexus-server/nexus-server.crt" >> /etc/ca-certificates.conf +# update-ca-certificates +# fi +# } firewall () { ufw default deny incoming ufw default deny outgoing - ufw allow in from any port 68 to any port 67 proto udp - ufw allow from any to any port 80 - ufw allow from any to any port 443 - ufw allow from any to any port _SERVER_PORT_ + ufw allow out from any to $1 port 80 + ufw allow out from any to $1 port 443 + ufw allow out from any to $1 port $2 ufw allow out from any to $1 port 1025:65535 proto tcp ufw allow out from any to $1 port 1025:65535 proto udp - # ufw allow from any to any port 22 ufw enable } -#add_nexus_certs - -#max_screen_brightness -#disable_screen_blanking +# add_nexus_certs \ No newline at end of file diff --git a/src/client/nexus-exam/nexus-exam.go b/src/client/nexus-exam/nexus-exam.go index 5ceed6e7..104e5cbf 100644 --- a/src/client/nexus-exam/nexus-exam.go +++ b/src/client/nexus-exam/nexus-exam.go @@ -42,7 +42,9 @@ var ( ) func exit(code int) { - exitFn() + if exitFn != nil { + exitFn() + } os.Exit(code) } -- GitLab