init deploy.sh
This commit is contained in:
parent
ab7a00c7c7
commit
c88f0c7112
35
testbed/scripts/deploy0.sh
Normal file
35
testbed/scripts/deploy0.sh
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
if [[ "$EUID" != "0" ]]; then
|
||||||
|
echo "Please run as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# root dotfiles
|
||||||
|
export http_proxy=http://192.168.16.118:8118 https_proxy=$http_proxy
|
||||||
|
apt update
|
||||||
|
apt install -y git vim zsh tmux
|
||||||
|
curl dotfiles.cn | bash -s - -al
|
||||||
|
chsh -s /bin/zsh
|
||||||
|
|
||||||
|
# ssh
|
||||||
|
sed -i "s/#Port 22/Port 12022/" /etc/ssh/sshd_config
|
||||||
|
sed -i "s/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0:12022/" /etc/ssh/sshd_config
|
||||||
|
systemctl restart ssh
|
||||||
|
|
||||||
|
# ufw
|
||||||
|
ufw allow 12022
|
||||||
|
ufw allow from 192.168.16.0/24
|
||||||
|
ufw default deny
|
||||||
|
ufw enable
|
||||||
|
|
||||||
|
# disable nouveau
|
||||||
|
bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
|
||||||
|
bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
|
||||||
|
cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
|
||||||
|
update-initramfs -u
|
||||||
|
|
||||||
|
echo "will reboot in 10 seconds... press ctrl-c to cancel."
|
||||||
|
sleep 10
|
||||||
|
reboot
|
86
testbed/scripts/deploy1.sh
Normal file
86
testbed/scripts/deploy1.sh
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#!/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
|
||||||
|
wget http://192.168.16.118/MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu22.04-x86_64.tgz
|
||||||
|
wget http://192.168.16.118/NVIDIA-Linux-x86_64-460.106.00.run
|
||||||
|
wget http://192.168.16.118/cuda_11.2.0_460.27.04_linux.run
|
||||||
|
|
||||||
|
# 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
|
||||||
|
x MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu22.04-x86_64.tgz
|
||||||
|
cd MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu22.04-x86_64
|
||||||
|
./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
|
||||||
|
sh /tmp/cuda_11.2.0_460.27.04_linux.run
|
||||||
|
|
||||||
|
# container
|
||||||
|
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) \
|
||||||
|
&& 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
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt install nvidia-container-runtime nvidia-container-toolkit
|
||||||
|
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
|
||||||
|
git clone https://git.nasp.ob.ac.cn/NASP/configurations
|
||||||
|
insert_if_not_exist "/etc/crontab" "59 23 * * * root \"$THIS_DIR\"/schedule-poweroff.sh"
|
||||||
|
cd /opt
|
||||||
|
git clone https://git.nasp.ob.ac.cn/NASP/registry
|
||||||
|
cd registry/scripts
|
||||||
|
./testbed_deploy.sh
|
||||||
|
|
||||||
|
echo "will reboot in 10 seconds... press ctrl-c to cancel."
|
||||||
|
sleep 10
|
||||||
|
reboot
|
6
testbed/scripts/deploy2.sh
Normal file
6
testbed/scripts/deploy2.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
nvidia-smi
|
||||||
|
ibv_devinfo
|
||||||
|
test -f /home/dictxiong/.ssh/authorized_keys
|
Loading…
Reference in New Issue
Block a user