You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.4 KiB
Bash
77 lines
1.4 KiB
Bash
#!/bin/bash
|
|
####
|
|
# Setup environment to run application in a docker container
|
|
#
|
|
# @todo:
|
|
#
|
|
#
|
|
# @author: stev leibelt <artodeto@bazzline.net>
|
|
# @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
|
|
docker compose up -d
|
|
}
|
|
|
|
function _stop ()
|
|
{
|
|
docker compose down
|
|
}
|
|
|
|
_main "${@}"
|