Posted on 06-16-2020 10:11 AM
I've written this script and it's not quite working as intended, looking for some help.
Goal is to:
Get current logged in user.
Write a file; /Users/Shared/user_setupTEST.config.
Lone remaining issue:
Script doesn't pass the variable in to the new file, see the line folders: /$CurrentUserHome/Movies
#!/bin/bash
CurrentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
#Current user home folder
CurrentUserHome=(/Users/"$CurrentUser")
cat << 'EOF' > "/Users/Shared/user_setupTEST.config"
[Computers]
desktop_enabled: True
documents_enabled: True
pictures_enabled: True
folders: /$CurrentUserHome/Movies
high_quality_enabled: False
always_show_in_photos: False
# Delete mode can be: ALWAYS_SYNC_DELETES, ASK, NEVER_SYNC_DELETES
delete_mode: NEVER_SYNC_DELETES
[Settings]
autolaunch: True
show_overlays: False
EOF
exit 0
Posted on 06-16-2020 11:35 AM
CurrentUserHome="/Users/$CurrentUser"
. In my example I'm just getting what their actual home folder is rather than assuming (although typically it would be at /Users/username).#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
userHome=$(/usr/bin/dscl . read "/Users/$loggedInUser" NFSHomeDirectory | awk '{print $NF}')
cat << EOF > "/Users/Shared/user_setupTEST.config"
[Computers]
desktop_enabled: True
documents_enabled: True
pictures_enabled: True
folders: $userHome/Movies
high_quality_enabled: False
always_show_in_photos: False
# Delete mode can be: ALWAYS_SYNC_DELETES, ASK, NEVER_SYNC_DELETES
delete_mode: NEVER_SYNC_DELETES
[Settings]
autolaunch: True
show_overlays: False
EOF
exit 0
Posted on 06-16-2020 01:45 PM
@ryan.ball This is amazing thanks so much. I beat myself up with this for 2 days before reaching out for some expertise. Appreciate your time it works like a charm, I owe you a beer if we even have another live JNUC.