Simplify AppArmor handler with new OS-Agent
This commit is contained in:
parent
f844eb1cf8
commit
a05772cbe2
1 changed files with 1 additions and 24 deletions
|
@ -8,20 +8,12 @@ CONFIG_FILE=%%HASSIO_CONFIG%%
|
||||||
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
|
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
|
||||||
PROFILES_DIR="${DATA}/apparmor"
|
PROFILES_DIR="${DATA}/apparmor"
|
||||||
CACHE_DIR="${PROFILES_DIR}/cache"
|
CACHE_DIR="${PROFILES_DIR}/cache"
|
||||||
REMOVE_DIR="${PROFILES_DIR}/remove"
|
|
||||||
|
|
||||||
# Exists AppArmor
|
|
||||||
if ! command -v apparmor_parser > /dev/null 2>&1; then
|
|
||||||
echo "[Warning]: No apparmor_parser on host system!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check folder structure
|
# Check folder structure
|
||||||
mkdir -p "${PROFILES_DIR}"
|
mkdir -p "${PROFILES_DIR}"
|
||||||
mkdir -p "${CACHE_DIR}"
|
mkdir -p "${CACHE_DIR}"
|
||||||
mkdir -p "${REMOVE_DIR}"
|
|
||||||
|
|
||||||
# Load/Update exists/new profiles
|
# Load exists profiles
|
||||||
for profile in "${PROFILES_DIR}"/*; do
|
for profile in "${PROFILES_DIR}"/*; do
|
||||||
if [ ! -f "${profile}" ]; then
|
if [ ! -f "${profile}" ]; then
|
||||||
continue
|
continue
|
||||||
|
@ -32,18 +24,3 @@ for profile in "${PROFILES_DIR}"/*; do
|
||||||
echo "[Error]: Can't load profile ${profile}"
|
echo "[Error]: Can't load profile ${profile}"
|
||||||
fi
|
fi
|
||||||
done
|
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 -f "${profile}"; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "[Error]: Can't remove profile ${profile}"
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in a new issue