Skip to content

Commit

Permalink
Simplify AppArmor handler with new OS-Agent (#165)
Browse files Browse the repository at this point in the history
* Simplify AppArmor handler with new OS-Agent

* improve grammar

* bump version number

Co-authored-by: Matheson Steplock <ikifar2012@users.noreply.github.com>
  • Loading branch information
pvizeli and ikifar2012 committed Nov 2, 2021
1 parent d15efe7 commit cf37577
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
2 changes: 1 addition & 1 deletion homeassistant-supervised/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: homeassistant-supervised
Section: base
Version: 1.0.1
Version: 1.0.2
Priority: optional
Architecture: all
Depends: curl, bash, docker-ce, dbus, network-manager, apparmor, jq, systemd, os-agent
Expand Down
25 changes: 1 addition & 24 deletions homeassistant-supervised/usr/sbin/hassio-apparmor
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ CONFIG_FILE=%%HASSIO_CONFIG%%
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
PROFILES_DIR="${DATA}/apparmor"
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
mkdir -p "${PROFILES_DIR}"
mkdir -p "${CACHE_DIR}"
mkdir -p "${REMOVE_DIR}"

# Load/Update exists/new profiles
# Load existing profiles
for profile in "${PROFILES_DIR}"/*; do
if [ ! -f "${profile}" ]; then
continue
Expand All @@ -32,18 +24,3 @@ for profile in "${PROFILES_DIR}"/*; do
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 -f "${profile}"; then
continue
fi
fi
echo "[Error]: Can't remove profile ${profile}"
done

0 comments on commit cf37577

Please sign in to comment.