Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom user for executing commands #764

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fi
# Define environment variables...
export APP_PORT=${APP_PORT:-80}
export APP_SERVICE=${APP_SERVICE:-"laravel.test"}
export APP_USER=${APP_USER:-sail}
export DB_PORT=${DB_PORT:-3306}
export WWWUSER=${WWWUSER:-$UID}
export WWWGROUP=${WWWGROUP:-$(id -g)}
Expand Down Expand Up @@ -211,7 +212,7 @@ if [ "$1" == "php" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "php")
else
Expand All @@ -225,7 +226,7 @@ elif [ "$1" == "bin" ]; then
if [ "$EXEC" == "yes" ]; then
CMD=$1
shift 1
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" ./vendor/bin/"$CMD")
else
Expand All @@ -237,7 +238,7 @@ elif [ "$1" == "docker-compose" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "${DOCKER_COMPOSE[@]}")
else
Expand All @@ -249,7 +250,7 @@ elif [ "$1" == "composer" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" "composer")
else
Expand All @@ -261,7 +262,7 @@ elif [ "$1" == "artisan" ] || [ "$1" == "art" ] || [ "$1" == "a" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan)
else
Expand All @@ -273,7 +274,7 @@ elif [ "$1" == "debug" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail -e XDEBUG_TRIGGER=1)
ARGS+=(exec -u "$APP_USER" -e XDEBUG_TRIGGER=1)
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan)
else
Expand All @@ -285,7 +286,7 @@ elif [ "$1" == "test" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan test)
else
Expand All @@ -297,7 +298,7 @@ elif [ "$1" == "phpunit" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/phpunit)
else
Expand All @@ -309,7 +310,7 @@ elif [ "$1" == "pest" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/pest)
else
Expand All @@ -321,7 +322,7 @@ elif [ "$1" == "pint" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php vendor/bin/pint)
else
Expand All @@ -333,7 +334,7 @@ elif [ "$1" == "dusk" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
Expand All @@ -347,7 +348,7 @@ elif [ "$1" == "dusk:fails" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=(-e "APP_URL=http://${APP_SERVICE}")
ARGS+=(-e "DUSK_DRIVER_URL=http://selenium:4444/wd/hub")
Expand All @@ -361,7 +362,7 @@ elif [ "$1" == "tinker" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" php artisan tinker)
else
Expand All @@ -373,7 +374,7 @@ elif [ "$1" == "node" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" node)
else
Expand All @@ -385,7 +386,7 @@ elif [ "$1" == "npm" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npm)
else
Expand All @@ -397,7 +398,7 @@ elif [ "$1" == "npx" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" npx)
else
Expand All @@ -409,7 +410,7 @@ elif [ "$1" == "pnpm" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpm)
else
Expand All @@ -421,7 +422,7 @@ elif [ "$1" == "pnpx" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" pnpx)
else
Expand All @@ -433,7 +434,7 @@ elif [ "$1" == "yarn" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" yarn)
else
Expand All @@ -445,7 +446,7 @@ elif [ "$1" == "bun" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bun)
else
Expand All @@ -457,7 +458,7 @@ elif [ "$1" == "bunx" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bunx)
else
Expand Down Expand Up @@ -508,7 +509,7 @@ elif [ "$1" == "shell" ] || [ "$1" == "bash" ]; then
shift 1

if [ "$EXEC" == "yes" ]; then
ARGS+=(exec -u sail)
ARGS+=(exec -u "$APP_USER")
[ ! -t 0 ] && ARGS+=(-T)
ARGS+=("$APP_SERVICE" bash)
else
Expand Down
Loading