#!/bin/zsh -e

## Copyright © 2012-2014, 2024 Apple Inc. All rights reserved.
##
## IMPORTANT NOTE: This file is licensed only for use on Apple-branded
## computers and is subject to the terms and conditions of the Apple Software
## License Agreement accompanying the package this file is a part of.
## You may not port this file to another platform without Apple's written consent.

## Store vnc server settings in the file
## "/Library/Preferences/com.apple.VNCSettings.txt"

## Must be run sudo (EUID 0) with environment variable VNCSETTINGS
## containing the encoded settings string.

[ "x$EUID"         = "x0" ]	     ## Exit unless root
[ "x$VNCSETTINGS" != "x"  ]	     ## Exit unless value specified.

VNCSETTINGSFILE="/Library/Preferences/com.apple.VNCSettings.txt"

 /usr/bin/touch        "$VNCSETTINGSFILE"
     /bin/chmod 600    "$VNCSETTINGSFILE"

print "$VNCSETTINGS" > "$VNCSETTINGSFILE"

/usr/sbin/chown 0      "$VNCSETTINGSFILE"
 /usr/bin/chgrp 0      "$VNCSETTINGSFILE"
     /bin/chmod 400    "$VNCSETTINGSFILE"
