
* laying the groundwork * moving more stuff * move files into place * add control * postinst script * preinst * added more to postinst and preinst * I think this works * fix gitignore and control * fixes * Delete homeassistant-supervised.deb * Check network connection * first test of build deb * test 2 * create changelog * switch to lowercase for github action * test without args * fix typo in example changelog * Resolve errors * Space out control * added files to gitignore * update gitignore * putting everything in place * revert actions changes * Test action * test workflow * new action * get rid of push * set version number to match os agent format * added machine type select * move bin * postrm undo dpkg-divert
49 lines
1.1 KiB
Bash
49 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Load configs
|
|
CONFIG_FILE=%%HASSIO_CONFIG%%
|
|
|
|
# Read configs
|
|
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
|
|
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 -f "${profile}"; then
|
|
continue
|
|
fi
|
|
fi
|
|
echo "[Error]: Can't remove profile ${profile}"
|
|
done
|