diff --git a/README.md b/README.md index 0e262db..34b8a11 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,13 @@ In the LaunchDaemon add the following: Basic dGVzdDp0ZXN0 ``` +#### 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 +--follow-redirects +``` + ### DEPNotify InstallApplications can work in conjunction with DEPNotify to automatically create and manipulate the progress bar. diff --git a/payload/Library/installapplications/installapplications.py b/payload/Library/installapplications/installapplications.py index dd727a8..cb1e64c 100755 --- a/payload/Library/installapplications/installapplications.py +++ b/payload/Library/installapplications/installapplications.py @@ -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: @@ -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() @@ -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):