From 0bbc4eedd7741312168986b8b624169a7f81338a Mon Sep 17 00:00:00 2001 From: toxa Date: Sun, 29 Jan 2023 12:23:38 +0300 Subject: [PATCH] * windows adjust docker cmd --- bash/_docker-cmd.sh | 15 +++++++++++++++ bash/composer-set-to-1.sh | 18 ++++++++++++++++++ bash/composer-set-to-2.sh | 18 ++++++++++++++++++ bash/enter-to-workspace.sh | 7 ++++++- bash/mysql.sh | 6 +++++- bash/restart-nginx.sh | 6 +++++- bash/root-onto-workspace.sh | 18 ++++++++++++++++++ 7 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 bash/_docker-cmd.sh create mode 100644 bash/composer-set-to-1.sh create mode 100644 bash/composer-set-to-2.sh create mode 100644 bash/root-onto-workspace.sh diff --git a/bash/_docker-cmd.sh b/bash/_docker-cmd.sh new file mode 100644 index 0000000..fa8bd4e --- /dev/null +++ b/bash/_docker-cmd.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Grab OS type +if [[ "$(uname)" == "Darwin" ]]; then + OS_TYPE="OSX" +else + OS_TYPE=$(expr substr $(uname -s) 1 5) +fi + +DOCKER_CMD=docker + +if [[ $OS_TYPE == "MINGW" ]]; then + DOCKER_CMD="winpty docker" +fi + +export DOCKER_CMD \ No newline at end of file diff --git a/bash/composer-set-to-1.sh b/bash/composer-set-to-1.sh new file mode 100644 index 0000000..ca63b7f --- /dev/null +++ b/bash/composer-set-to-1.sh @@ -0,0 +1,18 @@ +#!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + +PHP_VERSION=$1 # Without dot + +if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi + +CONTAINER=$(docker ps | grep workspace${PHP_VERSION} | awk '{print $1}') + + +if [[ -z "${CONTAINER}" ]]; then + echo "Unable to find container: workspace${PHP_VERSION}" + exit 1 +fi + +$DOCKER_CMD exec -ti ${CONTAINER} composer self-update --1 diff --git a/bash/composer-set-to-2.sh b/bash/composer-set-to-2.sh new file mode 100644 index 0000000..18cb9dd --- /dev/null +++ b/bash/composer-set-to-2.sh @@ -0,0 +1,18 @@ +#!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + +PHP_VERSION=$1 # Without dot + +if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi + +CONTAINER=$(docker ps | grep workspace${PHP_VERSION} | awk '{print $1}') + + +if [[ -z "${CONTAINER}" ]]; then + echo "Unable to find container: workspace${PHP_VERSION}" + exit 1 +fi + +$DOCKER_CMD exec -ti ${CONTAINER} composer self-update --2 diff --git a/bash/enter-to-workspace.sh b/bash/enter-to-workspace.sh index e809f91..311d1e5 100755 --- a/bash/enter-to-workspace.sh +++ b/bash/enter-to-workspace.sh @@ -1,13 +1,18 @@ #!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + PHP_VERSION=$1 # Without dot if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi CONTAINER=$(docker ps | grep workspace${PHP_VERSION} | awk '{print $1}') + if [[ -z "${CONTAINER}" ]]; then echo "Unable to find container: workspace${PHP_VERSION}" exit 1 fi -docker exec -ti ${CONTAINER} su laradock +$DOCKER_CMD exec -ti ${CONTAINER} su laradock diff --git a/bash/mysql.sh b/bash/mysql.sh index 6a63bf9..2e2fc01 100755 --- a/bash/mysql.sh +++ b/bash/mysql.sh @@ -1,4 +1,8 @@ #!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + CONTAINER=$(docker ps | grep mariadb | awk '{print $1}') if [[ -z "${CONTAINER}" ]]; then @@ -6,4 +10,4 @@ if [[ -z "${CONTAINER}" ]]; then exit 1 fi -docker exec -ti ${CONTAINER} bash -c 'LANG=ru_RU.UTF-8 mysql -u root -p123456' +$DOCKER_CMD exec -ti ${CONTAINER} bash -c 'LANG=ru_RU.UTF-8 mysql -u root -p123456' diff --git a/bash/restart-nginx.sh b/bash/restart-nginx.sh index d390941..4dd5866 100755 --- a/bash/restart-nginx.sh +++ b/bash/restart-nginx.sh @@ -1,4 +1,8 @@ #!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + CONTAINER=$(docker ps | grep nginx | awk '{print $1}') if [[ -z "${CONTAINER}" ]]; then @@ -6,4 +10,4 @@ if [[ -z "${CONTAINER}" ]]; then exit 1 fi -docker exec -ti ${CONTAINER} nginx -s reload \ No newline at end of file +$DOCKER_CMD exec -ti ${CONTAINER} nginx -s reload \ No newline at end of file diff --git a/bash/root-onto-workspace.sh b/bash/root-onto-workspace.sh new file mode 100644 index 0000000..4d91dc8 --- /dev/null +++ b/bash/root-onto-workspace.sh @@ -0,0 +1,18 @@ +#!/bin/bash +. ./_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + +PHP_VERSION=$1 # Without dot + +if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi + +CONTAINER=$(docker ps | grep workspace${PHP_VERSION} | awk '{print $1}') + + +if [[ -z "${CONTAINER}" ]]; then + echo "Unable to find container: workspace${PHP_VERSION}" + exit 1 +fi + +$DOCKER_CMD exec -ti ${CONTAINER}