#!/bin/bash
log_file="/var/log/openFuyao/bkeagent.log"
[ -f "$log_file" ] || touch "$log_file"
log() {
local msg=$1
echo "$(date +'%Y-%m-%d %H:%M:%S') INFO install-lxcfs.sh $msg" >> "$log_file"
echo "$(date +'%Y-%m-%d %H:%M:%S') INFO install-lxcfs.sh $msg"
}
if [ -f /etc/os-release ]; then
source /etc/os-release
os_type=$ID
os_version=$VERSION_ID
else
log "不支持的操作系统"
exit 1
fi
if [ ! -d "/var/lib/lxc/lxcfs" ]; then
log "创建目录 /var/lib/lxc/lxcfs"
mkdir -p /var/lib/lxc/lxcfs
fi
if [ "$os_type" == "ubuntu" ]; then
/etc/openFuyao/bkeagent/package-downloader.sh lxcfs
elif [ "$os_type" == "centos" ] && [ "$os_version" == "7" ]; then
/etc/openFuyao/bkeagent/package-downloader.sh lxcfs
/etc/openFuyao/bkeagent/package-downloader.sh fuse-libs
elif [ "$os_type" == "centos" ] && [ "$os_version" == "8" ]; then
/etc/openFuyao/bkeagent/package-downloader.sh lxcfs
elif [ "$os_type" == "kylin" ]; then
/etc/openFuyao/bkeagent/package-downloader.sh lxcfs
/etc/openFuyao/bkeagent/package-downloader.sh lxcfs-tools
elif [ "$os_type" == "openEuler" ]; then
log "openEuler not install lxcfs"
else
log "不支持的操作系统 $os_type $os_version"
exit 1
fi
modprobe fuse &> /dev/null
if [ -f /usr/lib/systemd/system/lxcfs.service ]; then
sed -i 's/\/var\/lib\/lxcfs/\/var\/lib\/lxc\/lxcfs/g' /usr/lib/systemd/system/lxcfs.service
systemctl daemon-reload
systemctl restart lxcfs
systemctl enable lxcfs
log "lxcfs 安装成功"
fi