Home

Awesome

Imagr Config Creator (CLI)

This interactive script will generate or edit a workflow plist for Imagr.

Usage

The only command line argument must be a path to a plist file. If no plist exists at that location, it will create one (and fail if it can't write to it).

./config_creator.py /Users/nmcspadden/Desktop/imagr_config.plist
nmcspadden$ ./config_creator.py imagr_config.plist 
Entering interactive mode... (type "help" for commands)
> help
Available sub-commands:
	add-computername-component
	add-erase-component
	add-image-component
	add-package-component
	add-partition-component
	add-script-component
	add-workflow
	display-components
	display-workflows
	exit
	help
	new-password
	remove-component
	remove-workflow
	set-bless-target
	set-description
	set-restart-action
	show-password
	show-workflow
> 

Command list:

For more information on what these arguments represent, consult the Imagr documentation.

exit - Changes are only saved when you exit. Ctrl-C or Ctrl-D will NOT save the plist.

Password related:

Workflow related:

Per-Workflow settings related:

Component related:

Examples

$ ./config_creator.py new_imagr_config.plist
Entering interactive mode... (type "help" for commands)
> add-workflow 'First Image'
Workflow 'First Image':
{'bless_target': False,
 'components': [],
 'description': '',
 'name': 'First Image',
 'restart_action': 'none'}
> add-image-component --workflow 'First Image' --url 'http://server/image.dmg'
Workflow 'First Image':
{'bless_target': False,
 'components': [{'type': 'image', 'url': 'http://server/image.dmg'}],
 'description': '',
 'name': 'First Image',
 'restart_action': 'none'}
> add-package-component --workflow 'First Image' --url 'http://server/munki.pkg' 
Workflow 'First Image':
{'bless_target': False,
 'components': [{'type': 'image', 'url': 'http://server/image.dmg'},
                {'first_boot': True,
                 'type': 'package',
                 'url': 'http://server/munki.pkg'}],
 'description': '',
 'name': 'First Image',
 'restart_action': 'none'}
> add-script-component --workflow 'First Image' --content 'test_postinstall_script.sh' --no-firstboot
Workflow 'First Image':
{'bless_target': False,
 'components': [{'type': 'image', 'url': 'http://server/image.dmg'},
                {'first_boot': True,
                 'type': 'package',
                 'url': 'http://server/munki.pkg'},
                {'content': '#!/bin/bash\necho "<"\necho "{{target_volume}}"\n/usr/bin/touch "{{target_volume}}/some_file"',
                 'first_boot': False,
                 'type': 'script'}],
 'description': '',
 'name': 'First Image',
 'restart_action': 'none'}
> exit

Resulting plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>password</key>
	<string></string>
	<key>workflows</key>
	<array>
		<dict>
			<key>bless_target</key>
			<false/>
			<key>components</key>
			<array>
				<dict>
					<key>type</key>
					<string>image</string>
					<key>url</key>
					<string>http://server/image.dmg</string>
				</dict>
				<dict>
					<key>first_boot</key>
					<true/>
					<key>type</key>
					<string>package</string>
					<key>url</key>
					<string>http://server/munki.pkg</string>
				</dict>
				<dict>
					<key>content</key>
					<string>#!/bin/bash
echo "&lt;"
echo "{{target_volume}}"
/usr/bin/touch "{{target_volume}}/some_file"</string>
					<key>first_boot</key>
					<false/>
					<key>type</key>
					<string>script</string>
				</dict>
			</array>
			<key>description</key>
			<string></string>
			<key>name</key>
			<string>First Image</string>
			<key>restart_action</key>
			<string>none</string>
		</dict>
	</array>
</dict>
</plist>

Partition example

$ ./config_creator.py new.plist
Entering interactive mode... (type "help" for commands)
> add-workflow 'hello'
Workflow 'hello':
{'bless_target': False,
 'components': [],
 'description': '',
 'name': 'hello',
 'restart_action': 'none'}
> add-partition-component --workflow 'hello' --map 'GPTFormat' --names 'First' 'Second' --formats 'Journaled HFS+' 'Journaled HFS+' --sizes '50%' '50%' --target 'First'
Workflow 'hello':
{'bless_target': False,
 'components': [{'map': 'GPTFormat',
                 'partitions': [{'format_type': 'Journaled HFS+',
                                 'name': 'First',
                                 'size': '50%'},
                                {'format_type': 'Journaled HFS+',
                                 'name': 'Second',
                                 'size': '50%'}],
                 'type': 'partition'}],
 'description': '',
 'name': 'hello',
 'restart_action': 'none'}
> 

Resulting plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>password</key>
	<string></string>
	<key>workflows</key>
	<array>
		<dict>
			<key>bless_target</key>
			<false/>
			<key>components</key>
			<array>
				<dict>
					<key>map</key>
					<string>GPTFormat</string>
					<key>partitions</key>
					<array>
						<dict>
							<key>format_type</key>
							<string>Journaled HFS+</string>
							<key>name</key>
							<string>First</string>
							<key>size</key>
							<string>50%</string>
						</dict>
						<dict>
							<key>format_type</key>
							<string>Journaled HFS+</string>
							<key>name</key>
							<string>Second</string>
							<key>size</key>
							<string>50%</string>
						</dict>
					</array>
					<key>type</key>
					<string>partition</string>
				</dict>
			</array>
			<key>description</key>
			<string></string>
			<key>name</key>
			<string>hello</string>
			<key>restart_action</key>
			<string>none</string>
		</dict>
	</array>
</dict>
</plist>