|
Lines 46-51
Link Here
|
| 46 |
|
46 |
|
| 47 |
scriptpath = [] |
47 |
scriptpath = [] |
| 48 |
desktopFolderName = "Eigene Shares" |
48 |
desktopFolderName = "Eigene Shares" |
|
|
49 |
desktopFolderNameMac = listener.configRegistry.get('ucsschool/userlogon/mac/foldername', desktopFolderName) |
| 49 |
globalLinks = {} |
50 |
globalLinks = {} |
| 50 |
|
51 |
|
| 51 |
strTeacher = listener.baseConfig.get('ucsschool/ldap/default/container/teachers', 'lehrer') |
52 |
strTeacher = listener.baseConfig.get('ucsschool/ldap/default/container/teachers', 'lehrer') |
|
Lines 132-144
Link Here
|
| 132 |
|
133 |
|
| 133 |
|
134 |
|
| 134 |
def generateMacScript(uid, name, host): |
135 |
def generateMacScript(uid, name, host): |
| 135 |
return '''#!/bin/sh # generated script for accessing a samba share |
136 |
return '''#!/usr/bin/osascript |
| 136 |
/usr/bin/osascript <<EOF |
|
|
| 137 |
tell application "Finder" |
137 |
tell application "Finder" |
| 138 |
open location "smb://%s@%s/%s" |
138 |
open location "smb://%s@%s/%s" |
| 139 |
activate |
139 |
activate |
| 140 |
end tell |
140 |
end tell |
| 141 |
EOF |
|
|
| 142 |
''' % (uid, host, name) |
141 |
''' % (uid, host, name) |
| 143 |
|
142 |
|
| 144 |
def writeMacLinkScripts(uid, homepath, links): |
143 |
def writeMacLinkScripts(uid, homepath, links): |
|
Lines 154-184
Link Here
|
| 154 |
except: |
153 |
except: |
| 155 |
pass |
154 |
pass |
| 156 |
|
155 |
|
| 157 |
if not os.path.exists(os.path.join(homepath, "Desktop", desktopFolderName)): |
156 |
if not os.path.exists(os.path.join(homepath, "Desktop", desktopFolderNameMac)): |
| 158 |
if not os.path.exists(homepath): |
157 |
if not os.path.exists(homepath): |
| 159 |
os.mkdir(homepath, 0700) |
158 |
os.mkdir(homepath, 0700) |
| 160 |
os.chown(homepath, uidnumber, gidnumber) |
159 |
os.chown(homepath, uidnumber, gidnumber) |
| 161 |
|
160 |
|
| 162 |
for path in [os.path.join(homepath, "Desktop"), os.path.join(homepath, "Desktop", desktopFolderName)]: |
161 |
for path in [os.path.join(homepath, "Desktop"), os.path.join(homepath, "Desktop", desktopFolderNameMac)]: |
| 163 |
if not os.path.exists(path): |
162 |
if not os.path.exists(path): |
| 164 |
os.mkdir(path) |
163 |
os.mkdir(path) |
| 165 |
os.chown(path, uidnumber, gidnumber) |
164 |
os.chown(path, uidnumber, gidnumber) |
| 166 |
|
165 |
|
| 167 |
# remove old scripts |
166 |
# remove old scripts |
| 168 |
for file in os.listdir(os.path.join(homepath, "Desktop", desktopFolderName)): |
167 |
for file in os.listdir(os.path.join(homepath, "Desktop", desktopFolderNameMac)): |
| 169 |
try: |
168 |
try: |
| 170 |
os.remove(os.path.join(homepath, "Desktop", desktopFolderName,file)) |
169 |
if os.path.isdir(os.path.join(homepath, "Desktop", desktopFolderNameMac,file)): |
|
|
170 |
shutil.rmtree(os.path.join(homepath, "Desktop", desktopFolderNameMac,file)) |
| 171 |
else: |
| 172 |
os.remove(os.path.join(homepath, "Desktop", desktopFolderNameMac,file)) |
| 171 |
except: |
173 |
except: |
| 172 |
univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR, "ucsschool-user-logonscripts: failed to remove %s" % file) |
174 |
univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR, "ucsschool-user-logonscripts: failed to remove %s" % file) |
| 173 |
raise |
175 |
raise |
| 174 |
|
176 |
|
| 175 |
for name in links: |
177 |
for name in links: |
| 176 |
macscriptpath = os.path.join(homepath, "Desktop", desktopFolderName, "%s.app" % name) |
178 |
macscriptpath = os.path.join(homepath, "Desktop", desktopFolderNameMac, "%s.app" % name) |
| 177 |
fp = open(macscriptpath ,'w') |
179 |
os.mkdir(macscriptpath) |
| 178 |
fp.write(generateMacScript(uid, name, links[name]).replace('\n','\r\n')) |
|
|
| 179 |
fp.close() |
| 180 |
os.chmod(macscriptpath, 0500) |
| 181 |
os.chown(macscriptpath, uidnumber, gidnumber) |
180 |
os.chown(macscriptpath, uidnumber, gidnumber) |
|
|
181 |
macscriptfile = os.path.join(macscriptpath, name) |
| 182 |
fp = open(macscriptfile ,'w') |
| 183 |
fp.write(generateMacScript(uid, name, links[name])) |
| 184 |
fp.close() |
| 185 |
os.chmod(macscriptfile, 0700) |
| 186 |
os.chown(macscriptfile, uidnumber, gidnumber) |
| 182 |
finally: |
187 |
finally: |
| 183 |
listener.unsetuid() |
188 |
listener.unsetuid() |
| 184 |
|
189 |
|