#!/bin/bash

set -x
arch=$(uname -m)
match="amd64"
if [ "$arch" == "aarch64" ] ; then
    match="arm64"
elif [ "$arch" == "x86_64" ] ; then
    match="amd64"
else
    echo "Unkown arch $arch"
    exit 1
fi

nodeName=`hostname`
nodename=${nodeName,,}
cp -r config.toml.tmpl /var/lib/rancher/k3s/agent/etc/containerd/
systemctl daemon-reload && systemctl restart k3s
#systemctl restart containerd #no docker no containerd for systemd
sleep 5s
#k3s ctr image import ascend-k8sdeviceplugin-$match.tar
kubectl label node $nodename accelerator=huawei-Ascend310P
mkdir -p /var/log/mindx-dl/devicePlugin
kubectl apply -f device-plugin-310P-$match.yaml
set +x
