#!/bin/bash stop() { # Do nothing : } start() { echo "ESAME_CLEAN_HOME = ${ESAME_CLEAN_HOME}" echo "ESAME_USER = ${ESAME_USER}" # Check if we started this service at least once since the exam has been started. # If the machine crashes or reboots, the home dir will not be cleaned anyway. # The home dir will be cleaned only when the machine will be set to normal and then # to exam mode again if [[ -f /local/mk-homedir ]]; then if [[ ${ESAME_CLEAN_HOME} -eq 1 ]]; then (echo -n "CLEANING HOME FOR ${ESAME_USER} at "; date ) >> /var/log/esame.log echo "CLEANING HOME FOR ${ESAME_USER}" # Start fresh (but keep the home, just in case) TIME=`date +%Y%m%d-%H%M` cd /local && mv ${ESAME_USER} "${ESAME_USER}.${TIME}" chown root:root "${ESAME_USER}.${TIME}" chmod 700 "${ESAME_USER}.${TIME}" cp -a /opt/esame/home/${ESAME_USER} ./ chown -Rh ${ESAME_USER}:esame ${ESAME_USER} fi # remove the file to avoid cleaning the homedir on machine reboot rm /local/mk-homedir >/dev/null 2>&1 else echo "ESAME_CLEAN_HOME value not applied." fi } args=("$@") case "$1" in 'start') start ;; 'stop') stop ;; 'restart') stop start ;; *) echo "Usage: $0 { start | stop | restart } {0 | 1} { username }"; exit 1; ;; esac exit 0