applied-ai-018's picture
Add files using upload-large-folder tool
45361be verified
#!/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