Skip to content

Added configurable user for shell commands #779

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

Closed
wants to merge 2 commits 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
47 changes: 24 additions & 23 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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 @@ -213,7 +214,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 @@ -227,7 +228,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 @@ -241,7 +242,7 @@ elif [ "$1" == "run" ]; 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" "$CMD")
else
Expand All @@ -253,7 +254,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 @@ -265,7 +266,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 @@ -277,7 +278,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 @@ -289,7 +290,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 @@ -301,7 +302,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 @@ -313,7 +314,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 @@ -325,7 +326,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 @@ -337,7 +338,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 @@ -349,7 +350,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 @@ -363,7 +364,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 @@ -377,7 +378,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 @@ -389,7 +390,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 @@ -401,7 +402,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 @@ -413,7 +414,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 @@ -425,7 +426,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 @@ -437,7 +438,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 @@ -449,7 +450,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 @@ -461,7 +462,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 @@ -473,7 +474,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 @@ -524,7 +525,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