Last active
August 9, 2018 14:22
-
-
Save HodGreeley/a298336b9425a31560f669468d2cf7f1 to your computer and use it in GitHub Desktop.
macOS command line to create user to run a service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use these to see the current list of users and groups, to select unique user and groud ids. | |
dscacheutil -q user | awk 'BEGIN { ORS="" } /name/ { print $2 " " } /uid/ { print $2 "\n" }' | sort -unk 2 | |
dscacheutil -q group | awk 'BEGIN { ORS="" } /name/ { print $2 " " } /gid/ { print $2 "\n" }' | sort -unk 2 | |
# I chose 400 for both uid and gid based on what's in use on my own machine. | |
# DO NOT use 400 without checking it's available first. | |
sudo dscl . -create /Groups/_sync_gateway | |
sudo dscl . -create /Groups/_sync_gateway PrimaryGroupID 400 | |
sudo dscl . -create /Users/_sync_gateway UniqueID 400 | |
sudo dscl . -create /Users/_sync_gateway PrimaryGroupID 400 | |
sudo dscl . -create /Users/_sync_gateway UserShell /usr/bin/false | |
sudo dscl . -create /Users/_sync_gateway NFSHomeDirectory /Users/sync_gateway | |
sudo mkdir /Users/sync_gateway | |
sudo chown _sync_gateway:_sync_gateway /Users/sync_gateway | |
# Run the Sync Gateway macOS install script, with the option to assign the user to run under. | |
sudo ./sync_gateway_service_install.sh --runas=_sync_gateway | |
# Check Sync Gateway is running | |
# Look for, e.g., active count = 1, state = running | |
sudo launchctl print system/com.couchbase.mobile.sync_gateway |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment