-
Notifications
You must be signed in to change notification settings - Fork 263
/
preflight.sh
40 lines (33 loc) · 982 Bytes
/
preflight.sh
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
#!/bin/bash
echo "Running preflight.sh"
# Command Flags:
# PLATFORM (Required, must be "gke" or "gce")
#
# Example to invoke this script:
# bash preflight.sh PLATFORM=[GCE or GKE]
# Warning:
# For any dependencies, please add them into `setup.sh` or `maxtext_dependencies.Dockerfile`.
# You should not install any dependencies in this file.
# Stop execution if any command exits with error
set -e
# Set environment variables
for ARGUMENT in "$@"; do
IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
export "$KEY"="$VALUE"
done
if [ -z $PLATFORM ]; then
echo "Error: PLATFORM flag is missing."
exit 1
fi
# Check if sudo is available
if command -v sudo >/dev/null 2>&1; then
# sudo is available, use it
echo "running rto_setup.sh with sudo"
# apply network settings.
sudo bash rto_setup.sh
else
# sudo is not available, run the script without sudo
echo "running rto_setup.sh without sudo"
# apply network settings.
bash rto_setup.sh
fi