Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP redirect option #77

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ In the LaunchDaemon add the following:
<string>Basic dGVzdDp0ZXN0</string>
```

#### Follow HTTP Redirects
If your webserver needs to redirect InstallApplictions to fetch content from another URL, pass `--follow-redirects` in your LaunchDaemon. Useful for situations where content may be stored on a CDN or object storage.

```xml
<string>--follow-redirects</string>
```

### DEPNotify
InstallApplications can work in conjunction with DEPNotify to automatically create and manipulate the progress bar.

Expand Down
10 changes: 10 additions & 0 deletions payload/Library/installapplications/installapplications.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def download_if_needed(item, stage, type, opts, depnotifystatus):
if opts.headers:
item.update({'additional_headers':
{'Authorization': opts.headers}})
# Check if we need to follow redirects.
if opts.follow_redirects:
item.update({'follow_redirects': True})
# Download the file once:
iaslog('Starting download: %s' % (urllib.parse.unquote(itemurl)))
if opts.depnotify:
Expand Down Expand Up @@ -404,6 +407,9 @@ def main():
o.add_option('--userscript', default=None,
help=('Optional: Trigger a user script run.'),
action='store_true')
o.add_option('--follow-redirects', default=False,
help=('Optional: Follow HTTP redirects.'),
action='store_true')

opts, args = o.parse_args()

Expand Down Expand Up @@ -517,6 +523,10 @@ def main():
headers = {'Authorization': opts.headers}
json_data.update({'additional_headers': headers})

# Check if we need to follow redirects.
if opts.follow_redirects:
item.update({'follow_redirects': True})

# Delete the bootstrap file if it exists, to ensure it's up to date.
if not opts.skip_validation:
if os.path.isfile(jsonpath):
Expand Down