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

Installa anche l'override di USBGuard

parent 499e7924
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#!/usr/bin/env bash
# LabManager: systemd units & scripts installer v2.0
GIT_URL=https://gitlab.di.unipmn.it
GIT_BASE_DIR=ulisse/labmanager-systemd/raw
......@@ -16,6 +16,10 @@ SYSTEMD_FILES=(
"esamesync-esame.service" "esame-get-config.timer" "esame-configurator.target" "esame.target" "esamekiosk.target" "esameshow.target" "esame-multi-user.target"
)
USBGUARD_OVERRIDE_FILES=(
"usbguard.service.d/override.conf"
)
SYSCONFIG_FILES=(
"labmanager"
"esamesync-esame"
......@@ -46,6 +50,7 @@ OLD_FILES=(
"/etc/systemd/system/esame.target"
"/etc/systemd/system/esamekiosk.target"
"/etc/systemd/system/esameshow.target"
"/etc/systemd/system/usbguard.service.d"
)
# DON'T TOUCH UNDER THIS LINE! #################################################
......@@ -75,7 +80,7 @@ myuseradd() {
fi
}
function removeFiles {
removeFiles() {
local files=( "$@" )
for f in "${files[@]}"
......@@ -85,7 +90,7 @@ function removeFiles {
done
}
function downloadFiles {
downloadFiles() {
local base_url="$1"
shift
local files=( "$@" )
......@@ -124,7 +129,9 @@ then
exit 1
fi
# remove obsolete files
GIT_BRANCH_PATH=${GIT_URL}/${GIT_BASE_DIR}/${GIT_BRANCH}
# Remove obsolete files
echo -e "\e[1mRemoving obsolete files...\e[0m"
removeFiles ${OLD_FILES[@]}
echo
......@@ -148,13 +155,13 @@ mkdir -p /usr/libexec/labmanager
echo
echo
# script per i servizi systemd
# Systemd services scripts
echo -e "\e[1mDownloading systemd script files...\e[0m"
cd /usr/libexec/labmanager
echo "Creating symlink bta-no-usbpen -> /bin/sleep..."
ln -s -f /bin/sleep bta-no-usbpen
echo
downloadFiles "$GIT_URL/$GIT_BASE_DIR/$GIT_BRANCH/bin-ubuntu" ${BIN_FILES[@]}
downloadFiles "${GIT_BRANCH_PATH}/bin-ubuntu" ${BIN_FILES[@]}
chmod +x *
echo
echo
......@@ -167,22 +174,32 @@ for conffile in ${SYSCONFIG_FILES[@]}; do
if [ -e "${conffile}" ]; then
echo "Not overwriting existing file ${conffile}, skipping it."
else
downloadFiles "$GIT_URL/$GIT_BASE_DIR/$GIT_BRANCH/sysconfig" "${conffile}"
downloadFiles "${GIT_BRANCH_PATH}/sysconfig" "${conffile}"
fi
done
echo
echo
# servizi systemd
# Systemd services files
echo -e "\e[1mDownloading systemd unit files...\e[0m"
cd /etc/systemd/system
downloadFiles "$GIT_URL/$GIT_BASE_DIR/$GIT_BRANCH/systemd-ubuntu" ${SYSTEMD_FILES[@]}
downloadFiles "${GIT_BRANCH_PATH}/systemd-ubuntu" ${SYSTEMD_FILES[@]}
echo
echo
# Override USBGuard
echo -e "\e[1mOverriding USBGuard systemd service...\e[0m"
mkdir /etc/systemd/system/usbguard.service.d
cd /etc/systemd/system/usbguard.service.d
downloadFiles "${GIT_BRANCH_PATH}/systemd-ubuntu" ${USBGUARD_OVERRIDE_FILES[@]}
echo
echo
# following links should not be needed, specifying services as "Wants" directives should suffice
# Following links should not be needed, specifying services as "Wants" directives should suffice
# create symlinks for target esame, esamekiosk, esameshow and esame-configurator
# Create symlinks for target esame, esamekiosk, esameshow and esame-configurator
echo -e "\e[1mSetting up targets & services...\e[0m"
cd /etc/systemd/system
mkdir esame.target.wants
cd esame.target.wants
ln -s /usr/lib/systemd/system/accounts-daemon.service .
......@@ -216,7 +233,9 @@ cd ..
mkdir esame-configurator.target.wants
cd esame-configurator.target.wants
ln -s /etc/systemd/system/enable-wol@.service enable-wol@eth0.service
cd..
cd ..
echo
echo
echo -e "\e[1mReload systemd...\e[0m"
systemctl daemon-reload
......
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