This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathconfigure_cluster.sh
More file actions
executable file
·140 lines (119 loc) · 4.82 KB
/
Copy pathconfigure_cluster.sh
File metadata and controls
executable file
·140 lines (119 loc) · 4.82 KB
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
#!/bin/bash
NGENCERF_APP=/ngencerf-app
REPOS=(
"ngencerf-ui"
"ngencerf-server"
"ngencerf-docker"
"ngen"
"nwm-cal-mgr"
"ngen-forcing"
"nwm-fcst-mgr"
"nwm-verf"
)
# ------------------------------------------------------------------------------
# Helper: Prompt user with a message, then open the file in an editor
# ------------------------------------------------------------------------------
edit_file_with_message() {
local file="$1"
local message="$2"
echo
echo "================================================================================"
echo "$message"
echo
echo "When you're done, save and exit your editor (e.g., :wq in vim)."
echo "================================================================================"
echo
read -p "Press ENTER to open $file..." _
# Fallback chain: $EDITOR -> vim -> vi
if [[ -n "$EDITOR" ]]; then
"$EDITOR" "$file"
elif command -v vim >/dev/null 2>&1; then
vim "$file"
else
vi "$file"
fi
}
cd $NGENCERF_APP
# ------------------------------------------------------------------------------
# Clone Repositories
# ------------------------------------------------------------------------------
echo "Cloning repos..."
echo
for repo in "${REPOS[@]}"; do
if [[ ! -d "$repo" ]]; then
if [[ "$repo" == "ngen" ]]; then
git clone -b development --recurse-submodules https://github.com/NGWPC/$repo.git
# initialize and update submodules to correct commit
git submodule update --init --recursive
else
git clone -b development https://github.com/NGWPC/$repo.git
fi
else
echo "$repo already exists, skipping clone."
fi
echo
done
# ------------------------------------------------------------------------------
# Configure ngencerf-server
# ------------------------------------------------------------------------------
cd ngencerf-server
# Only copy if override file doesn't exist
if [[ ! -f ngencerf_services.override.env ]]; then
echo "Creating ngencerf_services.override.env from template..."
cp ngencerf_services.env ngencerf_services.override.env
else
echo "Override file already exists: ngencerf_services.override.env"
fi
echo
edit_file_with_message "ngencerf_services.override.env" \
"Update database user, password, host and EDFS URL in this file."
edit_file_with_message ".env" \
"Update paths and tags in this file."
# ------------------------------------------------------------------------------
# Load static data
# ------------------------------------------------------------------------------
echo "Loading static data directory..."
STATIC_DIR="$NGENCERF_APP/data/ngen-cal-data/ngen-static-files"
SOURCE_DIR="$NGENCERF_APP/nwm-cal-mgr/module_parameter_files"
if [[ -d "$STATIC_DIR" ]]; then
echo "Static data directory already exists at $STATIC_DIR"
echo "Skipping module_parameter_files copy and S3 sync."
else
echo "Creating static data directory..."
sudo mkdir -p "$STATIC_DIR"
sudo chown -R $(whoami):pwuser $NGENCERF_APP/data/ngen-cal-data
sudo chmod -R g+rwx $NGENCERF_APP/data/ngen-cal-data
if [[ ! -d "$STATIC_DIR/module_parameter_files" ]]; then
echo "Copying module_parameter_files directory from nwm-cal-mgr repo..."
cp --archive "$SOURCE_DIR" "$STATIC_DIR/"
else
echo "Skipping copy: module_parameter_files already exists in $STATIC_DIR"
fi
edit_file_with_message "/tmp/aws.credentials" \
"Paste export statements for your AWS credentials in this file. These are temporary credentials to copy the static files"
source /tmp/aws.credentials
echo
echo "Copying data from NGWPC data bucket..."
aws s3 sync s3://ngwpc-dev/ngen-static-files "$STATIC_DIR/"
rm -f /tmp/aws.credentials
fi
# ------------------------------------------------------------------------------
# Pull/build Docker images and build Singularity containers
# ------------------------------------------------------------------------------
echo
echo "Building Singularity containers..."
$NGENCERF_APP/nwm-automation-scripts/parallel_works_scripts/build_cluster.sh --build-type=development all
# ------------------------------------------------------------------------------
# Copy nginx-unprivileged.sif to singularity directory
# ------------------------------------------------------------------------------
echo
echo "Building nginx Singularity container if it doesn't exist..."
if [[ ! -f "$NGENCERF_APP/singularity/nginx-unprivileged.sif" ]]; then
cd $NGENCERF_APP
mkdir -p singularity
git clone https://github.com/parallelworks/interactive_session.git
cp interactive_session/downloads/jupyter/nginx-unprivileged.sif singularity/
rm -rf interactive_session
else
echo "nginx-unprivileged.sif already exists in $NGENCERF_APP/singularity/"
fi