/
programmedrucken
executable file
·259 lines (212 loc) · 15 KB
/
programmedrucken
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/sh
ADDONNAME=print
ADDON_DIR=/usr/local/etc/config/addons/${ADDONNAME}
WWW_DIR=/usr/local/etc/config/addons/www/${ADDONNAME}
RCD_DIR=/usr/local/etc/config/rc.d
# check for unsupported platforms
if grep -qim1 busmatic /www/api/methods/ccu/downloadFirmware.tcl; then
exit 13
fi
model=`grep VERSION /boot/VERSION | awk -F'[=.]' {'print $2'}`
version=`grep VERSION /boot/VERSION | awk -F'[=.]' {'print $3'}`
build=`grep VERSION /boot/VERSION | awk -F'[=.]' {'print $4'}`
echo "Found firmware version $model.$version.$build"
if [ $model -ge 2 ] && [ $version -ge 53 ]; then
### FOR CCU FW >= x.53
# String to include the functions.js for DV/Overview & Deviceparamter
SCGISTRING="setFooter(s);"
RCGISTRING="setFooter(s); var scriptpp = document.createElement(\\\\\"script\\\\\"); scriptpp.type = \\\\\"text/javascript\\\\\"; scriptpp.src = \\\\\"/addons/print/functions.js\\\\\"; \\\\\$(\\\\\"body\\\\\").appendChild(scriptpp);"
# String to include the functions.js for Programm/s
SSTRINGZWO="setFooter(s);"
RSTRINGZWO="setFooter(s); var scriptpp = document.createElement(\"script\"); scriptpp.type = \"text/javascript\"; scriptpp.src = \"/addons/print/functions.js\"; \$(\"body\").appendChild(scriptpp);"
# String to include the print button for single "Direkte Verknüpfung"
SCGISTRINGZWO="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='CollectData_SaveProfileSettings(0);'>\\\\\${footerBtnOk}</div></td>\\\\\";"
RCGISTRINGZWO="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='CollectData_SaveProfileSettings(0);'>\\\\\${footerBtnOk}</div></td><td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='PrintPage();'>Drucken</div></td>\\\\\";"
# String to include the overview print button in "Direkte Verknüpfungen"
SOVERDVCGI="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS22100' onclick='loadNewLinkPage();' >\\\\\"+ translateKey('footerBtnNewLink') +\\\\\"</div></td>\\\\\";"
ROVERDVCGI="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS22100' onclick='loadNewLinkPage();' >\\\\\"+ translateKey('footerBtnNewLink') +\\\\\"</div></td></td><td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS04906' onclick='PrintAllDV();'>\Übersicht Drucken</div></td>\\\\\";"
# String to include the print button in "Geräteparameter"
SDEVPARACGI="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='CloseDeviceParameters();'>\\\\\"+translateKey('footerBtnCancel')+\\\\\"</div></td>\\\\\";"
RDEVPARACGI="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='CloseDeviceParameters();'>\\\\\"+translateKey('footerBtnCancel')+\\\\\"</div></td><td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='PrintDevPara();'>Drucken</div></td>\\\\\";"
# String to include the print buttons for "Programme"
SPROGLISTSTRING="<td style='text-align:center; vertical-align: middle;'><div class='FooterButton CLASS04906' onclick='new HMScriptExecutor();' >\"+translateKey('footerBtnTestScript')+ \"</div></td>"
RPROGLISTSTRING="<td style='text-align:center; vertical-align: middle;'><div class='FooterButton CLASS04906' onclick='new HMScriptExecutor();' >\"+translateKey('footerBtnTestScript')+ \"</div></td><td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS04906' onclick='PrintAllPrograms();'>Drucken</div></td><td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='PrintAllSysPrograms();'>Drucken inkl. Interne</div></td>"
# String to include the print button in single "Programm"
SSTRING="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS04801' onclick='new HMScriptExecutor();'>\${footerBtnTestScript}</div></td>"
RSTRING="<td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS04801' onclick='new HMScriptExecutor();'>\${footerBtnTestScript}</div></td><td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='PrintPage();'>Drucken</div></td>"
else
### FOR CCU FW < x.53
# String to include the functions.js for DV/Overview & Deviceparamter
SCGISTRING="setFooter(s);"
RCGISTRING="setFooter(s); var scriptpp = document.createElement(\\\\\"script\\\\\"); scriptpp.type = \\\\\"text/javascript\\\\\"; scriptpp.src = \\\\\"/addons/print/functions.js\\\\\"; \\\\\$(\\\\\"body\\\\\").appendChild(scriptpp);"
# String to include the functions.js for Programm/s
SSTRINGZWO="setFooter(s);"
RSTRINGZWO="setFooter(s); var scriptpp = document.createElement(\"script\"); scriptpp.type = \"text/javascript\"; scriptpp.src = \"/addons/print/functions.js\"; \$(\"body\").appendChild(scriptpp);"
# String to include the print button for single "Direkte Verknüpfung"
SCGISTRINGZWO="<td align='center' valign='middle'><div class='FooterButton' onclick='CollectData_SaveProfileSettings(0);'>\\\\\${footerBtnOk}</div></td>\\\\\";"
RCGISTRINGZWO="<td align='center' valign='middle'><div class='FooterButton' onclick='CollectData_SaveProfileSettings(0);'>\\\\\${footerBtnOk}</div></td><td align='center' valign='middle'><div class='FooterButton' onclick='PrintPage();'>Drucken</div></td>\\\\\";"
# String to include the overview print button in "Direkte Verknüpfungen"
SOVERDVCGI="<td align='center' valign='middle'><div class='FooterButton CLASS22100' onclick='loadNewLinkPage();' >\\\\\"+ translateKey('footerBtnNewLink') +\\\\\"</div></td>\\\\\";"
ROVERDVCGI="<td align='center' valign='middle'><div class='FooterButton CLASS22100' onclick='loadNewLinkPage();' >\\\\\"+ translateKey('footerBtnNewLink') +\\\\\"</div></td></td><td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='PrintAllDV();'>\Übersicht Drucken</div></td>\\\\\";"
# String to include the print button in "Geräteparameter"
SDEVPARACGI="<td align='center' valign='middle'><div class='FooterButton' onclick='CloseDeviceParameters();'>\\\\\"+translateKey('footerBtnCancel')+\\\\\"</div></td>\\\\\";"
RDEVPARACGI="<td align='center' valign='middle'><div class='FooterButton' onclick='CloseDeviceParameters();'>\\\\\"+translateKey('footerBtnCancel')+\\\\\"</div></td><td align='center' valign='middle'><div class='FooterButton' onclick='PrintDevPara();'>Drucken</div></td>\\\\\";"
# String to include the print buttons for "Programme"
SPROGLISTSTRING="<td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='new HMScriptExecutor();' >\"+translateKey('footerBtnTestScript')+ \"</div></td>"
RPROGLISTSTRING="<td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='new HMScriptExecutor();' >\"+translateKey('footerBtnTestScript')+ \"</div></td><td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='PrintAllPrograms();'>Drucken</div></td><td align='center' valign='middle'><div class='FooterButton CLASS04906' onclick='PrintAllSysPrograms();'>Drucken inkl. Interne</div></td>"
# String to include the print button in single "Programm"
SSTRING="<td align='center' valign='middle'><div class='FooterButton CLASS04801' onclick='new HMScriptExecutor();'>\${footerBtnTestScript}</div></td>"
RSTRING="<td align='center' valign='middle'><div class='FooterButton CLASS04801' onclick='new HMScriptExecutor();'>\${footerBtnTestScript}</div></td><td align='center' valign='middle'><div class='FooterButton' onclick='PrintPage();'>Drucken</div></td>"
fi
case "$1" in
""|start)
if [ -e /www/config/ic_deviceparameters.cgi_tmp ]; then
echo "Temporary file /www/config/ic_deviceparameters.cgi_tmp does exist. Delete it..."
mount -o rw,remount /
rm -rf /www/config/ic_deviceparameters.cgi_tmp
mount -o ro,remount /
fi
if [ ! -e /www/config/ic_deviceparameters.cgi_org ]; then
echo "File /www/config/ic_deviceparameters.cgi_org does not exist. Copying it..."
mount -o rw,remount /
mv /www/config/ic_deviceparameters.cgi /www/config/ic_deviceparameters.cgi_org
sed -e "s|$SCGISTRING|$RCGISTRING|g" "/www/config/ic_deviceparameters.cgi_org" > "/www/config/ic_deviceparameters.cgi_tmp"
sed -e "s|$SDEVPARACGI|$RDEVPARACGI|g" "/www/config/ic_deviceparameters.cgi_tmp" > "/www/config/ic_deviceparameters.cgi"
rm -rf /www/config/ic_deviceparameters.cgi_tmp
chmod 755 /www/config/ic_deviceparameters.cgi
mount -o ro,remount /
fi
if [ -e /www/config/ic_linkpeerlist.cgi_tmp ]; then
echo "Temporary file /www/config/ic_linkpeerlist.cgi_tmp does exist. Delete it..."
mount -o rw,remount /
rm -rf /www/config/ic_linkpeerlist.cgi_tmp
mount -o ro,remount /
fi
if [ ! -e /www/config/ic_linkpeerlist.cgi_org ]; then
echo "File /www/config/ic_linkpeerlist.cgi_org does not exist. Copying it..."
mount -o rw,remount /
mv /www/config/ic_linkpeerlist.cgi /www/config/ic_linkpeerlist.cgi_org
sed -e "s|$SCGISTRING|$RCGISTRING|g" "/www/config/ic_linkpeerlist.cgi_org" > "/www/config/ic_linkpeerlist.cgi_tmp"
sed -e "s|$SOVERDVCGI|$ROVERDVCGI|g" "/www/config/ic_linkpeerlist.cgi_tmp" > "/www/config/ic_linkpeerlist.cgi"
rm -rf /www/config/ic_linkpeerlist.cgi_tmp
chmod 755 /www/config/ic_linkpeerlist.cgi
mount -o ro,remount /
fi
if [ -e /www/config/ic_setprofiles.cgi_tmp ]; then
echo "Temporary file /www/config/ic_setprofiles.cgi_tmp does exist. Delete it..."
mount -o rw,remount /
rm -rf /www/config/ic_setprofiles.cgi_tmp
mount -o ro,remount /
fi
if [ ! -e /www/config/ic_setprofiles.cgi_org ]; then
echo "File /www/config/ic_setprofiles.cgi_org does not exist. Copying it..."
mount -o rw,remount /
mv /www/config/ic_setprofiles.cgi /www/config/ic_setprofiles.cgi_org
sed -e "s|$SCGISTRING|$RCGISTRING|g" "/www/config/ic_setprofiles.cgi_org" > "/www/config/ic_setprofiles.cgi_tmp"
sed -e "s|$SCGISTRINGZWO|$RCGISTRINGZWO|g" "/www/config/ic_setprofiles.cgi_tmp" > "/www/config/ic_setprofiles.cgi"
rm -rf /www/config/ic_setprofiles.cgi_tmp
chmod 755 /www/config/ic_setprofiles.cgi
mount -o ro,remount /
fi
if [ -e /www/rega/pages/tabs/admin/views/programlist.htm_tmp ]; then
echo "Temporary file /www/rega/pages/tabs/admin/views/programlist.htm_tmp does exist. Delete it..."
mount -o rw,remount /
rm -rf /www/rega/pages/tabs/admin/views/programlist.htm_tmp
mount -o ro,remount /
fi
if [ ! -e /www/rega/pages/tabs/admin/views/programlist.org1 ]; then
echo "File /www/rega/pages/tabs/admin/views/programlist.org1 does not exist. Copying it..."
mount -o rw,remount /
mv /www/rega/pages/tabs/admin/views/programlist.htm /www/rega/pages/tabs/admin/views/programlist.org1
sed -e "s|$SPROGLISTSTRING|$RPROGLISTSTRING|g" "/www/rega/pages/tabs/admin/views/programlist.org1" > "/www/rega/pages/tabs/admin/views/programlist.htm_tmp"
sed -e "s|$SSTRINGZWO|$RSTRINGZWO|g" "/www/rega/pages/tabs/admin/views/programlist.htm_tmp" > "/www/rega/pages/tabs/admin/views/programlist.htm"
chmod 755 /www/rega/pages/tabs/admin/views/programlist.htm
rm -rf /www/rega/pages/tabs/admin/views/programlist.htm_tmp
mount -o ro,remount /
fi
if [ -e /www/rega/pages/tabs/admin/views/programs.htm_tmp ]; then
echo "Temporary file /www/rega/pages/tabs/admin/views/programs.htm_tmp does exist. Delete it..."
mount -o rw,remount /
rm -rf /www/rega/pages/tabs/admin/views/programs.htm_tmp
mount -o ro,remount /
fi
if [ -e /www/rega/pages/tabs/admin/views/programs.org ]; then
echo "File /www/rega/pages/tabs/admin/views/programs.org does exist. Restore it..."
mount -o rw,remount /
rm -rf /www/rega/pages/tabs/admin/views/programs.htm
mv /www/rega/pages/tabs/admin/views/programs.org /www/rega/pages/tabs/admin/views/programs.htm
mount -o ro,remount /
fi
if [ ! -e /www/rega/pages/tabs/admin/views/programs.org1 ]; then
echo "File /www/rega/pages/tabs/admin/views/programs.org1 does not exist. Copying it..."
mount -o rw,remount /
mv /www/rega/pages/tabs/admin/views/programs.htm /www/rega/pages/tabs/admin/views/programs.org1
sed -e "s|$SSTRING|$RSTRING|g" "/www/rega/pages/tabs/admin/views/programs.org1" > "/www/rega/pages/tabs/admin/views/programs.htm_tmp"
sed -e "s|$SSTRINGZWO|$RSTRINGZWO|g" "/www/rega/pages/tabs/admin/views/programs.htm_tmp" > "/www/rega/pages/tabs/admin/views/programs.htm"
chmod 755 /www/rega/pages/tabs/admin/views/programs.htm
rm -rf /www/rega/pages/tabs/admin/views/programs.htm_tmp
mount -o ro,remount /
fi
if [ ! -e /www/rega/esp/PrintPrograms.fn ]; then
echo "File /www/rega/esp/PrintPrograms.fn does not exist. Copying it..."
mount -o rw,remount /
cp /usr/local/etc/config/addons/www/print/PrintPrograms.fn /www/rega/esp/PrintPrograms.fn
chmod 755 /www/rega/esp/PrintPrograms.fn
mount -o ro,remount /
fi
if [ ! -e /www/rega/esp/PrintProgram.htm ]; then
echo "File /www/rega/esp/PrintProgram.htm does not exist. Copying it..."
mount -o rw,remount /
cp /usr/local/etc/config/addons/www/print/PrintProgram.htm /www/rega/esp/PrintProgram.htm
chmod 755 /www/rega/esp/PrintProgram.htm
mount -o ro,remount /
fi
;;
restart|stop)
exit 0
;;
info)
echo "Info: <b>Programmedrucken CCU Addon</b><br/>"
echo "Info: Erzeugt Druckansichten für Programme<br/><br/>"
echo "Info: (c) 2010-2020 HMside, anli, jp112sdl, jens-maus<br/>"
echo "Info: <a href='https://github.com/litti/hm-print'>https://github.com/litti/hm-print</a>"
echo "Version: $(cat ${ADDON_DIR}/VERSION)"
echo "Name: Programmedrucken"
echo "Operations: uninstall"
echo "Update: /addons/${ADDONNAME}/update-check.cgi"
;;
uninstall)
mount -o rw,remount /
if [ -e /www/rega/pages/tabs/admin/views/programs.org1 ]; then
rm -rf /www/rega/pages/tabs/admin/views/programs.htm
mv /www/rega/pages/tabs/admin/views/programs.org1 /www/rega/pages/tabs/admin/views/programs.htm
fi
if [ -e /www/config/ic_deviceparameters.cgi_org ]; then
rm -rf /www/config/ic_deviceparameters.cgi
mv /www/config/ic_deviceparameters.cgi_org /www/config/ic_deviceparameters.cgi
fi
if [ -e /www/config/ic_linkpeerlist.cgi_org ]; then
rm -rf /www/config/ic_linkpeerlist.cgi
mv /www/config/ic_linkpeerlist.cgi_org /www/config/ic_linkpeerlist.cgi
fi
if [ -e /www/config/ic_setprofiles.cgi_org ]; then
rm -rf /www/config/ic_setprofiles.cgi
mv /www/config/ic_setprofiles.cgi_org /www/config/ic_setprofiles.cgi
fi
if [ -e /www/rega/pages/tabs/admin/views/programlist.org1 ]; then
rm -rf /www/rega/pages/tabs/admin/views/programlist.htm
mv /www/rega/pages/tabs/admin/views/programlist.org1 /www/rega/pages/tabs/admin/views/programlist.htm
fi
rm -rf /www/rega/esp/PrintPrograms.fn
rm -rf /www/rega/esp/PrintProgram.htm
rm -rf ${ADDON_DIR}
rm -rf ${WWW_DIR}
rm -f ${RCD_DIR}/${ADDONNAME}
mount -o ro,remount /
;;
*)
echo "Usage: programmedrucken {info|start|uninstall}" >&2
exit 1
;;
esac
exit 0