#!/usr/bin/python
# Script to add RestartFix for Chameleon boot loaders
import sys
import os
import shutil
vol = str(sys.argv[3])
extrafolder = vol + "/tmpcham/Extra"
if not os.path.exists(extrafolder):
os.makedirs(extrafolder)
boot = "/tmpcham/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 RestartFix has been written or not
RestartFixCheck = False
body = ""
for line in infile:
# if we finish the tags and haven't written RestartFix Yet
if "" in line and RestartFixCheck == False:
line = " RestartFix\n"
line += " No\n"
line += "\n"
RestartFixCheck = True
body += line
infile.close()
outfile = open(plist, "w")
outfile.write(body)
outfile.close()