From f95d45c36e7c7131747259956821d844e8952e5d Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Thu, 8 Jun 2017 10:53:01 +0000 Subject: nss-3.31 --- nss/automation/taskcluster/scripts/tools.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'nss/automation/taskcluster/scripts/tools.sh') diff --git a/nss/automation/taskcluster/scripts/tools.sh b/nss/automation/taskcluster/scripts/tools.sh index dacfdeb..46d567e 100644 --- a/nss/automation/taskcluster/scripts/tools.sh +++ b/nss/automation/taskcluster/scripts/tools.sh @@ -2,11 +2,21 @@ set -v -e -x +if [[ $(id -u) -eq 0 ]]; then + # Drop privileges by re-running this script. + # Note: this mangles arguments, better to avoid running scripts as root. + exec su worker -c "$0 $*" +fi + # Usage: hg_clone repo dir [revision=@] hg_clone() { repo=$1 dir=$2 rev=${3:-@} + if [ -d "$dir" ]; then + hg pull -R "$dir" -ur "$rev" "$repo" && return + rm -rf "$dir" + fi for i in 0 2 5; do sleep $i hg clone -r "$rev" "$repo" "$dir" && return -- cgit v1.2.1