#!/bin/bash

# Run with admin privileges
osascript -e 'do shell script "
HOSTS_FILE=\"/etc/hosts\"
SERVER_NAME=\"DeLeoServer\"
SERVER_IP=\"192.168.0.37\"
ENTRY=\"$SERVER_IP $SERVER_NAME\"

cp \"$HOSTS_FILE\" \"${HOSTS_FILE}.backup\"
grep -v -i \"$SERVER_NAME\" \"$HOSTS_FILE\" > \"${HOSTS_FILE}.tmp\" || true
mv \"${HOSTS_FILE}.tmp\" \"$HOSTS_FILE\"
echo \"\" >> \"$HOSTS_FILE\"
echo \"$ENTRY\" >> \"$HOSTS_FILE\"

dscacheutil -flushcache
killall -HUP mDNSResponder
" with administrator privileges'

# Show success message
osascript -e 'display dialog "DeLeoServer has been added to your Mac!\n\nTo connect:\n1. Open Finder\n2. Press Command+K\n3. Type: smb://DeLeoServer/S-DRIVE\n4. Click Connect\n5. Enter your username and password" buttons {"OK"} default button 1 with title "Setup Complete" with icon note'

