Closed RKCZ closed 5 years ago
Can you install getent in that shell? If not, do you know how to detect when the script is running in that shell and execute an alternate command to get the user’s full name?
Iif not, just comment out line 11 and be sure to set your name manually via
sqitch config --user user.name "You Fullname"
Hi @RKCZ, any thoughts on this?
Hi, I tried looking for a way to install getent in docker toolbox and on my personal pc I found it can probably use getent provided by Cygwin if it is installed. I can't say for sure if the Cygwin version is compatible because of cygwin issue on my side.
I think that the best way would be to find full name with some windows provided command to avoid the need to install cygwin. Not sure if this is the optimal way but I have found user's full name with command net user <username>
. I am not an expert on how this command works so maybe there is some option to show just the full name without other info.
Platform on which script is executed could be possibly determined as it is with uname command. For me it shows MINGW64_NT-
Thanks. Does this patch work for you?
--- a/docker-sqitch.sh
+++ b/docker-sqitch.sh
@@ -13,8 +13,12 @@ passopt=(
)
# Handle OS-specific options.
-if [ "Darwin" = $(uname) ]; then
+os=$(uname)
+if [ "Darwin" = "$os" ]; then
passopt+=(-e "SQITCH_ORIG_FULLNAME=$(id -P $user | awk -F '[:]' '{print $8}')")
+elif [ "MINGW64_NT" = "$os" ]; then
+ passopt+=(-e "SQITCH_ORIG_FULLNAME=$(net user $user)")
+ passopt+=(-u $(id -u ${user}):$(id -g ${user}))
else
passopt+=(-e "SQITCH_ORIG_FULLNAME=$(getent passwd $user | cut -d: -f5 | cut -d, -f1)")
passopt+=(-u $(id -u ${user}):$(id -g ${user}))
Better attempt to also cover Cygwin, more easily add other OS variants in the future:
--- a/docker-sqitch.sh
+++ b/docker-sqitch.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Determine which Docker image to run.
SQITCH_IMAGE=${SQITCH_IMAGE:=sqitch/sqitch:latest}
@@ -13,12 +13,21 @@ passopt=(
)
# Handle OS-specific options.
-if [ "Darwin" = $(uname) ]; then
- passopt+=(-e "SQITCH_ORIG_FULLNAME=$(id -P $user | awk -F '[:]' '{print $8}')")
-else
- passopt+=(-e "SQITCH_ORIG_FULLNAME=$(getent passwd $user | cut -d: -f5 | cut -d, -f1)")
- passopt+=(-u $(id -u ${user}):$(id -g ${user}))
-fi
+case "$(uname -s)" in
+ Linux*)
+ passopt+=(-e "SQITCH_ORIG_FULLNAME=$(getent passwd $user | cut -d: -f5 | cut -d, -f1)")
+ passopt+=(-u $(id -u ${user}):$(id -g ${user}))
+ ;;
+ Darwin*)
+ passopt+=(-e "SQITCH_ORIG_FULLNAME=$(id -P $user | awk -F '[:]' '{print $8}')")
+ ;;
+ MINGW*|CYGWIN*)
+ passopt+=(-e "SQITCH_ORIG_FULLNAME=$(net user $user)")
+ ;;
+ *)
+ echo "Unknown OS: $(uname -s)"
+ ;;
+esac
# Iterate over optional Sqitch and engine variables.
for var in \
@@ -38,7 +47,7 @@ done
# Determine the name of the container home directory.
homedst=/home
-if [ $(id -u) -eq 0 ]; then
+if [ $(id -u ${user}) -eq 0 ]; then
homedst=/root
fi
I pushed that last patch in 119970a. LMK if it doesn't work for you.
Hello,
when docker-sqitch shell script is executed on Docker toolbox quickstart terminal for Windows 7 following message appears: