sourcezap/libexec/srczap/srczap-clone

42 lines
682 B
Text
Raw Normal View History

2024-05-11 21:43:59 +02:00
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-/usr/local}
libexec=$(dirname "$0")
git="${localbase}"/bin/git
giturl=$1
gitdir=$2
branch=$3
mode=u=rwX,g=rX,o=
##
# functions
gitexec()
{
doas -n -u _srczap \
/bin/sh -c "umask ${mode}; ${git} ${1}"
}
##
# main
if ! "${libexec}"/issrczap-member; then
echo "[-] This command must be run by a member of the '_srczap' group"
exit 1
fi
if [ -e "${gitdir}/.git" ]; then
echo "[-] ${gitdir} exists."
echo "[-] Try 'srczap pull'"
exit 1
fi
set -x
gitexec "clone ${giturl} ${gitdir}"
cd "${gitdir}"
gitexec "config core.filemode off"
2024-05-11 22:15:23 +02:00
gitexec "checkout -t origin/${branch}"
set +x
echo "[-] Done"