1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2026-05-01 06:02:23 +01:00

OS: move service scripts into libexec

This commit is contained in:
Pascal Vizeli
2018-11-29 16:01:16 +00:00
parent bc3cc20629
commit ae0a2fe264
12 changed files with 8 additions and 7 deletions

View File

@@ -0,0 +1,47 @@
#!/bin/sh
set -e
# Load configs
CONFIG_FILE=/mnt/data/hassos.json
# Read configs
PROFILES_DIR="$(jq --raw-output '.apparmor // empty' ${CONFIG_FILE})"
if [ -z "${PROFILES_DIR}" ]; then
exit 0
fi
PROFILES_DIR="/mnt/data/${PROFILES_DIR}"
CACHE_DIR="${PROFILES_DIR}/cache"
REMOVE_DIR="${PROFILES_DIR}/remove"
# Check folder structure
mkdir -p ${PROFILES_DIR}
mkdir -p ${CACHE_DIR}
mkdir -p ${REMOVE_DIR}
# Load/Update exists/new profiles
for profile in ${PROFILES_DIR}/*; do
if [ ! -f ${profile} ]; then
continue
fi
# Load Profile
if ! apparmor_parser -r -W -L ${CACHE_DIR} ${profile}; then
echo "[Error]: Can't load profile ${profile}"
fi
done
# Cleanup old profiles
for profile in ${REMOVE_DIR}/*; do
if [ ! -f ${profile} ]; then
continue
fi
# Unload Profile
if apparmor_parser -R -W -L ${CACHE_DIR} ${profile}; then
if rm ${profile}; then
continue
fi
fi
echo "[Error]: Can't remove profile ${profile}"
done