Skip to content

Instantly share code, notes, and snippets.

@johanneswseitz
Created April 4, 2012 16:48
Show Gist options
  • Save johanneswseitz/2303751 to your computer and use it in GitHub Desktop.
Save johanneswseitz/2303751 to your computer and use it in GitHub Desktop.
Change Jenkins User
#!/bin/bash
#Execute with curl -sL https://raw.github.com/gist/2303751/fix-jenkins.sh | sudo sh
PLIST_PATH=/Library/LaunchDaemons/org.jenkins-ci
JENKINS_HOME=/Users/Shared/Jenkins/Home
if [[ $EUID -ne 0 ]]; then
echo "Execute this script with sudo"
else
echo "Jenkins will run as" $SUDO_USER
defaults write $PLIST_PATH UserName $SUDO_USER
defaults write $PLIST_PATH GroupName staff
echo "Changing owner of JENKINS_HOME"
chown -hR "$SUDO_USER:staff" $JENKINS_HOME
echo "Restarting Jenkins..."
launchctl unload "$PLIST_PATH.plist"
launchctl load "$PLIST_PATH.plist"
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment