-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·124 lines (115 loc) · 3.11 KB
/
setup
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
#!/usr/bin/env bash
#
# VM-utility installation
#
# Check usage below.
set -e
#######################################
# DEFAULT VALUES
#######################################
VMU_HOME=$(dirname $(realpath $BASH_SOURCE))
BIN_DIR="/usr/local/bin"
INTERACTIVE=
#######################################
# FUNCTIONS
#######################################
usage() {
echo "VM-utility installation"
echo
echo "Usage: setup [options] [directory]"
echo
echo "Create links to vm-utility tools in a destination directory."
echo "If no arguments are given the tools are made available for all"
echo "users by linking them to the /usr/local/bin directory."
echo
echo "Examples:"
echo
echo " sudo ./setup"
echo " Do a default global install."
echo
echo " ./setup ~/bin"
echo " Install the VM-utility tools in your own ~/bin/ directory."
echo
echo "Options:"
echo " -h, --help Displays help on commandline options."
echo " -i, --interactive Prompts whether to remove destinations"
echo " when linking the executables."
echo
echo "Arguments:"
echo " directory The path where executable utility tools"
echo " are linked so that they can be easily"
echo " added to the PATH."
echo " Default: /usr/local/bin"
}
#######################################
# EXECUTION
#######################################
#######################################
# Handling command line arguments
#######################################
if ! OPTS="$(getopt \
--longoptions help,interactive \
--options hi \
--name "$(basename "$0")" \
-- "$@"
)"; then
usage
exit 1
fi
eval set -- "$OPTS"
while true; do
case "$1" in
--help|-h)
usage;
exit
;;
--interactive|-i)
INTERACTIVE="-i"
shift
;;
--)
shift
break
;;
*)
echo "DEBUG: No implementation for the option $1"
exit 1
;;
esac
done
ARGS=("$@")
ARGCOUNT=${#ARGS[@]}
if [ "$ARGCOUNT" -eq "1" ]; then
BIN_DIR="${ARGS[0]}"
elif [ "$ARGCOUNT" -gt "1" ]; then
echo "Too many arguments supplied."
usage
exit 1
fi
#######################################
# Main Execution
#######################################
echo "Linking executables to $BIN_DIR .."
mkdir -p $BIN_DIR
ln -fsv $INTERACTIVE -t $BIN_DIR \
$VMU_HOME/vmu-config \
$VMU_HOME/vmu-calls \
$VMU_HOME/network/net-calls \
$VMU_HOME/multipass/mp-calls \
$VMU_HOME/multipass/mp-ssh \
$VMU_HOME/multipass/mp-launch \
$VMU_HOME/multipass/mp-route \
$VMU_HOME/multipass/mp-delete \
$VMU_HOME/jenkins/vm-agent/launch-vm-agent \
$VMU_HOME/jenkins/vm-controller/launch-vm-jenkins \
$VMU_HOME/ssh/make-ssh-tunnel \
$VMU_HOME/ssh/rm-ssh-tunnel \
$VMU_HOME/installers/multipass/setup-multipass \
$VMU_HOME/installers/docker/setup-docker \
$VMU_HOME/installers/jenkins/dind/run-dind \
$VMU_HOME/installers/jenkins/dind/run-jenkins \
$VMU_HOME/development/config-nano \
$VMU_HOME/development/config-git \
$VMU_HOME/development/dev-vm \
$VMU_HOME/development/mp-purge
echo "vm-utility installed."