File jenkins-agent-workdir.sh of Package jenkins-agent

#!/bin/sh
# Prepare a working directory for the Jenkins Agent
# Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>

set -Ceu

WD="$JENKINS_AGENT_WORK_DIR"
WD_DEFAULT='/var/opt/jenkins'

# Custom working directory, symlinking to default:
if [ ! "$WD" == "$WD_DEFAULT" ]
then
	if [ ! -L "$WD_DEFAULT" ]
	then
		ln -fs "$WD" "$WD_DEFAULT"
	fi
fi

# Default but non-existing working directory, creating:
if [ "$WD" == "$WD_DEFAULT" ] && [ ! -d "$WD_DEFAULT" ]
then
	rm -f "$WD_DEFAULT" # could be a symlink if the user switches back from a custom directory
	install -o jenkins-agent -g jenkins-agent -dm0750 "$WD_DEFAULT"
fi
openSUSE Build Service is sponsored by