NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / sys / unix / hints / macosx.sh
blob7ff5b32c9e592359be8f51d3447951f190313f98
1 #!/bin/sh
2 # aNetHack 0.0.1 macosx.sh $ANH-Date: 1455930387 2016/02/20 01:06:27 $ $ANH-Branch: master $:$ANH-Revision: 1.16 $
3 # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
4 # aNetHack may be freely redistributed. See license for details.
6 # hints helper script for macosx
7 # DO NOT invoke directly.
9 # Works for 10.4 and 10.5. (The 10.5 support might work for 10.4 but keep
10 # both versions in case we need to support earlier versions.)
12 cmd=$1
14 case "x$cmd" in
15 xuser)
16 # fail unless user exists (good through 10.4)
17 user=$2
18 gotuser=`niutil -readval . /users/$user name 0 2>/dev/null`
19 [ -z $gotuser ] && (echo "User $user does not exist."
20 exit 1;
24 #name: dummy1
25 #_writers_passwd: dummy1
26 #_writers_tim_password: dummy1
27 #_writers_picture: dummy1
28 #home: /Users/dummy1
29 #gid: 504
30 #picture: /Library/User Pictures/Animals/Dragonfly.tif
31 #uid: 504
32 #hint: dummy1
33 #_writers_hint: dummy1
34 #sharedDir:
35 #_shadow_passwd:
36 #_writers_realname: dummy1
37 #shell: /bin/bash
38 #passwd: ********
39 #authentication_authority: ;ShadowHash;
40 #realname: dummyname1
41 #generateduid: F6D4991C-BDF5-481F-A407-D84C6A2D0E2A
43 xgroup)
44 # fail unless group exists (good through 10.4)
45 group=$2
46 gotgrp=`niutil -readval . /groups/$group name 0 2>/dev/null`
47 [ -z $gotgrp ] && ( echo "Group $group does not exist."
48 exit 1
52 #niutil -read . /groups/bin name 0
53 #name: bin
54 #gid: 7
55 #passwd: *
56 #generateduid: ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000007
57 #smb_sid: S-1-5-21-107
58 #realname: Binary
60 xuser2)
61 # fail unless user exists (required as of 10.5)
62 user=$2
63 if( dscl localhost -read /Search/Users/$user 1>/dev/null 2>&1 );
64 then
65 true;
66 else
67 echo "User $user does not exist.";
68 exit 1;
72 xgroup2)
73 # if group does not exist, create it (required as of 10.5)
74 group=$2
75 [ -z $group ] && ( echo "No group specified."
76 exit 1
78 if( dscl localhost -read /Search/Groups/$group 1>/dev/null 2>&1 );
79 then
80 true;
81 else
82 echo "Group $group does not exist - creating.";
83 dseditgroup -o create -r "Games Group" -s 3600 $group
84 if( dscl localhost -read /Search/Groups/$group 1>/dev/null 2>&1 );
85 then
86 true;
87 else
88 echo "Unable to create group $group."
89 exit 1
94 xeditsysconf)
95 src=$2
96 dest=$3
97 # we should traverse the elements of $PATH instead
98 if [ -f /usr/bin/gdb ]; then
99 gdbpath='GDBPATH=/usr/bin/gdb' #traditional location
100 elif [ -f /opt/local/bin/ggdb ]; then
101 gdbpath='GDBPATH=/opt/local/bin/ggdb' #macports gdb
102 elif [ -f /Developer/usr/bin/gdb ]; then
103 # this one seems to be broken with Xcode 5.1.1 on Mountain Lion
104 gdbpath='GDBPATH=/Developer/usr/bin/gdb' #recent Xcode tools
105 else
106 gdbpath='#GDBPATH' #none of the above
108 if [ -f /bin/grep ]; then
109 greppath='GREPPATH=/bin/grep'
110 elif [ -f /usr/bin/grep ]; then
111 greppath='GREPPATH=/usr/bin/grep'
112 else
113 greppath='#GREPPATH'
115 # PANICTRACE_GDB value should only be replaced if gdbpath is '#GDBPATH'
116 if ! [ -e $dest ]; then
117 sed -e "s:^GDBPATH=.*:$gdbpath:" \
118 -e "s:^GREPPATH=.*:$greppath:" \
119 -e 's/^PANICTRACE_GDB=[12]/PANICTRACE_GDB=0/' \
120 -e 's/^#OPTIONS=.*/&\
121 OPTIONS=!use_darkgray/' \
122 $src > $dest
126 #% dscl localhost -read /Search/Groups/wheel
127 # AppleMetaNodeLocation: /Local/Default
128 # GeneratedUID: ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000
129 # GroupMembership: root
130 # Password: *
131 # PrimaryGroupID: 0
132 # RealName:
133 # System Group
134 # RecordName: wheel
135 # RecordType: dsRecTypeStandard:Groups
136 # SMBSID: S-1-5-21-100
138 xdescplist) SVSDOT=`util/makedefs --svs .`
139 cat <<E_O_M;
140 <?xml version="1.0" encoding="UTF-8"?>
141 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
142 <plist version="1.0">
143 <dict>
144 <key>IFPkgDescriptionDeleteWarning</key>
145 <string></string>
146 <key>IFPkgDescriptionDescription</key>
147 <string>aNetHack $SVSDOT for the MacOS X Terminal
148 </string>
149 <key>IFPkgDescriptionTitle</key>
150 <string>aNetHack</string>
151 <key>IFPkgDescriptionVersion</key>
152 <string>$SVSDOT</string>
153 </dict>
154 </plist>
155 E_O_M
158 xinfoplist) SVSDOT=`util/makedefs --svs .`
159 cat <<E_O_M;
160 <?xml version="1.0" encoding="UTF-8"?>
161 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
162 <plist version="1.0">
163 <dict>
164 <key>CFBundleGetInfoString</key>
165 <string>aNetHack $SVSDOT for the MacOS X Terminal</string>
166 <key>CFBundleIdentifier</key>
167 <string>org.aanethack.term</string>
168 <key>CFBundleName</key>
169 <string>aNetHack</string>
170 <key>CFBundleShortVersionString</key>
171 <string>$SVSDOT</string>
172 <key>IFMajorVersion</key>
173 <integer>3</integer>
174 <key>IFMinorVersion</key>
175 <integer>3</integer>
176 <key>IFPkgFlagAllowBackRev</key>
177 <true/>
178 <key>IFPkgFlagAuthorizationAction</key>
179 <string>RootAuthorization</string>
180 <key>IFPkgFlagDefaultLocation</key>
181 <string>/</string>
182 <key>IFPkgFlagInstallFat</key>
183 <false/>
184 <key>IFPkgFlagIsRequired</key>
185 <false/>
186 <key>IFPkgFlagOverwritePermissions</key>
187 <true/>
188 <key>IFPkgFlagRelocatable</key>
189 <false/>
190 <key>IFPkgFlagRestartAction</key>
191 <string>NoRestart</string>
192 <key>IFPkgFlagRootVolumeOnly</key>
193 <false/>
194 <key>IFPkgFlagUpdateInstalledLanguages</key>
195 <false/>
196 <key>IFPkgFlagUseUserMask</key>
197 <false/>
198 <key>IFPkgFormatVersion</key>
199 <real>0.10000000149011612</real>
200 </dict>
201 </plist>
202 E_O_M
205 *) echo "Unknown command $cmd"
206 exit 1
208 esac
210 # dscl localhost -read /Search/Users/games
211 # dsAttrTypeNative:_writers_hint: games
212 # dsAttrTypeNative:_writers_jpegphoto: games
213 # dsAttrTypeNative:_writers_LinkedIdentity: games
214 # dsAttrTypeNative:_writers_passwd: games
215 # dsAttrTypeNative:_writers_picture: games
216 # dsAttrTypeNative:_writers_realname: games
217 # dsAttrTypeNative:_writers_UserCertificate: games
218 # AppleMetaNodeLocation: /Local/Default
219 # AuthenticationAuthority: ;ShadowHash; ;Kerberosv5;;games@LKDC:SHA1.3F695B215C78511043D9787CA51DE92E6494A021;LKDC:SHA1.3F695B215C78511043D9787CA51DE92E6494A021;
220 # AuthenticationHint: games
221 # GeneratedUID: A727EFB1-D6AA-4FE2-8524-0E154890E9A9
222 # NFSHomeDirectory: /Users/games
223 # Password: ********
224 # Picture:
225 # /Library/User Pictures/Flowers/Sunflower.tif
226 # PrimaryGroupID: 20
227 # RealName: games
228 # RecordName: games
229 # RecordType: dsRecTypeStandard:Users
230 # UniqueID: 505
231 # UserShell: /bin/bash
233 # see also: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/additionalfeatures/chapter_10_section_9.html
235 # another mess: 10.4 creates a group for every user, 10.5 dumps you into staff.
236 # so I think we need to explicitly create group games in both (if it doesn't
237 # exist) and use owner bin (nope that fails since everything seems to be owned
238 # by root. Do we want that? How about just creating user games as well?)
240 # [Hermes:sys/unix/hints] keni% dscl localhost -read /Search/Users/games9
241 # <dscl_cmd> DS Error: -14136 (eDSRecordNotFound)
242 # [Hermes:sys/unix/hints] keni% dscl localhost -read /Search/Users/games9 >/dev/null
243 # <dscl_cmd> DS Error: -14136 (eDSRecordNotFound)
244 # [Hermes:sys/unix/hints] keni% dscl localhost -read /Search/Users/games > /dev/null
245 # status is good: 0 or 56
247 # file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/releasenotes/MacOSXServer/RN-DirectoryServices/index.html