-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappsync
More file actions
executable file
·149 lines (130 loc) · 3.71 KB
/
appsync
File metadata and controls
executable file
·149 lines (130 loc) · 3.71 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
141
142
143
144
145
146
147
148
149
#!/bin/bash
#
# Performs rsync from build to production
# Ruoshi Sun
function print_usage {
echo "Usage: `basename $0` EASYCONFIG"
echo " `basename $0` core easybuild/VERSION"
echo " `basename $0` vendor NAME/VERSION"
}
function print_error {
RED='\e[1;31m'
NC='\e[m'
echo -e "${RED}Error: $1${NC}"
echo
print_usage
exit 1
}
NARGS=$#
if [ $NARGS -eq 0 ]; then
print_usage
exit 0
fi
# directory name for software and modules
ml easybuild
read -r CFGS MODFILE SOFTWARE < <(
eb --show-config|awk '/^repository/ {print $4} /^subdir-modules/ {print $4} /^subdir-software/ {print $4}'|tr '\n' ' '
)
MODFILE=$(echo $MODFILE|sed 's@/.*$@@')
SOFTWARE=$(echo $SOFTWARE|sed 's@/.*$@@')
# determine source and destination for /apps
APP_SOURCE=$(realpath /apps)
if [ "$(basename $APP_SOURCE)" = "202412_build" ]; then
APP_DEST=${APP_SOURCE/_build/}
else
if [[ "$APP_SOURCE" == *"_build" ]]; then
APP_DEST=$(echo $APP_SOURCE | sed -e 's@weka@gpfs/tardis@' -e 's/_build//')
else
echo "WARNING: Syncing from YYYYMM to YYYYMM_build should only be done for special cases"
APP_DEST="$(echo $APP_SOURCE | sed 's@gpfs/tardis@weka@')"_build
fi
fi
for i in $APP_SOURCE $APP_DEST; do
if [ ! -d $i ]; then
print_error "Cannot find directory $i."
fi
done
if [ $NARGS -eq 2 ]; then
# Need to use realpath for vendor source and destination
# Do not use /apps or it will overwrite the vendor symlink
case $1 in
vendor)
APP_SOURCE=$(dirname $APP_SOURCE)/$1/installation
APP_DEST=$(dirname $APP_DEST)/$1/production
SOFTWARE_PATH=$SOFTWARE/$2
MODFILE_PATH=$MODFILE/$2.lua
;;
core)
# only for EasyBuild
if [[ ! $2 == "easybuild/"* ]]; then
print_error "You can only sync the easybuild module."
fi
SOFTWARE_PATH=$SOFTWARE/standard/$1/$2
MODFILE_PATH=$MODFILE/standard/$1/$2.lua
;;
*)
print_error "invalid category $1."
;;
esac
fi
echo "Source = $APP_SOURCE"
echo "Destination = $APP_DEST"
echo
# needed to rsync relative path names
# also ensures that easyconfig is read from $CFGS instead of $PWD
cd $APP_SOURCE
# standard module via easyconfig
if [ $NARGS -eq 1 ]; then
set -e
set -o pipefail
TMP=$(eb -D $1 2>/dev/null)
eval $(echo "$TMP"|grep "^CFGS=")
read -r EB PREFIX DIR < <(echo "$TMP"| awk '
/\[x\]/ {gsub(/\)$/,""); print $3, $(NF-2), $NF}
' | tail -1)
if [ $? -ne 0 ]; then
print_error "possible error in module installation."
fi
# e.g. openmpi/5.0.7 under gcc/14.2.0:
# PREFIX = standard/compiler/gcc/14.2.0
# LUA = openmpi/5.0.7.lua
# DIR = openmpi/5.0.7
# NAME = openmpi
PREFIX="standard/$PREFIX"
LUA="$DIR.lua"
# remove . from directory for hidden module
DIR="${DIR/\/./\/}"
NAME=$(dirname $DIR)
SOFTWARE_PATH=$SOFTWARE/$PREFIX/$DIR
MODFILE_PATH="$MODFILE/$PREFIX/$LUA"
# e.g. OpenMPI-5.0.7-NVHPC-25.3.eb:
# CFGS = /apps/ebscripts/easybuild/easyconfigs
# CFGS:6 = ebscripts/easybuild/easyconfigs
EB_PATH=${CFGS:6}/${EB:6}
fi
echo "== Paths
Software: $SOFTWARE_PATH
Modulefile: $MODFILE_PATH"
if [ $NARGS -eq 1 ]; then
echo "Easyconfig: $EB_PATH"
fi
echo
# check paths
read -p "== Perform rsync now? [y/N]" realrun
if [[ ! $realrun =~ ^[Yy]$ ]]; then
echo "== No changes performed."
exit 0
fi
echo "== Performing rsync..."
rsync -avR --delete $SOFTWARE_PATH $APP_DEST && \
rsync -avR $MODFILE_PATH $APP_DEST && \
if [ $NARGS -eq 1 ]; then
rsync -avR $EB_PATH $APP_DEST
fi
# check default symlink
DEFAULT=$MODFILE/$PREFIX/$NAME/default
if [ -e $DEFAULT ]; then
rsync -avR $DEFAULT $APP_DEST
fi
echo
echo "== Done."