switch_selinux.sh | 开启或禁用SELinux

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

猜你喜欢

转载自www.cnblogs.com/shichangming/p/10127267.html