49 lines
904 B
Bash
Executable File
49 lines
904 B
Bash
Executable File
#!/bin/bash
|
|
# Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
|
|
PN=$(basename $0)
|
|
|
|
die ()
|
|
{
|
|
echo "$@" 1>&2;
|
|
exit 1
|
|
}
|
|
|
|
usage()
|
|
{
|
|
cat << EOT
|
|
Usage: $PN <user> <working-dir> [<gitarg1> <gitarg2>...]
|
|
|
|
Execute git command with user rights in selected working directory
|
|
EOT
|
|
}
|
|
|
|
if [ "$#" -le 3 ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
username="$1"
|
|
if ! id "$username" >/dev/null 2>&1; then
|
|
die "Unknown user $username"
|
|
fi
|
|
shift
|
|
workdir="$1"
|
|
shift
|
|
|
|
git_cmd=$(command -v git)
|
|
if [ "$?" != "0" ]; then
|
|
die "Command git does not found"
|
|
fi
|
|
|
|
export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
export GIT_SSH="/usr/local/psa/admin/sbin/modules/git/git_ssh"
|
|
export GIT_SSH_VARIANT=ssh
|
|
|
|
export PRESERVE_ENV="GIT_SSH,GIT_ASKPASS,GIT_PASS"
|
|
HOME=$(eval echo ~"$username")
|
|
export HOME
|
|
umask 022
|
|
|
|
/usr/local/psa/admin/sbin/filemng "$username" exec "$workdir" "$git_cmd" "$@"
|