#!/bin/bash
set -eu

[ -x /usr/sbin/semanage ] || exit 0

semanage fcontext -a -t swift_var_cache_t "/mnt/state/var/cache/swift(/.*)?"
restorecon -Rv /mnt/state/var/cache/swift

# allows rsync to write to /mnt/state/var/log/rsyncd.log
semanage fcontext -a -t var_log_t "/mnt/state/var/log"
restorecon -Rv /mnt/state/var/log

# relabel /mnt/state/srv/node as swift_data_t for selinux before the service
# is started. Otherwise selinux will deny writes to this directory.
semanage fcontext -a -t swift_data_t "/mnt/state/srv/node"
restorecon -Rv /mnt/state/srv/node
