Add SELinux Check

This commit is contained in:
Erope
2022-05-13 19:29:03 +08:00
parent a9ffccf894
commit 750decd076
3 changed files with 37 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ NZ_BASE_PATH="/opt/nezha"
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
NZ_VERSION="v0.10.0"
NZ_VERSION="v0.10.1"
red='\033[0;31m'
green='\033[0;32m'
@@ -94,15 +94,16 @@ before_show_menu() {
}
install_base() {
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1) ||
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1) ||
(install_soft curl wget git unzip)
}
install_soft() {
(command -v yum >/dev/null 2>&1 && yum install $* -y) ||
(command -v apt >/dev/null 2>&1 && apt install $* -y) ||
# The official Arch library does not contain selinux components
(command -v yum >/dev/null 2>&1 && yum install $* selinux-policy -y) ||
(command -v apt >/dev/null 2>&1 && apt install $* selinux-utils -y) ||
(command -v pacman >/dev/null 2>&1 && pacman -Syu $*) ||
(command -v apt-get >/dev/null 2>&1 && apt-get install $* -y)
(command -v apt-get >/dev/null 2>&1 && apt-get install $* selinux-utils -y)
}
install_dashboard() {
@@ -164,8 +165,20 @@ install_dashboard() {
fi
}
selinux(){
#Check SELinux
getenforce | grep enfor
if [ $? -eq 0 ];then
echo -e "SELinux runningclosing now"
setenforce 0 &>/dev/null
find_key="SELINUX="
sed -ri "/^$find_key/c${find_key}disabled" /etc/selinux/config
fi
}
install_agent() {
install_base
selinux
echo -e "> Install Nezha Agent"