From 1c93798037b553829d9dc7348836451873368ff5 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 24 Aug 2019 17:24:09 -0700 Subject: [PATCH] Check for semanage command availability --- install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index afd9e16e60..89f1d1271f 100755 --- a/install.sh +++ b/install.sh @@ -337,11 +337,15 @@ setup_binary() { if command -v getenforce > /dev/null 2>&1; then if [ "Disabled" != `getenforce` ]; then - info "SeLinux is enabled, setting permissions" - if ! $SUDO semanage fcontext -l | grep "${BIN_DIR}/k3s" > /dev/null 2>&1; then - $SUDO semanage fcontext -a -t bin_t "${BIN_DIR}/k3s" + if command -v semanage > /dev/null 2>&1; then + info "SELinux is enabled, setting permissions" + if ! $SUDO semanage fcontext -l | grep "${BIN_DIR}/k3s" > /dev/null 2>&1; then + $SUDO semanage fcontext -a -t bin_t "${BIN_DIR}/k3s" + fi + $SUDO restorecon -v ${BIN_DIR}/k3s > /dev/null + else + error 'SELinux is enabled but semanage is not found' fi - $SUDO restorecon -v ${BIN_DIR}/k3s > /dev/null fi fi }