-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathactivate_app.bash
54 lines (48 loc) · 1.33 KB
/
activate_app.bash
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
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: $0 <application dir>"
exit 1
fi
APP_DIRPATH=${1}
SCRIPT_PATH=`readlink -f "$0"`
SCRIPT_DIR=`dirname ${SCRIPT_PATH}`
if [ ! -f ${APP_DIRPATH}/core_config.json ]
then
echo "ERROR: can not find ${APP_DIRPATH}/core_config.json"
exit 1
fi
if [[ "$(uname -r)" == *microsoft* ]]
then
export OS_TYPE=wsl2
elif [[ "$(uname)" == "Darwin" ]]
then
export OS_TYPE=Mac
else
export OS_TYPE=Linux
fi
export ARCH_TYPE=`arch`
APP_NAME=
if [ ${OS_TYPE} = "wsl2" ]
then
export ASSET_IPADDR=`cat /etc/resolv.conf | grep nameserver | awk '{print $NF}'`
NETWORK_INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$' | tr -d '\n')
export CORE_IPADDR=$(ip addr | grep inet | grep "${NETWORK_INTERFACE}" | awk '{print $2}' | awk -F/ '{print $1}')
bash ${SCRIPT_DIR}/third-party/mustache/mo ${SCRIPT_DIR}/template/win_core_config_json.tpl > ${APP_DIRPATH}/core_config.json
cd ${APP_DIRPATH}
APP_NAME=`find . -name "*.exe"`
./${APP_NAME}
elif [ ${OS_TYPE} = "Mac" ]
then
cd ${APP_DIRPATH}
BASE_NAME=`basename ${APP_DIRPATH}`
APP_NAME=`find ./${BASE_NAME}.app/Contents/MacOS -type f`
./${APP_NAME}
else
cd ${APP_DIRPATH}
BASE_NAME=`basename ${APP_DIRPATH}`
ARCH_TYPE=`arch`
APP_NAME=${BASE_NAME}.${ARCH_TYPE}
./${APP_NAME}
exit 1
fi