pve/build_backend.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

2023-02-15 15:03:21 +08:00
#!/bin/bash
#from https://github.com/spiritLHLS/pve
2023-02-17 10:31:28 +08:00
# 打印信息
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
_green() { echo -e "\033[32m\033[01m$@\033[0m"; }
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
# 创建资源池
_green "正在创建资源池 mypool..."
pvesh create /pools --poolid mypool
_green "资源池 mypool 已创建!"
2023-02-24 09:40:10 +08:00
# 安装必备模块
2023-02-23 22:41:11 +08:00
apt-get update
2023-02-24 09:40:10 +08:00
apt-get install -y sudo
2023-02-23 22:41:11 +08:00
apt-get install -y ifupdown2
2023-02-23 23:10:52 +08:00
apt-get install -y lshw
2023-02-24 09:40:10 +08:00
apt-get install -y iproute2
apt-get install -y net-tools
2023-02-24 10:39:40 +08:00
apt-get install -y cloud-init
2023-02-24 14:00:22 +08:00
if ! dpkg -s novnc > /dev/null 2>&1 ; then
apt-get update
apt-get install -y novnc
echo "noVNC已成功安装"
else
echo "noVNC已安装"
fi
2023-02-24 10:39:40 +08:00
2023-02-23 22:41:11 +08:00
2023-02-17 10:16:17 +08:00
# 检测AppArmor模块
if ! dpkg -s apparmor > /dev/null 2>&1; then
2023-02-17 10:31:28 +08:00
_green "正在安装 AppArmor..."
2023-02-17 10:16:17 +08:00
apt-get update
apt-get install -y apparmor
fi
if ! systemctl is-active --quiet apparmor.service; then
2023-02-17 10:31:28 +08:00
_green "启动 AppArmor 服务..."
2023-02-17 10:16:17 +08:00
systemctl enable apparmor.service
systemctl start apparmor.service
fi
if ! lsmod | grep -q apparmor; then
2023-02-17 10:31:28 +08:00
_green "正在加载 AppArmor 内核模块..."
2023-02-17 10:16:17 +08:00
modprobe apparmor
fi
if ! lsmod | grep -q apparmor; then
2023-02-19 09:57:08 +08:00
_yellow "AppArmor 仍未加载可能需要重新启动系统加载但你可以在面板尝试创建并启动CT"
2023-02-17 10:16:17 +08:00
fi