diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-08 10:53:01 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-08 10:53:01 +0000 |
commit | f95d45c36e7c7131747259956821d844e8952e5d (patch) | |
tree | eee14f8b212c48f8597c2a4927a167fcc3a15ea5 /nss/automation/taskcluster/scripts/tools.sh | |
parent | dc1565216a5d20ae0d75872151523252309a1292 (diff) | |
download | nss-master.tar.gz |
Diffstat (limited to 'nss/automation/taskcluster/scripts/tools.sh')
-rw-r--r-- | nss/automation/taskcluster/scripts/tools.sh | 10 |
1 files changed, 10 insertions, 0 deletions
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 |