Separate exam-mode stuff in own role

This commit is contained in:
Raphael Dannecker 2025-03-18 14:37:13 +01:00
parent 43157dd810
commit 3d01394820
13 changed files with 493 additions and 472 deletions

View file

@ -1,16 +0,0 @@
#!/usr/bin/bash
#
# rename -exam directories in /home and /lmn/media older than 12h
# remove -exam.* directories in /home and /lmn/media older than 10d
#
set -eu
for dir in /home/ /lmn/media ; do
if [[ -d "${dir}" ]]; then
find "${dir}" -maxdepth 1 -mindepth 1 -name '*-exam' -type d -cmin +720 \
-exec bash -c 'mv "$0" "$0".$( date +%Y%m%d-%H%M --reference="$0" )' {} \;
find "${dir}" -maxdepth 1 -mindepth 1 -name '*-exam.*' -type d -cmin +14400 \
-exec rm -rf {} \;
fi
done

View file

@ -1,6 +0,0 @@
[Unit]
Description=Rename/Remove -exam directories older than 12h/10d
[Service]
Type=simple
ExecStart=/usr/local/sbin/rmexam

View file

@ -1,8 +0,0 @@
[Unit]
Description=Run rmexam after boot
[Timer]
OnBootSec=0min
[Install]
WantedBy=timers.target

View file

@ -36,26 +36,3 @@
{% if 'teacherlaptop' not in group_names %}
[[ "${UID}" -gt 10000 ]] && ! findmnt /srv/samba/schools/default-school > /dev/null && exit 0
{% endif %}
- name: Provide rmexam script
ansible.builtin.copy:
src: rmexam
dest: /usr/local/sbin/
mode: 0755
when: "'teacherlaptop' not in group_names"
- name: Provide rmexam services and timers for some scripts
ansible.builtin.copy:
src: "{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
loop:
- rmexam.service
- rmexam.timer
when: "'teacherlaptop' not in group_names"
- name: Enable rmexam.timer
ansible.builtin.systemd:
name: rmexam.timer
enabled: true
when: "'teacherlaptop' not in group_names"