<commit_before>#!/bin/bash
set -eux

# This script adds a Mac OS Launch Daemon, which runs on first boot
PLIST=/Library/LaunchDaemons/com.macstadium.set-hostname.plist
cat <<EOF > "${PLIST}"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.github.timsutton.osx-vm-templates.detectnewhardware</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/sbin/networksetup</string>
        <string>-detectnewhardware</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
EOF

# This script sets a random hostname
cat <<-EOF > /usr/local/bin/set-random-hostname
#!/bin/bash
set -eu
scutil –-set HostName "$(sed "$(perl -e "print int rand(99999)")q;d" /usr/share/dict/words | awk '{print tolower($0)}')"
EOF

/bin/chmod 644 "${PLIST}" "/usr/local/bin/set-random-hostname"
/usr/sbin/chown root:wheel "${PLIST}" "/usr/local/bin/set-random-hostname"<commit_msg>Turns out you need to quote 'EOF'<commit_after>#!/bin/bash
set -eux

# This script adds a Mac OS Launch Daemon, which runs on first boot
PLIST=/Library/LaunchDaemons/com.macstadium.vmkite.set-random-hostname.plist
cat <<EOF > "${PLIST}"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.macstadium.vmkite.set-random-hostname</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/set-random-hostname</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
EOF

# This script sets a random hostname
cat << 'EOF' > /usr/local/bin/set-random-hostname
#!/bin/bash
set -eu
RANDOM_WORDS="$(sed "$(perl -e "print int rand(99999)")q;d" /usr/share/dict/words | awk '{print tolower($0)}')"
scutil –-set HostName "vmkite-${RANDOM_WORDS}"
EOF

/bin/chmod 644 "${PLIST}" "/usr/local/bin/set-random-hostname"
/usr/sbin/chown root:wheel "${PLIST}" "/usr/local/bin/set-random-hostname"
{'fraction_non_alphanumeric': 0.19491525423728814, 'fraction_numerical': 0.01694915254237288, 'mean_word_length': 3.9649532710280373, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 2, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '782311', 'n_tokens_mistral': 850, 'n_tokens_neox': 806, 'n_words': 163}