File size: 5,979 Bytes
45361be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
#!/bin/bash
# Copyright (c) 2023 Habana Labs, Ltd. an Intel Company.Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)"
source $SOURCE_DIR/config.properties
export PDSH_RCMD_TYPE=ssh
HOSTFILE="${HOSTFILE:-$SOURCE_DIR/hostfile}";
BASE_PDSH_CMD="pdsh -w ^$HOSTFILE"
BASE_DIR="$SOURCE_DIR/utilities"
if [ -z "$(dpkg -l | awk "/^ii pdsh/")" ]; then
echo "!!!! ERROR: pdsh is not installed in your system. Please install pdsh before proceeding !!!!"
exit 1
fi
show_help()
{
cat <<EOF
Usage: ./configure_system.sh [-c command] [-r command] [-p command] [-d command] [-h]
-c configure ... Configure Command to setup ssh, hugepages, duplicate_repo, duplicate_datasets, all
i.e (./configure_system.sh -c ssh, ssh_home, hugepages, duplicate_repo, duplicate_datasets, all)
-r reload ... Reload (driver)
i.e (./configure_system.sh -r driver)
-p ports ... Control/check Gaudi Network Ports (up, down, status, idc)
i.e (./configure_system.sh -p status)
-d docker ... Configure Docker Environment (install-compose, pull-base)
i.e (./configure_system.sh -p status)
-s ............. Secret Commands. Used to run any bash commands
-h ............. Optional; show help
This wrapper script configures and updates nodes specified in hostfile
Requirements:
- pdsh
EOF
}
eval "$(ssh-agent -s)"
ssh-add "$SOURCE_DIR/ssh/mint_rsa"
while getopts :c:r:p:d:s:h flag
do
case "${flag}" in
c) action=${OPTARG}
case "$action" in
"ssh")
$BASE_DIR/setup_passwordless_ssh.sh
;;
"ssh_home")
$BASE_DIR/setup_home_directory.sh
;;
"hugepages")
$BASE_PDSH_CMD "$BASE_DIR/set_hugepages.sh"
;;
"cpu")
$BASE_PDSH_CMD "echo -n "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor"
;;
"install_driver")
$BASE_PDSH_CMD "$BASE_DIR/kubevirt_docker.sh $DRIVER_VERSION"
;;
"duplicate_repo")
$BASE_PDSH_CMD mkdir -p $DOCKER_DIR
$BASE_PDSH_CMD mkdir -p $SOURCE_DIR
for IP in `cat $HOSTFILE`; do
rsync -ahvzgop $DOCKER_DIR/ $USER@$IP:$DOCKER_DIR
rsync -ahvzgop --exclude "$DOCKER_DIR" $SOURCE_DIR/ $USER@$IP:$SOURCE_DIR
done
;;
"duplicate_dataset")
$BASE_PDSH_CMD mkdir -p $DATASET_DIR
echo "Experimental!!! Running sequentially and not preferred method of copying large datasets to x machines"
for IP in `cat $HOSTFILE`; do
rsync -ahvzgop $DATASET_DIR/ $USER@$IP:$DATASET_DIR
done
;;
"all")
sudo apt-get install pdsh -y
$BASE_DIR/setup_passwordless_ssh.sh
$BASE_PDSH_CMD mkdir -p $DOCKER_DIR
$BASE_PDSH_CMD mkdir -p $SOURCE_DIR
for IP in `cat $HOSTFILE`; do
rsync -ahvzgop $DOCKER_DIR/ $USER@$IP:$DOCKER_DIR
rsync -ahvzgop --exclude "$DOCKER_DIR" $SOURCE_DIR/ $USER@$IP:$SOURCE_DIR
done
$BASE_PDSH_CMD "$BASE_DIR/set_hugepages.sh"
$BASE_PDSH_CMD "echo -n "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor"
;;
*)
echo "No action chosen. Exiting now ..."
exit 0
;;
esac
;;
r) action=${OPTARG}
case "$action" in
"driver")
$BASE_PDSH_CMD "$BASE_DIR/reload_driver.sh"
;;
*)
echo "No action chosen. Exiting now ..."
exit 0
;;
esac
;;
p) action=${OPTARG}
case "$action" in
"up")
$BASE_PDSH_CMD "$BASE_DIR/manage_network_ifs.sh --up --l3"
;;
"down")
$BASE_PDSH_CMD "$BASE_DIR/manage_network_ifs.sh --down"
;;
"status")
$BASE_PDSH_CMD "$BASE_DIR/manage_network_ifs.sh --status"
;;
"idc")
$BASE_PDSH_CMD "$BASE_DIR/l3-routes.sh "
;;
*)
echo "No action chosen. Exiting now ..."
exit 0
;;
esac
;;
d) action=${OPTARG}
case "$action" in
"install-compose")
$BASE_PDSH_CMD "$BASE_DIR/install_docker_compose.sh"
;;
"pull-base")
$BASE_PDSH_CMD "docker pull $BASE_IMAGE"
;;
*)
echo "No action chosen. Exiting now ..."
exit 0
;;
esac
;;
s)
shift 1;
$BASE_PDSH_CMD "$@"
;;
h) show_help >&2; exit 0 ;;
*) show_help >&2; exit 0 ;;
esac
done
|