From: mwolson_admin Date: Wed, 14 Nov 2007 03:38:56 +0000 (-0500) Subject: run-in-pagsh: Figure out what user we're running as X-Git-Url: https://git.hcoop.net/hcoop/scripts.git/commitdiff_plain/4ead870dfc40bf8955b1e324141b11de46aad40c run-in-pagsh: Figure out what user we're running as Cron can be stupid sometimes and set LOGNAME, but not USER. --- diff --git a/run-in-pagsh b/run-in-pagsh index a8bcef8..5ef0e24 100755 --- a/run-in-pagsh +++ b/run-in-pagsh @@ -51,6 +51,18 @@ K5PID=$HOME/.run/$1.pid shift CMD="$*" +# Try to deduce the user we're running as. +if test -z "$USER"; then + if test -n "$LOGNAME"; then + USER=$LOGNAME + elif test -n "$HOME"; then + USER=$(basename "$HOME") + else + echo "Error: cannot deduce your username" + exit 1 + fi +fi + # Your keytab file. KTAB=/etc/keytabs/user.daemon/$USER