Last active
February 13, 2018 13:56
-
-
Save 04n0/ccc6c3fe5c2e5e03f5c31ad8c9a65a2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
date > /etc/box_build_time | |
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}') | |
# Set computer/hostname | |
COMPNAME=vagrant-macos | |
scutil --set ComputerName "${COMPNAME}" | |
scutil --set HostName "${COMPNAME}" | |
# Packer passes boolean user variables through as '1', but this might change in | |
# the future, so also check for 'true'. | |
if [ "$INSTALL_VAGRANT_KEYS" = "true" ] || [ "$INSTALL_VAGRANT_KEYS" = "1" ]; then | |
echo "Installing vagrant keys for $USERNAME user" | |
mkdir "/Users/$USERNAME/.ssh" | |
chmod 0700 "/Users/$USERNAME/.ssh" | |
curl -L 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' > "/Users/$USERNAME/.ssh/authorized_keys" | |
chmod 0600 "/Users/$USERNAME/.ssh/authorized_keys" | |
chown -R "$USERNAME" "/Users/$USERNAME/.ssh" | |
fi | |
# Create a group and assign the user to it | |
dseditgroup -o create "$USERNAME" | |
dseditgroup -o edit -a "$USERNAME" "$USERNAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment