-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_unpack.sh
executable file
·52 lines (48 loc) · 1.4 KB
/
_unpack.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
#!/bin/bash
Usage() {
echo "Usage: $0 --mode <install|uninstall> [--remove-cache <true|false>] [--install-dir <install-dir>] [--help]"
echo "args can be one or more of the following :"
echo " --mode | -m : Mode of operation. Default: install"
echo " --remove-cache | -r : Remove cache. Default: true"
echo " --install-dir : Installation directory. Default: $HOME/.homecli"
echo " --help | -h : Show this help message"
exit 1
}
while true; do
case "$1" in
--mode | -m)
MODE=$2
if [ "$MODE" != "install" ] && [ "$MODE" != "uninstall" ]; then
echo "invalid argument: $MODE (should be install or uninstall)"
Usage
fi
shift 2
;;
--remove-cache | -r)
REMOVE_CACHE=$2
shift 2
;;
--install-dir)
INSTALL_DIR=$2
shift 2
;;
--help | -h)
Usage
;;
-*)
echo "Unknown option: $1"
Usage
;;
*)
break
;;
esac
done
MODE=${MODE:-install}
INSTALL_DIR=${INSTALL_DIR:-$HOME/.homecli}
REMOVE_CACHE=${REMOVE_CACHE:-true}
if [ "$MODE" = "install" ]; then
./install.sh --mode unpack --install-dir $INSTALL_DIR --tarfile homecli.tar.gz --old-install-dir /home/runner/.homecli
elif [ "$MODE" = "uninstall" ]; then
./uninstall.sh --remove-cache $REMOVE_CACHE --install-dir $INSTALL_DIR
fi