Chameleon Applications

Chameleon Applications Commit Details

Date:2010-10-02 20:53:27 (10 years 22 days ago)
Author:scrax scrax
Commit:165
Parents: 164
Message:fixing commit errors
Changes:
R/branches/scrax/trunk/package/Scripts/Advanced copia → /branches/scrax/trunk/package/Scripts/Advanced

File differences

branches/scrax/trunk/package/Scripts/Advanced/ForceHPET/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceHPET"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/EHCIacquire/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="EHCIacquire"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/VBIOS/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="VBIOS"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/GUI/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="GUI"
string="No"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/SMBIOSdefaults/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="SMBIOSdefault"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/UseMemDetect/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UseMemDetect"
string="No"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/Wait/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="Wait"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/LegacyLogo/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="LegacyLogo"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/UseNvidiaROM/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UseNvidaROM"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/ForceWake/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceWake"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/Wake/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="Wake"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/UseAtiROM/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UseAtiROM"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/BootBanner/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="BootBanner"
string="No"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/QuietBoot/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="QuietBoot"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/scrax/trunk/package/Scripts/Advanced/UHCIreset/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UHCIreset"
string="Yes"
main ()
{
bootplist="${2}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"

Archive Download the corresponding diff file

Revision: 165