Created
October 12, 2015 04:55
-
-
Save gnilchee/7f3927e2cefbac42f3c1 to your computer and use it in GitHub Desktop.
SELinux config file update script written in Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
disabled() { | |
sed -i 's/^SELINUX=.*/SELINUX=disabled/' config && echo SUCCESS || echo FAILURE | |
} | |
permissive() { | |
sed -i 's/^SELINUX=.*/SELINUX=permissive/' config && echo SUCCESS || echo FAILURE | |
} | |
enforcing() { | |
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' config && echo SUCCESS || echo FAILURE | |
} | |
current() { | |
grep -E '^SELINUX=' config | awk -F "=" '{print $2}' | |
} | |
printconfig() { | |
cat config | |
} | |
case "$1" in | |
--disabled) | |
disabled | |
;; | |
--permissive) | |
permissive | |
;; | |
--enforcing) | |
enforcing | |
;; | |
--current) | |
current | |
;; | |
--print) | |
printconfig | |
;; | |
*) | |
echo "Usage: $(readlink -f $0) {--current|--print|--disabled|--permissive|--enforcing}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment