-
-
Notifications
You must be signed in to change notification settings - Fork 320
/
run.sh
executable file
·80 lines (70 loc) · 1.48 KB
/
run.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
####
# Setup environment to run application in a docker container
#
# @todo:
#
#
# @author: stev leibelt <[email protected]>
# @since: 2024-01-31
####
function _build ()
{
# stop execution if one comand fails
set -e
local PATH_OF_THIS_SCRIPT
PATH_OF_THIS_SCRIPT=$(realpath "$(dirname "${0}")")
if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/adb.php ]];
then
wget -O "${PATH_OF_THIS_SCRIPT}"/adb.php https://raw.githubusercontent.com/MlgmXyysd/php-adb/master/src/adb.php
fi
if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/libraries/adb ]];
then
wget -O "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip https://dl.google.com/android/repository/platform-tools_r34.0.5-linux.zip
unzip -d "${PATH_OF_THIS_SCRIPT}"/libraries "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip
rm "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip
mv "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools/* "${PATH_OF_THIS_SCRIPT}"/libraries/
rmdir "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools
fi
}
function _main ()
{
case "${1}" in
bulid)
_build
;;
login)
_login
;;
start)
_start
;;
stop)
_stop
;;
*)
echo "Usage: ${0} {build|login|start|stop}"
return 1
;;
esac
}
function _login ()
{
_start
docker compose exec php-cli bash
}
function _start ()
{
_stop
_build
if command -v adb &> /dev/null;
then
adb kill-server
fi
docker compose up -d
}
function _stop ()
{
docker compose down
}
_main "${@}"