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
posted @ 2018-12-30 10:25  scm1911  阅读(270)  评论(0编辑  收藏  举报
/** ####################################################################### */