-
Notifications
You must be signed in to change notification settings - Fork 0
/
print-instance-args_main.sh
executable file
·42 lines (41 loc) · 1.11 KB
/
print-instance-args_main.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
#!/bin/bash
NAME=`basename $( dirname ${BASH_SOURCE[0]} )`
if [ "${NAME}" == "." ]; then
NAME=`basename $(pwd)`
fi
DIRNAME=`dirname ${BASH_SOURCE[0]}`
DIRNAME=`readlink -f ${DIRNAME}`
if [ "${DIRNAME}" == "." ]; then
DIRNAME=`pwd`
fi
INSTANCECOUNT=0
for i in ${DIRNAME}/print-instance-args_*.sh ; do
INSTANCE=`basename $i ` #Just the file
INSTANCE=${INSTANCE:20} #Remove the first 20 chars (print-instance-args_)
INSTANCE="_"${INSTANCE:0:-3} #Remove the last 3 chars (.sh)
if [ "${INSTANCE:1}" == "main" ]; then
INSTANCE=""
fi
if [ "${INSTANCE:1}" == "*" ]; then
break;
else
INSTANCECOUNT=` expr ${INSTANCECOUNT} + 1 `
fi
if [ "${1}" == "${INSTANCE:1}" ]; then
if [ "${MATCHED}" == "1" ]; then
break
fi
if [ "${1}" == "${INSTANCE:1}" ]; then
MATCHED=1
fi
#Do this for each of them (or the match)
#echo Name: ${NAME}, DirName: ${DIRNAME}, Instance: ${INSTANCE:1}, Counter: ${INSTANCECOUNT}.
echo '--init'
echo '--label VPN=false'
echo '-v /mnt/mounts/:/mnt/mounts/'
fi
done
if [ "${INSTANCECOUNT}" == "0" ]; then
echo ${0}: No instances found, nothing was done. >&2
fi
#EXTRA Run: -it