-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·38 lines (29 loc) · 1001 Bytes
/
build.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
#!/bin/bash
cat docs/header.txt | grep -v ^# > usage.txt
SCRIPTS="$(ls scripts | grep -v \\.)"
for SCRIPT in $SCRIPTS; do
PAD="$(printf '%0.1s' " "{1..25})"
PAD_LENGTH="25"
if [ ${#SCRIPT} -gt $PAD_LENGTH ]; then
echo "ERROR: script name must be <= $PAD_LENGTH."
exit 1
fi
col1="$(printf '%s%*.*s' "$SCRIPT" 0 $((PAD_LENGTH - ${#SCRIPT} )) "$PAD")"
while read LINE; do
if [ -z "$LINE" ]; then
echo "[WARN] script '$SCRIPT' is missing \"SHORT_DESCRIPTION=\". Skipping..."
continue
fi
printf "%s %s\n" "$col1" "$LINE" >> usage.txt
col1="$PAD"
done <<< "$(cat scripts/$SCRIPT | sed -n -E "s/^SHORT_DESCRIPTION=\"(.*)\"/\1/p" | fold -w 60 -s)"
done
cat docs/footer.txt | grep -v ^# >> usage.txt
rm -frd out/
mkdir -p out/scripts
cp main.sh ./out/
cp usage.txt ./out/
cp -a ./keys/. ./out/keys/
cp -a ./scripts/. ./out/scripts/
# pass gitsha to /register endpoint
sed -i 's/PV_GITSHA=GITSHA/PV_GITSHA='$(git rev-parse --verify HEAD | cut -c1-7)'/g' ./out/scripts/install