#!/usr/bin/python
# Script to add UHCIreset for Chameleon boot loaders
import sys
import os
import shutil
vol = str(sys.argv[3])
extrafolder = vol + "/usr/local/chamTemp/Extra"
if not os.path.exists(extrafolder):
os.makedirs(extrafolder)
boot = "/usr/local/chamTemp/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
infile = open(plist, "r")
# check if UHCIreset has been written or not
UHCIresetCheck = False
body = ""
for line in infile:
# if we finish the tags and haven't written UHCIreset Yet
if "" in line and UHCIresetCheck == False:
line = " UHCIreset\n"
line += " Yes\n"
line += "\n"
UHCIresetCheck = True
body += line
infile.close()
outfile = open(plist, "w")
outfile.write(body)
outfile.close()