switch_selinux.sh | 開啟或禁用SELinux
#!/bin/bash
SELINUX_CFG="/etc/selinux/config"
uasge() {
echo "Usage: $0 on|off"
exit
}
main() {
case "$1" in
on)
sed -ri /^SELINUX=/'s/(SELINUX=).*/\1enforcing/' $SELINUX_CFG
;;
off)
sed -ri /^SELINUX=/'s/(SELINUX=).*/\1disabled/' $SELINUX_CFG
echo "you should reboot to make selinux enabled."
;;
*)
uasge
;;
esac
}
main $1