我现在正在尝试在 Mac OS 上为 jenkins 创建单独的用户并使用该用户运行它。
我创建了一个新用户:
# Create the group
sudo dscl . create /Groups/jenkins
sudo dscl . create /Groups/jenkins PrimaryGroupID 300
# Create the user
sudo dscl . create /Users/jenkins
sudo dscl . create /Users/jenkins PrimaryGroupID 300
sudo dscl . create /Users/jenkins UniqueID 300
sudo dscl . create /Users/jenkins UserShell /bin/bash
# Set the users pasword
sudo dscl . passwd /Users/jenkins 123qweASD
# Add the user to the group
sudo dscl . append /Groups/jenkins GroupMembership jenkins
我尝试以 jenkins 用户身份运行 jenkins:
sudo su - jenkins -c run_jenkins.sh
并得到一个错误:
su: no directory
在我为 jenkins 用户创建目录后:
sudo dscl . -create /Users/jenkins NFSHomeDirectory /Users/jenkins
随后发生下一个错误:
su: unknown login: jenkins
一般问题:
- 如何在没有主目录的情况下为守护进程创建类似 _www 的用户
- 我如何以新用户身份运行脚本。
感谢帮助!
man launchd.plist
UserName <string>
This optional key specifies the user to run the job as. This key is only
applicable when launchd is running as root.
GroupName <string>
This optional key specifies the group to run the job as. This key is only
applicable when launchd is running as root. If UserName is set and Group-
Name is not, the the group will be set to the default group of the user.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)