forked from HauptmannBoosted/ngcp-csc-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.sh
executable file
·64 lines (55 loc) · 1.73 KB
/
dev.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
CSC_SYS_PATH="/usr/share/ngcp-csc/csc"
CSC_TMP_PATH="/usr/share/ngcp-csc/csc.orig"
CSC_PATH="$PWD/dist"
if [ ! -e "$CSC_SYS_PATH" ]; then
mkdir -p "$CSC_SYS_PATH"
fi
CSC_LINK_TARGET=""
if [ -L "$CSC_SYS_PATH" ]; then
CSC_LINK_TARGET=$(readlink "$CSC_SYS_PATH")
fi
ARGS="$*";
case "$1" in
reset)
if [ -L "$CSC_SYS_PATH" ]; then
rm "$CSC_SYS_PATH"
echo "Removed link to development version $CSC_SYS_PATH -> $CSC_LINK_TARGET"
fi
if [ -d "$CSC_TMP_PATH" ]; then
mv "$CSC_TMP_PATH" "$CSC_SYS_PATH"
echo "Restored release version $CSC_TMP_PATH -> $CSC_SYS_PATH"
fi
;;
*)
i=0
while [ "$i" -lt "$#" ]; do
next=$(("$i + 1"))
case "${ARGS[$i]}" in
-p)
if [ "${ARGS[$next]}" != "" ]; then
CSC_PATH="${ARGS[$next]}"
else
echo "Path to development version must not be empty" >&2
exit 1;
fi
;;
-*)
echo "Invalid option ${ARGS[$i]}" >&2
exit 1;
;;
esac
i=$(("$i + 1"))
done
if [ ! -d "$CSC_PATH" ]; then
echo "Path to development version is not a directory '$CSC_PATH'" >&2
exit 1;
fi
if [ ! -L "$CSC_SYS_PATH" -a ! -d "$CSC_TMP_PATH" ]; then
mv "$CSC_SYS_PATH" "$CSC_TMP_PATH"
ln -s -f "$CSC_PATH" "$CSC_SYS_PATH"
fi
echo "Link to development version $CSC_SYS_PATH -> $(readlink ${CSC_SYS_PATH})"
echo "Release temporary moved to $CSC_TMP_PATH"
;;
esac