Help with policy script

Gerard_Allen
New Contributor

Hi all,

I'm having weird problems with the MountNetworkShare.sh . Nothing has been modified except to input the network path but it returns with:

/usr/sbin/jamf is version 8.62 Executing Policy Run Script mountNetworkShare.sh... Creating directory structure for /Library/Application Support/JAMF/Downloads/ Downloading http://<serveraddressremoved>:80/CasperShare/Scripts/mountNetworkShare.sh... Running script mountNetworkShare.sh... Script exit code: 2 Script result: /private/tmp/mountNetworkShare.sh: line 1: syntax error near unexpected token `newline' /private/tmp/mountNetworkShare.sh: line 1: `<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'

It looks like it's converting it to a html doc and can't execute but why???

1 ACCEPTED SOLUTION

bentoms
Release Candidate Programs Tester

Try running the script over AFP/SMB & not HTTP.

View solution in original post

17 REPLIES 17

jdziat
Contributor

Can you post your script and just remove any sensitive data? Looks like either you uploaded the incorrect file or maybe didnt save it as a plain text file but its hard to know for sure with the given information.

bentoms
Release Candidate Programs Tester

Try running the script over AFP/SMB & not HTTP.

leslie
Contributor II
Contributor II

Wonder what app you used to edit the script, if it embedded some html and also saved it with windows rather then Unix line endings. Would suggest editing the script with something like TextWrangler.

deej
New Contributor III

Check the permissions of the file on the distribution point. Your clients are downloading it over HTTP and getting a 403 - Permission Denied web response from the web server servicing that point.

deej
New Contributor III

Hint: Open Terminal and type:

curl http://<serveraddressremoved>:80/CasperShare/Scripts/mountNetworkShare.sh

What you see in your Terminal window is exactly what the Casper client is receiving and attempting to execute.

Gerard_Allen
New Contributor

OK, when I curl it I'm told that it has moved to https
When I curl the https url I get:
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Gerard_Allen
New Contributor

Thanks to everybody for your help on this. Still don't know why it's flipping to https but switching it to ditto over AFP/SMB worked!

jarednichols
Honored Contributor

Scripts should run fine over HTTP. Let's address root cause and not a band-aid. What did you open/edit the script with and what server OS is your JSS?

bentoms
Release Candidate Programs Tester

As Jared says, my suggestion was merely a bandaid.

Next steps would be to test further to resolve the issue now you know the script is good & can be deployed.

Gerard_Allen
New Contributor

Script was created and edited in textedit - converted to plain text.
Server OS is 10.7.4

daworley
Contributor II

Can you run the script locally, and get the proper http download?
What does the curl command above return to you?

Gerard_Allen
New Contributor

The script runs fine locally.

Here's what I get when I try to curl the script:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://<serverremoved>/CasperShare/Scripts/mountNetworkShare.sh">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8r DAV/2 Server at <serverremoved> Port 80</address>
</body></html>

jarednichols
Honored Contributor

Do you have mod_rewrite rules or anything in a .htaccess file? A 302 redirect is totally not a normal thing unless it was setup on purpose.

I'm also wondering if you've got some squirreliness up in your httpd.conf file. Can you paste it here?

tlarkin
Honored Contributor

Hi Everyone,

Just a thought here. On your web server (assuming Apache 2 here?) is the web docs folder linked to the actual CasperShare on the local server? When I set up HTTP distribution points I just usually use a symbolic link from the webdoc root in Apache to the actual local path on the Linux box where I typically set up my distribution points at.

Then, once that is verified, in the JSS > Settings > Servers > Distribution Point, under the HTTP tab ensure the context is set properly to the name of the share, in most cases called CasperShare.

I hope this helps,

Tom

Gerard_Allen
New Contributor

Hi Tom,

This is a vanilla JSS build on a Mac OS X 10.7.4 server. I've checked that webDAV is not switched on for CasperShare and that the CasperShare alias is in /Library/Webserver/Documents (and links correctly!)

Regards,
Ger...

jarednichols
Honored Contributor
the CasperShare alias

Woah, there it is. Did you say alias? Like, you created an alias in the Finder? That's likely your problem right there. Use a symlink or better yet, change DocumentRoot so it's actually pointed at the CasperShare folder.

Gerard_Allen
New Contributor

Sorry, syntax slip there. It's the symlink that was auto created by the JSS during setup. I haven't changed it, honest ;-)