configurations/testbed/scripts/deploy1.sh

92 lines
3.1 KiB
Bash
Raw Permalink Normal View History

2023-04-28 16:39:12 +08:00
#!/bin/bash
set -ex
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
if [[ "$EUID" != "0" ]]; then
echo "Please run as root."
exit 1
fi
# resolv
systemctl disable --now systemd-resolved
rm /etc/resolv.conf
cat << EOF > /etc/resolv.conf
nameserver 192.168.16.118
nameserver 166.111.8.28
nameserver 166.111.8.29
nameserver 114.114.114.114
EOF
# preparation
apt update
apt install -y make cmake python3 python3-pip gcc-10 g++-10 dkms net-tools ethtool
ethtool -s eno1 wol g
cd /tmp
2023-11-22 20:14:14 +08:00
wget http://192.168.16.118/MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu22.04-x86_64.tgz
2023-04-28 16:39:12 +08:00
wget http://192.168.16.118/NVIDIA-Linux-x86_64-460.106.00.run
2023-11-22 20:14:14 +08:00
# wget http://192.168.16.118/cuda_11.2.0_460.27.04_linux.run
2023-04-28 16:39:12 +08:00
# mlnx ofed
apt install -y pkg-config swig bison dpatch m4 libnl-3-dev autoconf automake libnl-route-3-dev chrpath quilt libgfortran5 libltdl-dev libfuse2 debhelper flex gfortran autotools-dev tk graphviz libnl-route-3-200
2023-11-22 20:14:14 +08:00
x MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu22.04-x86_64.tgz
cd MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu22.04-x86_64
2023-04-28 16:39:12 +08:00
./mlnxofedinstall --skip-unsupported-devices-check
/etc/init.d/openibd restart
# nvidia gpu
cd /tmp
#update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
#update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
# see: https://louwrentius.com/unattended-automatic-installation-of-linux-nvidia-binary-driver.html
sh /tmp/NVIDIA-Linux-x86_64-460.106.00.run -q -a -n -X -s
2023-11-22 20:14:14 +08:00
# sh /tmp/cuda_11.2.0_460.27.04_linux.run
2023-04-28 16:39:12 +08:00
# container
2023-11-22 20:14:14 +08:00
export http_proxy=http://192.168.16.118:8118 https_proxy=$http_proxy
2023-04-28 16:39:12 +08:00
cd /tmp
curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh --mirror Aliyun
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
2023-11-22 20:14:14 +08:00
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
2023-04-28 16:39:12 +08:00
apt update
2023-11-22 20:14:14 +08:00
apt install -y nvidia-container-runtime nvidia-container-toolkit
2023-04-28 16:39:12 +08:00
nvidia-ctk runtime configure --runtime=docker
systemctl restart docker
mkdir /etc/systemd/system/docker.service.d
cat << EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.16.118:8118"
Environment="HTTPS_PROXY=http://192.168.16.118:8118"
EOF
systemctl daemon-reload
systemctl restart docker
# conf from git
insert_if_not_exist()
{
filename=$1
line=$2
if [ ! -f "$filename" ]; then
touch $filename
fi
grep -qxF -- "$line" "$filename" || echo "$line" >> "$filename"
}
cd /opt
2024-04-16 00:36:48 +08:00
git clone https://git.nasp.fit/NASP/configurations
2023-11-22 20:14:14 +08:00
insert_if_not_exist "/etc/crontab" "59 22 * * * root /opt/configurations/testbed/scripts/schedule-poweroff.sh"
2023-04-28 16:39:12 +08:00
cd /opt
2024-04-16 00:36:48 +08:00
git clone https://git.nasp.fit/NASP/registry
2023-04-28 16:39:12 +08:00
cd registry/scripts
./testbed_deploy.sh
2023-04-29 19:27:43 +08:00
# scripts
2023-11-22 20:14:14 +08:00
cp /opt/configurations/testbed/scripts/dnew /usr/local/bin/
2023-04-29 19:27:43 +08:00
2023-04-28 16:39:12 +08:00
echo "will reboot in 10 seconds... press ctrl-c to cancel."
sleep 10
reboot