-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.proenv
More file actions
executable file
·44 lines (39 loc) · 1.12 KB
/
test.proenv
File metadata and controls
executable file
·44 lines (39 loc) · 1.12 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
#!/usr/bin/env bash
REPO="$(git rev-parse --show-toplevel)"
BRANCH=main
URL_BASE=https://github.com/optdyn
MOD_SHORT=test
MOD_NAME=proenv-${MOD_SHORT}-module
MOD_BASE=${URL_BASE}/${MOD_NAME}
REPO_ZIP=${MOD_BASE}/archive/refs/heads/${BRANCH}.zip
ZIP_FILE=${MOD_NAME}.zip
# download and extract
mkdir -p "${REPO}/.proenv/modules"
cd "${REPO}/.proenv/modules"
curl -fsSL $REPO_ZIP -o $ZIP_FILE
VERSION_HASH="$(unzip "${ZIP_FILE}" | grep --only-matching -E '^[a-f0-9]*')"
rm -f ${ZIP_FILE}
rm -rf ${MOD_NAME}
mv ${MOD_NAME}-${BRANCH} ./${MOD_NAME}
echo ${BRANCH} > ${MOD_NAME}/BRANCH
echo ${VERSION_HASH} > ${MOD_NAME}/HEAD
# links and perms
cd ..
chmod +x modules/${MOD_NAME}/bin/*
mkdir -p bin
cd bin
for binfile in ../modules/${MOD_NAME}/bin/*; do
if [[ ! -f ./"$(basename "${binfile}")" ]]; then
ln -s ${binfile} $(basename ${binfile})
else
ln -s ${binfile} ${MOD_SHORT}-$(basename ${binfile})
fi
done
cd ../etc
for etcfile in ../modules/${MOD_NAME}/etc/*; do
if [[ ! -f ./"$(basename "${etcfile}")" ]]; then
ln -s ${etcfile} $(basename ${etcfile})
else
ln -s ${etcfile} ${MOD_SHORT}-$(basename ${etcfile})
fi
done