Skip to content
Snippets Groups Projects
Commit f0c2005f authored by Alberto LIVIO BECCARIA's avatar Alberto LIVIO BECCARIA
Browse files

Merge branch 'testing'

parents 30996306 333a1e5d
No related branches found
No related tags found
No related merge requests found
Showing
with 343 additions and 287 deletions
#!/bin/bash
stop() {
:
}
start() {
if [ "z${ESAME_DESKTOP_WALLPAPER_URL}" != "z" -a "z${ESAME_DESKTOP_WM}" != "z" ]; then
if [[ ${ESAME_DESKTOP_WM} == "xfce4" ]]
then
sed -i 's@\(image-path.*value="\)\([^"]*\)\("\)@\1'"`echo "${ESAME_DESKTOP_WALLPAPER_URL}"`"'\3@g' /local/${ESAME_USER}/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
echo "Desktop wallpaper set to ${ESAME_DESKTOP_WALLPAPER_URL}"
fi
fi
}
args=("$@")
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "Usage: $0 { start | stop | restart }";
exit 1;
;;
esac
exit 0
#!/bin/bash
#/usr/local/sbin/esamesync-esame.sh
# Host for the sync operation
# (A different value can be specified in /etc/sysconfig/esamesync-esame)
ESAMESYNCHOST=master2.edu-al.unipmn.it
# Max delay in case of errors (a random delay will be used, calculated
# between 0 and this value).
# (A different value can be specified in /etc/sysconfig/esamesync-esame)
MAXSLEEP=30
# Configuration override can go to:
. /etc/sysconfig/esamesync-esame
/usr/local/bin/bta-netwait ${ESAMESYNCHOST}
/bin/cat <<MSG
Starting /opt/esame syncronization (if it seems to be stuck, please wait for
a few minutes for your updates to take place; they can require a long time)
DON'T TURN OFF THIS MACHINE NOW, JUST WAIT UNTIL FINISHED
MSG
DST=/opt/esame/
SRC=rsync://${ESAMESYNCHOST}/opt/esame/
cd ${DST}
# To fix spurious errors, we pause and repeat the sync if necessary.
# Note: excluding /opt/google as that is installed locally with RPMs.
# Note: excluding /opt/esame as it is already syncronized on every boot.
#
while ! rsync -avq --sparse --progress --delete --whole-file ${SRC} . ; do
SLEEPTIME="$(expr $RANDOM % $MAXSLEEP)"
echo "Error from rsync, sleeping for ${SLEEPTIME} seconds."
sleep ${SLEEPTIME}
done
...@@ -3,7 +3,21 @@ ...@@ -3,7 +3,21 @@
API_BASE_URL=https://labmanager-api.edu-al.unipmn.it/api/1.0 API_BASE_URL=https://labmanager-api.edu-al.unipmn.it/api/1.0
function getTokenJSON() { function getTokenJSON() {
echo `curl -s -k --max-time 10 -X POST -H "Content-Type: application/json" -d "{\"login\":\"guest\",\"pwd\":\"\"}" ${API_BASE_URL}/login` # store the whole response with the status at the end
HTTP_RESPONSE=$(curl -s -k -w "HTTPSTATUS:%{http_code}" --max-time 10 -X POST -H "Content-Type: application/json" -d "{\"login\":\"guest\",\"pwd\":\"\"}" ${API_BASE_URL}/login)
# extract the body
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
# check the status
if [[ $HTTP_STATUS -ne 200 ]]
then
echo "Error authenticating to server (http_status=$HTTP_STATUS)"
exit 1
else
echo $HTTP_BODY
fi
} }
...@@ -19,41 +33,27 @@ stop() { ...@@ -19,41 +33,27 @@ stop() {
} }
start() { getConfigVars() {
echo "START ESAME-GET-CONFIG"
TOKEN_JSON=$(getTokenJSON) TOKEN_JSON=$(getTokenJSON)
TOKEN=`echo ${TOKEN_JSON} | jsonValue token 1` TOKEN=`echo ${TOKEN_JSON} | jsonValue token 1`
MACHINE_NAME=`hostname` MACHINE_NAME=`hostname`
MACHINE_JSON=`/usr/bin/curl -s -k --max-time 10 -H "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/name/${MACHINE_NAME}` MACHINE_JSON=`/usr/bin/curl -s -k --max-time 10 -H "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/name/${MACHINE_NAME}`
MACHINE_ID=`echo $MACHINE_JSON | jsonValue id 1` MACHINE_ID=`echo $MACHINE_JSON | jsonValue id 1`
MACHINE_CONFIGS_ID=`echo $MACHINE_JSON | jsonValue configs_id 1` MACHINE_CONFIGS_ID=`echo $MACHINE_JSON | jsonValue configs_id 1`
CONFIG_NAME=`echo $MACHINE_JSON | jsonValue name 2`
MACHINE_CONFIGS_ID_PREV='' MACHINE_CONFIGS_ID_PREV=''
if [[ -e /local/config_id ]] CONFIG_NAME_PREV=''
if [[ -e /local/config_name ]]
then then
MACHINE_CONFIGS_ID_PREV=`cat /local/config_id` CONFIG_NAME_PREV=`cat /local/config_name`
fi
echo "TOKEN_JSON: $TOKEN_JSON"
echo "TOKEN: $TOKEN"
echo "MACHINE_NAME: $MACHINE_NAME"
echo "MACHINE_JSON: $MACHINE_JSON"
echo "MACHINE_ID: $MACHINE_ID"
echo "MACHINE_CONFIGS_ID: $MACHINE_CONFIGS_ID"
echo "MACHINE_CONFIGS_ID_PREV: $MACHINE_CONFIGS_ID_PREV"
# non sono riuscito a contattatare il ws
if [[ "$MACHINE_CONFIGS_ID" == "" ]]
then
echo "Error: WS unreachable or wrong credentials"
exit 1
fi fi
}
# back config files up
cp -f /local/esame-machine.conf /local/esame-machine.conf.prev 2>&1
cp -f /local/iptables /local/iptables.prev 2>&1
getConfigFile() {
# get configuration file # get configuration file
HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /local/esame-machine.conf --max-time 10 --header "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/${MACHINE_ID}/configfile` HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /local/esame-machine.conf --max-time 10 --header "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/${MACHINE_ID}/configfile`
if [[ $HTTP_STATUS -ne 200 ]] if [[ $HTTP_STATUS -ne 200 ]]
...@@ -63,7 +63,10 @@ start() { ...@@ -63,7 +63,10 @@ start() {
else else
echo "Downloaded config file (http_status=$HTTP_STATUS)" echo "Downloaded config file (http_status=$HTTP_STATUS)"
fi fi
}
getIpConfigFile() {
# get ipconfig file # get ipconfig file
HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /local/iptables --max-time 10 --header "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/${MACHINE_ID}/ipconfigfile` HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /local/iptables --max-time 10 --header "Authorization: Bearer ${TOKEN}" -X GET ${API_BASE_URL}/machines/${MACHINE_ID}/ipconfigfile`
if [[ $HTTP_STATUS -ne 200 ]] if [[ $HTTP_STATUS -ne 200 ]]
...@@ -73,51 +76,107 @@ start() { ...@@ -73,51 +76,107 @@ start() {
else else
echo "Downloaded iptables config file (http_status=$HTTP_STATUS)" echo "Downloaded iptables config file (http_status=$HTTP_STATUS)"
fi fi
}
updateCurrentConfigId() {
# Update this machine's current config id
HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /dev/null --max-time 10 -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" \
-X PUT -d "{\"current_configs_id\":\"$MACHINE_CONFIGS_ID\"}" ${API_BASE_URL}/machines/${MACHINE_ID}/currentconfig`
if [[ $HTTP_STATUS -ne 200 ]]
then
echo "Error updating current config (http_status=$HTTP_STATUS)"
exit 1
else
echo "Updated current config (http_status=$HTTP_STATUS)"
fi
}
start() {
echo "START ESAME-GET-CONFIG"
getConfigVars
#echo "TOKEN_JSON: $TOKEN_JSON"
#echo "TOKEN: $TOKEN"
#echo "MACHINE_NAME: $MACHINE_NAME"
#echo "MACHINE_JSON: $MACHINE_JSON"
#echo "MACHINE_ID: $MACHINE_ID"
#echo "MACHINE_CONFIGS_ID: $MACHINE_CONFIGS_ID"
#echo "MACHINE_CONFIGS_ID_PREV: $MACHINE_CONFIGS_ID_PREV"
echo "Configuration: $CONFIG_NAME"
# non sono riuscito a contattare il ws
if [[ "$CONFIG_NAME" == "" ]]
then
echo "Error: WS unreachable or wrong credentials"
exit 1
fi
# back config files up
cp -f /local/esame-machine.conf /local/esame-machine.conf.prev 2>&1
cp -f /local/iptables /local/iptables.prev 2>&1
getConfigFile
getIpConfigFile
# configuration profile is changed # configuration profile is changed
if [[ "$MACHINE_CONFIGS_ID" != "$MACHINE_CONFIGS_ID_PREV" ]] if [[ "$CONFIG_NAME" != "$CONFIG_NAME_PREV" ]]
then then
# stop the timer to avoid executing this script again before the boot # stop the timer to avoid executing this script again before the boot
/usr/bin/systemctl stop esame-apply-config.timer #/usr/bin/systemctl stop esame-apply-config.timer
# update config_id file
echo ${MACHINE_CONFIGS_ID} > /local/config_id
# update config_name file
echo ${CONFIG_NAME} > /local/config_name
# no exam, set normal target # no exam, set normal target
if [[ "$MACHINE_CONFIGS_ID" -eq "0" ]] if [[ "$CONFIG_NAME" == "normale" ]]
then then
# stop some services to revert system files # stop some services to revert system files
/usr/bin/systemctl stop esame-kioskmode #/usr/bin/systemctl stop esame-kioskmode
/usr/bin/systemctl stop esame-kdm-autologin #/usr/bin/systemctl stop esame-kdm-autologin
/usr/bin/systemctl stop esame-virtualbox #/usr/bin/systemctl stop esame-virtualbox
rm /local/esame-machine.conf 2>&1 rm /local/esame-machine.conf 2>&1
rm /local/esame-machine.conf.prev 2>&1 rm /local/esame-machine.conf.prev 2>&1
rm /local/iptables 2>&1 rm /local/iptables 2>&1
rm /local/iptables.prev 2>&1 rm /local/iptables.prev 2>&1
echo "Normal!" echo "Normal!"
/usr/bin/systemctl set-default graphical.target #systemctl isolate graphical && exit 0
/usr/bin/systemctl reboot --force #/usr/bin/systemctl set-default graphical.target
/usr/bin/systemctl reboot
#--force
else else
echo "Exam!" echo "Exam!"
/usr/bin/systemctl set-default esame.target #systemctl isolate esame.target && exit 0
/usr/bin/systemctl reboot --force #/usr/bin/systemctl set-default esame.target
/usr/bin/systemctl reboot
#--force
fi fi
else else
# Update this machine's current config id # at boot time choose the correct target
HTTP_STATUS=`/usr/bin/curl -s -k -w "%{http_code}" -o /dev/null --max-time 10 -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" \ if [[ "$1" == "boot" ]]
-X PUT -d "{\"current_configs_id\":\"$MACHINE_CONFIGS_ID\"}" ${API_BASE_URL}/machines/${MACHINE_ID}/currentconfig`
if [[ $HTTP_STATUS -ne 200 ]]
then then
echo "Error updating current config (http_status=$HTTP_STATUS)" # we have just rebooted, update the current configuration via web service
exit 1 updateCurrentConfigId
else case "$CONFIG_NAME" in
echo "Updated current config (http_status=$HTTP_STATUS)" 'normale') # normal
systemctl isolate graphical.target && exit 0
;;
'kiosk-dir' | 'kiosk-dir-esami' | 'kiosk-escher' | 'kiosk-freebrowsing' | 'kiosk-teco') # kiosk mode
systemctl isolate esamekiosk.target && exit 0
;;
*) # all full desktop exams
systemctl isolate esame.target && exit 0
;;
esac
fi fi
fi fi
# Runtime parameters # Runtime parameters
if [[ "$MACHINE_CONFIGS_ID" -ne "0" ]] if [[ "$CONFIG_NAME" != "normale" ]]
then then
# check if parameters are changed # check if parameters are changed
cmp --silent /local/esame-machine.conf /local/esame-machine.conf.prev cmp --silent /local/esame-machine.conf /local/esame-machine.conf.prev
...@@ -126,15 +185,33 @@ start() { ...@@ -126,15 +185,33 @@ start() {
/usr/bin/systemctl daemon-reload /usr/bin/systemctl daemon-reload
echo "Configuration parameters changed: restart some services... " echo "Configuration parameters changed: restart some services... "
# restart some exam services # restart some exam services
echo -n "USB..." #echo -n "USB..."
/usr/bin/systemctl restart esame-usb #/usr/bin/systemctl restart esame-usb
echo " done." #echo " done."
echo -n "Firefox home..." KIOSK_URL_CHANGED=$(diff /local/esame-machine.conf /local/esame-machine.conf.prev | grep ESAME_KIOSK_URL -c)
/usr/bin/systemctl restart esame-firefox-home if [[ $KIOSK_URL_CHANGED -ne 0 ]]
echo " done." then
echo -n "Firefox Home..."
FIREFOX_PID=$(pgrep firefox)
if [[ "${FIREFOX_PID}" != "" ]]
then
FIREFOX_USER=$(ps -o user= -p ${FIREFOX_PID})
rm -f /local/${FIREFOX_USER}/.mozilla/firefox/44bu2eyb.default/lock
pkill firefox
sleep 2
/usr/bin/systemctl restart esame-firefox-home
echo " done."
# no way to restart firefox, I must miss something :(
#echo -n "Restarting Firefox..."
#su - ${FIREFOX_USER} -c 'nohup /usr/bin/firefox --display=:0.0 &'
#echo " done."
else
/usr/bin/systemctl restart esame-firefox-home
echo " done."
fi
fi
echo echo
echo "All done." echo "All done."
exit 0
fi fi
fi fi
} }
...@@ -143,6 +220,9 @@ start() { ...@@ -143,6 +220,9 @@ start() {
args=("$@") args=("$@")
case "$1" in case "$1" in
'boot')
start "boot"
;;
'start') 'start')
start start
;; ;;
...@@ -154,7 +234,7 @@ case "$1" in ...@@ -154,7 +234,7 @@ case "$1" in
start start
;; ;;
*) *)
echo "Usage: $0 { start | stop | restart }"; echo "Usage: $0 { boot | start | stop | restart }";
exit 1; exit 1;
;; ;;
esac esac
......
#!/bin/bash #!/bin/bash
stop() { stop() {
#/etc/init.d/iptables-esame stop
#/etc/init.d/iptables restart
# se facciamo reboot tutte le volte questo non serve, ma si potrebbe prevedere # se facciamo reboot tutte le volte questo non serve, ma si potrebbe prevedere
#/usr/sbin/iptables-restore </etc/sysconfig/iptables #/usr/sbin/iptables-restore </etc/sysconfig/iptables
: :
......
#!/bin/bash #!/bin/bash
clear() { clear() {
sed -i '/AutoLoginEnable=/s/.*/#\0/' /etc/kde/kdm/kdmrc sed -i '/AutoLoginEnable=/s/.*/#\0/' /etc/kde/kdm/kdmrc
sed -i '/AutoLoginAgain=/s/.*/#\0/' /etc/kde/kdm/kdmrc sed -i '/AutoLoginAgain=/s/.*/#\0/' /etc/kde/kdm/kdmrc
sed -i '/AutoLoginUser=/s/.*/#\0/' /etc/kde/kdm/kdmrc sed -i '/AutoLoginUser=/s/.*/#\0/' /etc/kde/kdm/kdmrc
} }
......
...@@ -16,7 +16,6 @@ start() { ...@@ -16,7 +16,6 @@ start() {
cd /local && mv ${ESAME_USER} "${ESAME_USER}.${TIME}" cd /local && mv ${ESAME_USER} "${ESAME_USER}.${TIME}"
chown root:root "${ESAME_USER}.${TIME}" chown root:root "${ESAME_USER}.${TIME}"
chmod 700 "${ESAME_USER}.${TIME}" chmod 700 "${ESAME_USER}.${TIME}"
#cp -a /opt/esame/home/${ESAME_USER} ${ESAME_USER}
cp -a /opt/esame/home/${ESAME_USER} ./ cp -a /opt/esame/home/${ESAME_USER} ./
chown -Rh ${ESAME_USER}:esame ${ESAME_USER} chown -Rh ${ESAME_USER}:esame ${ESAME_USER}
fi fi
......
#!/bin/bash
# obsolete
stop() {
echo "STOP ESAME-APPLY-CONFIG"
#rm /local/esame-machine.conf
#rm /local/iptables
}
start() {
. /opt/esame/bin/get-config start
echo "START ESAME-APPLY-CONFIG"
# configuration profile is changed
if [[ "$MACHINE_CONFIGS_ID" != "$MACHINE_CONFIGS_ID_PREV" ]]
then
# update config_id file
echo ${MACHINE_CONFIGS_ID} > /local/config_id
# no exam, set normal target
if [[ "$MACHINE_CONFIGS_ID" -eq "0" ]]
then
# stop some services to revert system files
/usr/bin/systemctl stop esame-kioskmode
/usr/bin/systemctl stop esame-kdm-autologin
rm /local/esame-machine.conf 2>&1
rm /local/esame-machine.conf.prev 2>&1
rm /local/iptables 2>&1
rm /local/iptables.prev 2>&1
echo "Normal!"
/usr/bin/systemctl set-default graphical.target
reboot
else
echo "Exam!"
/usr/bin/systemctl set-default esame.target
reboot
fi
fi
if [[ "$MACHINE_CONFIGS_ID" -ne "0" ]]
then
# check if parameters are changed
cmp --silent /local/esame-machine.conf /local/esame-machine.conf.prev
if [[ $? -ne 0 ]]
then
/usr/bin/systemctl daemon-reload
echo "Configuration parameters changed: restart services... "
# restart some exam services
echo -n "USB..."
/usr/bin/systemctl start esame-usb
echo " done."
echo -n "Firefox home..."
/usr/bin/systemctl start esame-firefox-home
echo " done."
echo
echo "All done."
fi
fi
}
args=("$@")
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "Usage: $0 { start | stop | restart }";
exit 1;
;;
esac
exit 0
#!/bin/bash
find_regular_user_sessions() {
ESAME_KILL_USERS=`loginctl list-sessions -l | awk '{print $3}' | egrep -v 'root|labsync|esame|moodle|vbconsole|listed|USER'`
}
find_esame_user_sessions() {
ESAME_KILL_USERS=`loginctl list-sessions -l | awk '{print $3}' | egrep 'esame|moodle|vbconsole'`
}
kill_sessions() {
for a in ${ESAME_KILL_USERS}; do
echo loginctl kill-user "$a"
loginctl kill-user "$a"
done
}
start() {
# We kill user sessions when the exam starts.
find_regular_user_sessions
kill_sessions
}
stop() {
# We kill exam session when the exam ends.
find_esame_user_sessions
kill_sessions
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "Usage: $0 { start | stop | restart }";
exit 1;
;;
esac
exit 0
#!/bin/bash #!/bin/bash
getconf() {
ESAME_USB=${args[1]}
}
# Un'idea alternativa sarebbe impedire il caricamento del modulo # Un'idea alternativa sarebbe impedire il caricamento del modulo
# usb-storage. Occorre pero' rimuoverlo dai moduli gia' caricati, # usb-storage. Occorre pero' rimuoverlo dai moduli gia' caricati,
# e fare qualcosa nel caso in cui sia impossibile rimuoverlo # e fare qualcosa nel caso in cui sia impossibile rimuoverlo
...@@ -34,9 +30,9 @@ riabilitamodulo() { ...@@ -34,9 +30,9 @@ riabilitamodulo() {
} }
stop() { stop() {
#pkill -ALRM bta-no-usbpen pkill -ALRM bta-no-usbpen
#riabilitamodulo riabilitamodulo
#echo "STOP ESAME-USB" echo "STOP ESAME-USB"
: :
} }
......
...@@ -2,20 +2,6 @@ ...@@ -2,20 +2,6 @@
ESAME_VB_CONFIG_FILE="/local/vbconsole/bin/kiosk.settings" ESAME_VB_CONFIG_FILE="/local/vbconsole/bin/kiosk.settings"
getconf() {
# Get the right config file
# . /opt/esame/bin/getconf
# Source the current exam configuration
# . ${ESAME_CONF}
# Check the syntax of the configuration file
# /opt/esame/bin/esame-check-config.sh || exit 1
ESAME_VIRTUALBOX=${args[1]}
ESAME_USER=${args[2]}
}
stop() { stop() {
if [ -f ${ESAME_VB_CONFIG_FILE} ]; then if [ -f ${ESAME_VB_CONFIG_FILE} ]; then
echo "STOP VIRTUALBOX KIOSK"; echo "STOP VIRTUALBOX KIOSK";
......
#!/bin/bash #!/bin/bash
# LabManager: systemd units & scripts installer v2.0
GIT_URL=https://gitlab.di.unipmn.it GIT_URL=https://gitlab.di.unipmn.it
GIT_BASE_DIR=ulisse/labmanager-systemd/raw/v1.0 GIT_BASE_DIR=ulisse/labmanager-systemd/raw
GIT_BRANCH=master
function askYesNo {
QUESTION=$1 BIN_FILES=( "desktop-wallpaper" "esamesync-esame.sh" "firefox-home" "get-config" "iptables-rules" "kdm-autologin" "kioskmode" "mk-homedir" "nfs" "usb" "virtualbox" )
DEFAULT=$2
if [ "$DEFAULT" = true ]; then SYSTEMD_FILES=( "esame-desktop-wallpaper.service" "esame-firefox-home.service" "esame-get-config-boot.service" "esame-get-config.service" "esame-iptables-rules.service" "esame-kdm-autologin.service" "esame-kioskmode.service" "esame-mk-homedir.service" "esame-nfs.service" "esame-usb.service" "esame-virtualbox.service" "esamesync-esame.service" "esame-get-config.timer" "esame-configurator.target" "esame.target" "esamekiosk.target" )
OPTIONS="[Y/n]"
DEFAULT="y" # DON'T TOUCH UNDER THIS LINE! #################################################
else
OPTIONS="[y/N]" function downloadFiles {
DEFAULT="n" local base_url="$1"
fi shift
read -p "$QUESTION $OPTIONS " -n 1 -s -r INPUT local files=( "$@" )
INPUT=${INPUT:-${DEFAULT}}
echo ${INPUT} i=1
if [[ "$INPUT" =~ ^[yY]$ ]]; then for f in "${files[@]}"
ANSWER=true do
else echo -e "\n$i/${#files[@]} - $base_url/$f"
ANSWER=false curl -# --fail -O "$base_url/$f"
fi if [[ $? != 0 ]]
then
echo "curl exited with error code != 0, installation aborted."
exit 1
fi
i=$(expr $i + 1)
done
} }
echo -e "\nLabManager: systemd units & scripts installer"
if [ -z "$1" ]; then
echo -e "\nNo branch/tag specified, using branch 'master'."
echo -e "Please call '$0 <branch/tag>' to use a different source.\n"
else
GIT_BRANCH="$1"
echo -e "\nUsing branch/tag '$GIT_BRANCH'.\n"
fi
# v1.0 has a different set of files, print warning and abort installation
if [[ "$GIT_BRANCH" == "v1.0" ]]
then
echo -e "\e[1mWARNING!\e[0m"
echo "Branch 'v1.0' has a different installation procedure, please get"
echo -e "the correct installation script here:\n"
echo -e "$GIT_URL/$GIT_BASE_DIR/v1.0\n"
exit 1
fi
mkdir -p /usr/libexec/labmanager mkdir -p /usr/libexec/labmanager
# script per i servizi systemd # script per i servizi systemd
echo "Downloading systemd script files..." echo -e "\e[1mDownloading systemd script files...\e[0m"
cd /usr/libexec/labmanager cd /usr/libexec/labmanager
curl -O $GIT_URL/$GIT_BASE_DIR/bin/bta-no-usbpen echo "Creating symlink bta-no-usbpen -> /bin/sleep..."
curl -O $GIT_URL/$GIT_BASE_DIR/bin/get-config ln -s -f /bin/sleep bta-no-usbpen
curl -O $GIT_URL/$GIT_BASE_DIR/bin/kdm-autologin echo
curl -O $GIT_URL/$GIT_BASE_DIR/bin/mk-homedir downloadFiles "$GIT_URL/$GIT_BASE_DIR/$GIT_BRANCH/bin" ${BIN_FILES[@]}
curl -O $GIT_URL/$GIT_BASE_DIR/bin/firefox-home
curl -O $GIT_URL/$GIT_BASE_DIR/bin/iptables-rules
curl -O $GIT_URL/$GIT_BASE_DIR/bin/kioskmode
curl -O $GIT_URL/$GIT_BASE_DIR/bin/nfs
curl -O $GIT_URL/$GIT_BASE_DIR/bin/usb
curl -O $GIT_URL/$GIT_BASE_DIR/bin/virtualbox
chmod +x * chmod +x *
echo "OK." echo
echo
echo ""
# servizi systemd # servizi systemd
echo "Downloading systemd service files..." echo -e "\e[1mDownloading systemd unit files...\e[0m"
cd /etc/systemd/system cd /etc/systemd/system
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-apply-config.service downloadFiles "$GIT_URL/$GIT_BASE_DIR/$GIT_BRANCH/systemd" ${SYSTEMD_FILES[@]}
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-apply-config.timer echo
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-firefox-home.service echo
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-get-config.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-iptables-rules.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-kdm-autologin.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-kioskmode.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-mk-homedir.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-nfs.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame.target
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-usb.service
curl -O $GIT_URL/$GIT_BASE_DIR/systemd/esame-virtualbox.service
echo "OK."
echo ""
# disable old esame service?
askYesNo "Disable old systemd esame.service?" false
DOIT=$ANSWER
if [ "$DOIT" = true ]; then
systemctl disable esame.service
fi
echo -n "Reload systemd" # following links should be not needed, specifying services as "Wants" directives should suffice
# create symlinks for target esame and esamekiosk
#mkdir esame.target.wants
#cd esame.target.wants
#ln -s /usr/lib/systemd/system/accounts-daemon.service .
#ln -s /usr/lib/systemd/system/rtkit-daemon.service .
#ln -s /usr/lib/systemd/system/switcheroo-control.service .
#ln -s /usr/lib/systemd/system/systemd-update-utmp-runlevel.service .
#ln -s /usr/lib/systemd/system/udisks2.service .
#mkdir esamekiosk.target.wants
#cd esamekiosk.target.wants
#ln -s /usr/lib/systemd/system/accounts-daemon.service .
#ln -s /usr/lib/systemd/system/rtkit-daemon.service .
#ln -s /usr/lib/systemd/system/switcheroo-control.service .
#ln -s /usr/lib/systemd/system/systemd-update-utmp-runlevel.service .
#ln -s /usr/lib/systemd/system/udisks2.service .
echo -e "\e[1mReload systemd...\e[0m"
systemctl daemon-reload systemctl daemon-reload
echo
echo
echo -n "Enable systemd services..." echo -e "\e[1mEnable systemd services...\e[0m"
systemctl enable esame-*.service systemctl enable esame-*.service
systemctl enable esame-apply-config.timer systemctl enable esamesync-esame.service
echo " OK." systemctl enable esame-get-config.timer
echo
echo
echo -e "\e[1mDisable unwanted systemd services...\e[0m"
systemctl disable esame-usb.service
echo
echo
echo -e "\e[1mChange default target to esame-configurator.target...\e[0m"
systemctl set-default esame-configurator.target
echo
echo
echo "" echo -e "\e[1mAll done!\e[0m"
echo "All done!"
[Unit]
Description=Esame Configurator Target
Requires=basic.target network-online.target sshd.service abrtd.service
Conflicts=rescue.service rescue.target graphical.target esame.target esamekiosk.target
After=basic.target rescue.service rescue.target network-online.target sshd.service abrtd.service
AllowIsolate=yes
[Unit]
Description=Esame - Desktop Wallpaper
After=esame-mk-homedir.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/local/esame-machine.conf
ExecStart=/usr/libexec/labmanager/desktop-wallpaper start
ExecStop=/usr/libexec/labmanager/desktop-wallpaper stop
ExecReload=/usr/libexec/labmanager/desktop-wallpaper restart
[Install]
WantedBy=esame.target esamekiosk.target
...@@ -5,11 +5,10 @@ After=esame-mk-homedir.service ...@@ -5,11 +5,10 @@ After=esame-mk-homedir.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
TimeoutSec=0
EnvironmentFile=-/local/esame-machine.conf EnvironmentFile=-/local/esame-machine.conf
ExecStart=/usr/libexec/labmanager/firefox-home start ExecStart=/usr/libexec/labmanager/firefox-home start
ExecStop=/usr/libexec/labmanager/firefox-home stop ExecStop=/usr/libexec/labmanager/firefox-home stop
ExecReload=/usr/libexec/labmanager/firefox-home restart ExecReload=/usr/libexec/labmanager/firefox-home restart
[Install] [Install]
WantedBy=esame.target WantedBy=esame.target esamekiosk.target
...@@ -5,5 +5,9 @@ Wants=network-online.target esamesync-esame.service ...@@ -5,5 +5,9 @@ Wants=network-online.target esamesync-esame.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes
TimeoutSec=0 TimeoutSec=0
ExecStart=/usr/libexec/labmanager/get-config start ExecStart=/usr/libexec/labmanager/get-config boot
[Install]
WantedBy=esame-configurator.target
...@@ -5,9 +5,5 @@ Wants=network-online.target esamesync-esame.service ...@@ -5,9 +5,5 @@ Wants=network-online.target esamesync-esame.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes
TimeoutSec=0 TimeoutSec=0
ExecStart=/usr/libexec/labmanager/get-config start ExecStart=/usr/libexec/labmanager/get-config start
[Install]
WantedBy=esame.target
...@@ -4,7 +4,7 @@ Description=Get and apply config files from web service (timer) ...@@ -4,7 +4,7 @@ Description=Get and apply config files from web service (timer)
[Timer] [Timer]
OnBootSec=60s OnBootSec=60s
OnUnitActiveSec=60s OnUnitActiveSec=60s
#Unit=esame-apply-config.service #Unit=esame-get-config.service
[Install] [Install]
WantedBy=timers.target WantedBy=esame.target esamekiosk.target graphical.target
[Unit] [Unit]
Description=Apply iptables configuration Description=Apply iptables configuration
After=network-online.target esame-get-config.service After=network-online.target esame-get-config-boot.service
Wants=network-online.target Wants=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
TimeoutSec=0 #TimeoutSec=0
ExecStart=/usr/libexec/labmanager/iptables-rules start ExecStart=/usr/libexec/labmanager/iptables-rules start
[Install] [Install]
WantedBy=esame.target WantedBy=esame.target esamekiosk.target
[Unit] [Unit]
Description=KDM Autologin Description=KDM Autologin
After=kdm.service esame-mk-homedir.service esame-firefox-home.service esame-virtualbox.service After=kdm.service esame-mk-homedir.service esame-desktop-wallpaper.service esame-firefox-home.service esame-virtualbox.service
[Service] [Service]
Type=oneshot Type=oneshot
...@@ -12,4 +12,4 @@ ExecStop=/usr/libexec/labmanager/kdm-autologin stop ...@@ -12,4 +12,4 @@ ExecStop=/usr/libexec/labmanager/kdm-autologin stop
ExecReload=/usr/libexec/labmanager/kdm-autologin restart ExecReload=/usr/libexec/labmanager/kdm-autologin restart
[Install] [Install]
WantedBy=esame.target WantedBy=esame.target esamekiosk.target
...@@ -12,4 +12,4 @@ ExecStop=/usr/libexec/labmanager/kioskmode stop ...@@ -12,4 +12,4 @@ ExecStop=/usr/libexec/labmanager/kioskmode stop
ExecReload=/usr/libexec/labmanager/kioskmode restart ExecReload=/usr/libexec/labmanager/kioskmode restart
[Install] [Install]
WantedBy=esame.target WantedBy=esamekiosk.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment