From fdbec04c407a6248d6d128c3ccfdb14631586232 Mon Sep 17 00:00:00 2001
From: Florent Gluck <florent.gluck@hesge.ch>
Date: Sun, 28 Jul 2024 18:57:48 +0200
Subject: [PATCH] live-exam-os: added support for ntp time synchronization and
 i3 xfwm4 theme

---
 live_exam_os/Dockerfile                        |  6 ++++++
 live_exam_os/config/boot_hooks/firewall        |  7 ++++---
 live_exam_os/config/bootloader/grub_config.cfg | 13 -------------
 live_exam_os/config/packages.list.chroot       |  3 ++-
 live_exam_os/config/removepkg.hook.chroot      |  6 +++++-
 live_exam_os/config/screen/screen_settings.sh  |  9 ++++-----
 live_exam_os/config/xfce/xfwm4.xml             |  2 +-
 7 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/live_exam_os/Dockerfile b/live_exam_os/Dockerfile
index 3e5a747f..00c85e4c 100644
--- a/live_exam_os/Dockerfile
+++ b/live_exam_os/Dockerfile
@@ -45,6 +45,9 @@ ADD ${config_dir}/xfce/xfce4-settings-manager.xml config/includes.chroot/etc/xdg
 ADD ${config_dir}/xfce/xfce4-power-manager.xml config/includes.chroot/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/
 ADD ${config_dir}/xfce/xfwm4.xml config/includes.chroot/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/
 
+## Install i3 theme for xfwm4
+ADD ${config_dir}/themes config/includes.chroot/usr/share/themes/
+
 # syslinux (bios) cfg
 ADD ${config_dir}/bootloader/isolinux.cfg config/includes.binary/isolinux/isolinux.cfg
 ADD ${config_dir}/bootloader/isolinux_splash.png config/includes.binary/isolinux/splash.png
@@ -57,6 +60,9 @@ ADD ${config_dir}/bootloader/isolinux_stdmenu.cfg config/includes.binary/isolinu
 # server pub cert to be installed (system wide)
 #ADD ${config_dir}/${nexus_cert} config/includes.chroot/usr/share/ca-certificates/nexus-server/nexus-server.crt
 
+# ntp server configuration
+ADD ${config_dir}/ntp/timesyncd.conf config/includes.chroot/etc/systemd/
+
 # firewall hook ran at boot time
 ADD ${config_dir}/boot_hooks/firewall config/includes.chroot/lib/live/config/9999-firewall
 RUN echo "firewall ${server_ip} ${server_port}\n" >> config/includes.chroot/lib/live/config/9999-firewall
diff --git a/live_exam_os/config/boot_hooks/firewall b/live_exam_os/config/boot_hooks/firewall
index 15d0e09a..eb684dce 100755
--- a/live_exam_os/config/boot_hooks/firewall
+++ b/live_exam_os/config/boot_hooks/firewall
@@ -7,13 +7,14 @@ firewall ()
     # Block all incoming and outgoing traffic
     ufw default deny incoming
     ufw default deny outgoing
-    # Allow outgoing http and https traffic
+    # Allow outgoing http and https traffic to nexus-server
     ufw allow out from any to $1 port 80
     ufw allow out from any to $1 port 443
     # Allow outgoing traffic to nexus-server API
     ufw allow out from any to $1 port $2
-    # Allow outgoing ntp traffic
-    # ufw allow out from any to any port 123 proto udp
+    # Allow outgoing ntp and dns traffic
+    ufw allow out from any to any port 123 proto udp
+    ufw allow out from any to any port 53 proto udp
     # Allow outgoing traffic to nexus VMs (Spice)
     ufw allow out from any to $1 port 1025:65535 proto tcp
     ufw allow out from any to $1 port 1025:65535 proto udp
diff --git a/live_exam_os/config/bootloader/grub_config.cfg b/live_exam_os/config/bootloader/grub_config.cfg
index 06f5c5d1..2ceffbdc 100644
--- a/live_exam_os/config/bootloader/grub_config.cfg
+++ b/live_exam_os/config/bootloader/grub_config.cfg
@@ -1,15 +1,2 @@
 set default=0
 set timeout=0
-
-loadfont $prefix/dejavu-bold-16.pf2
-loadfont $prefix/dejavu-bold-14.pf2
-loadfont $prefix/unicode.pf2
-set gfxmode=auto
-insmod all_video
-insmod gfxterm
-insmod png
-
-source /boot/grub/theme.cfg
-
-terminal_output gfxterm
-
diff --git a/live_exam_os/config/packages.list.chroot b/live_exam_os/config/packages.list.chroot
index 352dba94..262f567a 100644
--- a/live_exam_os/config/packages.list.chroot
+++ b/live_exam_os/config/packages.list.chroot
@@ -11,4 +11,5 @@ virt-viewer
 firmware-iwlwifi
 network-manager
 network-manager-gnome
-#systemd-timesyncd
+systemd-timesyncd
+light
diff --git a/live_exam_os/config/removepkg.hook.chroot b/live_exam_os/config/removepkg.hook.chroot
index 3c80bac4..769cb216 100644
--- a/live_exam_os/config/removepkg.hook.chroot
+++ b/live_exam_os/config/removepkg.hook.chroot
@@ -1,3 +1,7 @@
 #!/bin/sh
 
-apt-get remove -y light-locker libreoffice-common libreoffice-core firefox-esr firefox-esr-l10n-fr nano vim
+apt-get remove -y light-locker libreoffice-common libreoffice-core firefox-esr firefox-esr-l10n-fr nano vim aspell aspell-fr bluetooth bluez bluez-firmware dosfstools raspi-firmware fdisk
+
+# Remove all packages marked as "rc", i.e. all packages deleted
+# from the system but for which configuration files are still present
+for i in `dpkg -l|grep ^rc|awk {'print $2'}`;do dpkg --force-all -P $i;done
diff --git a/live_exam_os/config/screen/screen_settings.sh b/live_exam_os/config/screen/screen_settings.sh
index 670b38a0..7b81ba32 100644
--- a/live_exam_os/config/screen/screen_settings.sh
+++ b/live_exam_os/config/screen/screen_settings.sh
@@ -1,8 +1,7 @@
 #!/bin/bash
 
-# Set brightness at 100%
-screen=`xrandr -q|grep ' connected'|head -n1|cut -d ' ' -f1`
-xrandr --output $screen --brightness 1
-
-# Disable screen blanking
+# Disable screen blanking (by default blanks the screen after 10min)
 xset s off
+
+# Set brightness to 100%
+light -S 100
diff --git a/live_exam_os/config/xfce/xfwm4.xml b/live_exam_os/config/xfce/xfwm4.xml
index fdbf87d0..2f7bcdfb 100644
--- a/live_exam_os/config/xfce/xfwm4.xml
+++ b/live_exam_os/config/xfce/xfwm4.xml
@@ -38,7 +38,7 @@
     <property name="snap_to_border" type="bool" value="true"/>
     <property name="snap_to_windows" type="bool" value="false"/>
     <property name="snap_width" type="int" value="10"/>
-    <property name="theme" type="empty"/>
+    <property name="theme" type="string" value="i3"/>
     <property name="title_alignment" type="string" value="center"/>
     <property name="title_font" type="string" value="Sans Bold 9"/>
     <property name="title_horizontal_offset" type="int" value="0"/>
-- 
GitLab