-
Notifications
You must be signed in to change notification settings - Fork 0
/
ironhide-configuration
executable file
·639 lines (553 loc) · 22 KB
/
ironhide-configuration
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
#!/bin/bash
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <mj@casalogic.dk> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you
# think
# this stuff is worth it, you can buy me a beer in return Martin Juhl
# ----------------------------------------------------------------------------
#
# This file is part of ironhide.
#
# ironhide is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ironhide is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ironhide. If not, see <http://www.gnu.org/licenses/>.
#
# Definitions
ARCH=`uname -m`
CONFIGURATIONFILE=/etc/default/ironhide
LOCALECONFIGFILE=.ironhide
DATAFOLDER=/usr/share/ironhide/data/
EXAMPLEFOLDER=/usr/share/ironhide/examples/
LASTUPDATE=`stat -c %y $DATAFOLDER/allmachineinfo | cut -d ' ' -f1`
HEIGHT=500
WIDTH=700
CONFIGMODE=NONE
NVIDIABUSID=`grep BusID /etc/X11/xorg.conf.nvidia | sed -e "s/[ \t]*BusID[ \t]*\"\(.*\)\"/\1/g"`
CONNECTEDMONITOR=`grep ConnectedMonitor /etc/X11/xorg.conf.nvidia | sed -e "s/[ \t]*Option[ \t]*\"ConnectedMonitor\"[ \t]*\"\(.*\)\"/\1/g"`
NVIDIABUSIDCUT=`grep BusID /etc/X11/xorg.conf.nvidia | sed -e "s/[ \t]*BusID[ \t]*\"\(.*\)\"/\1/g" |cut -d: -f2,3`
PIPE=/tmp/pipe
# Program Paths
LSPCI=`which lspci`
MODPROBE=`which modprobe`
WHOAMI=`which whoami`
WGET=`which wget`
GLXGEARS=`which glxgears`
# INCLUDES
source easybashgui
source $CONFIGURATIONFILE
if [ -f ~/$LOCALECONFIGFILE ];then
source ~/$LOCALECONFIGFILE
fi
# DEBUG? Comment Out...
exec 6>&2 ; exec 2> /dev/null
if [[ "$HOME" == "/root" ]]; then
echo "Do NOT run ironhide-configuration as the root user.."
echo "Please use sudo, gksudo, kdesudo or similiar."
exit 0
fi
LIB_CHECK="$(type "easybashgui" 2> /dev/null )"
[ ${#LIB_CHECK} -eq 0 ] && echo -e "\n\n\n\nYou need to copy \"easybashgui\" in your path\n\n\n\n" 1>&2 && exit 1
if [[ "`$WHOAMI`" != "root" ]]; then
x="alert_message --height $HEIGHT --width $WIDTH"
${x} "ironhide-configuration has been run without root priviledges and can't continue..\nPlease run with sudo, gksudo, kdesudo or similiar."
exit 1
fi
if [ $IRONHIDE_CONFIGURED -eq 1 ]; then
x="question --height $HEIGHT --width $WIDTH"
${x} "Ironhide Configuration.\n\nDo you want to reconfigure ironhide????"
answer="${?}"
if [ ${answer} -eq 1 ]; then
exit 0
fi
fi
if [ -f /usr/local/bin/bumblebee-enablecard ] || [ -f /usr/local/bin/bumblebee-disablecard ] || [ -f /etc/pm/power.d/bumblebee-disablecard-on-powerup ]; then
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 1 ] && [ -f /usr/local/bin/bumblebee-enablecard ]; then
/usr/local/bin/bumblebee-enablecard
fi
x="question --height $HEIGHT --width $WIDTH"
${x} "Old remains of a Bumblebee installation was found, do you want to rename those files??.\n"\
"This is HIGHLY recommend, as they will probably interfere with Ironhide.."
answer="${?}"
if [ ${answer} -eq 1 ]; then
if [ -f /etc/pm/power.d/bumblebee-disablecard-on-powerup ]; then
rm -rf /etc/pm/power.d/bumblebee-disablecard-on-powerup
fi
if [ -f /usr/local/bin/bumblebee-disablecard ]; then
rm -rf /usr/local/bin/bumblebee-disablecard
fi
if [ -f /usr/local/bin/bumblebee-enablecard ]; then
rm -rf /usr/local/bin/bumblebee-enablecard
fi
fi
fi
rm -rf "/tmp/index.google"
$WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
if [ ! -s /tmp/index.google ];then
x="alert_message --width $WIDTH --height $HEIGHT"
${x} "You are not connected to the Internet, and can't fetch the lastest configuration database.\n \
if you are experiencing problems, please try to rerun the configuration while connected to the internet."
DOUPDATE=0
else
x="question --width $WIDTH --height $HEIGHT"
${x} "Do you want to update the configuration database, last data is from $LASTUPDATE???\n"
answer="${?}"
if [ ${answer} -eq 1 ]; then
DOUPDATE=0
else
DOUPDATE=1
fi
fi
echo $DOUPDATE
# Since Ironhide is a project to get Optimus laptops to work, we can safely
# assume that the nvidia driver is not used for the default display (:0)
# Therefore default to mesa instead of nvidia. vglrun sets the GL library
# path to /usr/lib{,32}/nvidia-current for programs running on the display
# accelerated by the nvidia card. Since most graphical applications are not
# statically linked nor setuid/setgid binaries, this is fine. There is an
# exception on this: programs which overwrite LD_LIBRARY_PATH will fail to
# load the nvidia GL driver. However, this method will allow GL on the Intel
# display where the previous situation breaks it.
# TLDR: this allows the intel display to use GL, the ironhide display will
# load the nvidia driver through vglrun in almost all cases
# this takes care of setting correct links which is used on
# /usr/lib/nvidia-current/gl.conf
# multiarch support
for arch in x86_64-linux-gnu i386-linux-gnu; do
# check if the link exist to prevent error messages
if update-alternatives --list ${arch}_gl_conf >/dev/null 2>&1; then
sudo update-alternatives --force --set ${arch}_gl_conf /usr/lib/$arch/mesa/ld.so.conf
fi
done
# versions before Oneiric without multiarch
if update-alternatives --list gl_conf >/dev/null 2>&1; then
sudo update-alternatives --force --set gl_conf /usr/lib/mesa/ld.so.conf
fi
# remove a legacy link which was not used anyway
sudo rm -rf /etc/alternatives/xorg_extra_modules-ironhide
sudo rm -rf /etc/alternatives/_xorg_extra_modules
# fix appeared in commit 68a75db4df628a910886, it should remove an excess
# symlink; /usr/lib/xorg/extra-modules ->
# /etc/alternatives/{_,}xorg_extra_modules -> /usr/lib/nvidia-current/xorg
sudo rm -f /usr/lib/nvidia-current/xorg/xorg
# Refresh the dynamic loader search path so /etc/ld.so.conf.d/GL.conf ->
# /etc/alternatives/gl_conf -> /usr/lib/mesa/ld.so.conf
sudo ldconfig
x="progress -w 600"
if [[ -p $PIPE ]]; then
rm $PIPE
fi
mkfifo $PIPE
tail -f $PIPE | ${x} "Setting up and Downloading Configuration... Please wait" &
echo 0 >> $PIPE
echo 15 >> $PIPE
if [ $DOUPDATE -eq 1 ]; then
if [ -f $DATAFOLDER/machineinfo ]; then
mv $DATAFOLDER/machineinfo $DATAFOLDER/machineinfo-`stat -c %y $DATAFOLDER/machineinfo | cut -d ' ' -f1`
fi
wget -O $DATAFOLDER/machineinfo "http://martin-juhl.dk/ironhide/?searchitem=`sudo dmidecode --string system-product-name`&search=1" 1>/dev/null 2>/dev/null
fi
echo 33 >> $PIPE
i=1
unset profiles
if [ -f $DATAFOLDER/machineinfo ]; then
while read line
do
profiles[$i]="$i: `echo $line | cut -f1 -d\|``echo $line |cut -f2 -d\|` by`echo $line | cut -f5 -d\|`, Confirmed by`echo $line |cut -f6 -d\|` users."
((i+=1))
done < $DATAFOLDER/machineinfo
fi
profiles[i]="9997: Enter Manual Configuration"
((i+=1))
profiles[i]="9998: Show all profiles."
((i+=1))
profiles[i]="9999: Do not configure now."
echo 50 >> $PIPE
if [ $DOUPDATE -eq 1 ]; then
if [ -f $DATAFOLDER/allmachineinfo ]; then
mv $DATAFOLDER/allmachineinfo $DATAFOLDER/allmachineinfo-`stat -c %y $DATAFOLDER/allmachineinfo | cut -d ' ' -f1`
fi
wget -O $DATAFOLDER/allmachineinfo "http://martin-juhl.dk/ironhide/?searchitem=showall&search=1" 1>/dev/null 2>/dev/null
fi
echo 75 >> $PIPE
s=1
i=1
unset allprofiles
while read line
do
allprofiles[i]="$i: `echo $line | cut -f1 -d\|``echo $line |cut -f2 -d\|` by`echo $line | cut -f5 -d\|`, Confirmed by`echo $line |cut -f6 -d\|` users."
((i+=1))
done < $DATAFOLDER/allmachineinfo
allprofiles[i]="9997: Enter Manual Configuration"
((i+=1))
allprofiles[i]="9999: Do not configure now."
echo 100 >> $PIPE
while [ "$CONFIGMODE" != "MANUAL" ] && [ "$CONFIGMODE" != "DONE" ] ; do
if [ "$CONFIGMODE" != "AUTO" ] ; then
case `cat $DATAFOLDER/machineinfo | wc -l` in
0)
x="question --width $WIDTH --height $HEIGHT"
${x} "We have no configuration available for your system. Entering manual configuration.\n"\
"If you get ironhide running, please run ironhide-submitsystem.\n"\
"Do you want to run manual configuration, if not, you'll be presented with a full list of system profiles."
answer="${?}"
if [ ${answer} -eq 1 ]; then
CONFIGMODE=FULLLIST
else
CONFIGMODE=MANUAL
fi
;;
1)
CONFIGMODE=AUTO
MANUFACTURER=`cat $DATAFOLDER/machineinfo |cut -f1 -d\|`
MODEL=`cat $DATAFOLDER/machineinfo |cut -f2 -d\|`
USER=`cat $DATAFOLDER/machineinfo |cut -f5 -d\|`
POWERON=`cat $DATAFOLDER/machineinfo |cut -f3 -d\|`
POWEROFF=`cat $DATAFOLDER/machineinfo |cut -f4 -d\|`
CONFIRMEDBY=`cat $DATAFOLDER/machineinfo |cut -f6 -d\|`
OS=`cat $DATAFOLDER/machineinfo |cut -f7 -d\|`
POWERSTATUS=`cat $DATAFOLDER/machineinfo |sed -n 1p|cut -f3 -d\| | sed -e 's/ //g'`
;;
*)
x="menu -w $WIDTH -h $HEIGHT"
${x} "${profiles[@]}"
choice="$(0< "${dir_tmp}/${file_tmp}" )"
choice=`echo $choice | cut -f1 -d:`
if [[ $choice == "9998" ]] ; then
CONFIGMODE=FULLLIST
elif [[ $choice == 9999 ]] || [[ $choice == "" ]]; then
x="message --width $WIDTH --height $HEIGHT"
${x} "Ironhide has NOT been configured, and probably won't work."
exit 0
elif [[ $choice == 9997 ]] ; then
CONFIGMODE=MANUAL
else
CONFIGMODE=AUTO
MANUFACTURER=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f1 -d\|`
MODEL=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f2 -d\|`
USER=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f5 -d\|`
POWERON=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f3 -d\|`
POWEROFF=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f4 -d\|`
CONFIRMEDBY=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f6 -d\|`
OS=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f7 -d\|`
POWERSTATUS=`cat $DATAFOLDER/machineinfo |sed -n \`echo $choice\`p|cut -f3 -d\| | sed -e 's/ //g'`
fi
;;
esac
fi
echo $CONFIGMODE
if [ "$CONFIGMODE" = "AUTO" ] ; then
if [ "$POWERSTATUS" = "UNAVAILABLE" ] ; then
PWSTATUS="Unavailable"
else
PWSTATUS="Available"
fi
x="question --width $WIDTH --height $HEIGHT"
${x} "The following system profile has been found/selected:\n"\
"Machine: $MANUFACTURER $MODEL\n"\
"Power Control Scripts: $PWSTATUS\n"\
"Tested on: $OS\n"\
"Submitted by: $USER\n"\
"Confirmed working by $CONFIRMEDBY user(s).\n"\
"Do you want to use this configuration?\n"
answer="${?}"
if [ ${answer} -eq 1 ]; then
CONFIGMODE=NONE
else
CONFIGMODE=DONE
fi
fi
if [ "$CONFIGMODE" = "FULLLIST" ] ; then
x="menu -w $WIDTH -h $HEIGHT"
${x} "${allprofiles[@]}"
choice="$(0< "${dir_tmp}/${file_tmp}" )"
choice=`echo $choice | cut -f1 -d:`
if [ $choice -eq 9999 ] ; then
x="message --width $WIDTH --height $HEIGHT"
${x} "Ironhide has NOT been configured, and probably won't work."
exit 0
elif [ $choice -eq 9997 ] ; then
CONFIGMODE=MANUAL
else
CONFIGMODE=AUTO
MANUFACTURER=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f1 -d\|`
MODEL=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f2 -d\|`
USER=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f5 -d\|`
POWERON=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f3 -d\|`
POWEROFF=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f4 -d\|`
CONFIRMEDBY=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f6 -d\|`
OS=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f7 -d\|`
POWERSTATUS=`cat $DATAFOLDER/allmachineinfo |sed -n \`echo $choice\`p|cut -f3 -d\| | sed -e 's/ //g'`
fi
fi
done
if [ "$CONFIGMODE" == "MANUAL" ]; then
POWERSTATUS="UNAVAILABLE"
fi
if [ `${LSPCI} |grep VGA |wc -l` -eq 2 ]; then
NVIDIABUSID=`${LSPCI} | grep VGA | grep nVidia | awk '{ print "PCI:"$1 }' | sed s/\\\./:/g`
elif [ `${LSPCI} |grep 3D |wc -l` -eq 1 ]; then
NVIDIABUSID=`${LSPCI} | grep 3D | grep nVidia | awk '{ print "PCI:"$1 }' | sed s/\\\./:/g`
else
x="message --width $WIDTH --height $HEIGHT"
${x} "The BusID of the nVidia card can't be determined.\n"\
"You must correct this manually in /etc/X11/xorg.conf.nvidia\n"\
"Please report this problem..\n"
exit 0
fi
sudo sed -i "s/\([ \t]*BusID[ \t]*\)\".*\"/\1\"$NVIDIABUSID\"/g" /etc/X11/xorg.conf.nvidia
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 1 ]; then
if [ -f /usr/local/bin/ironhide-enablecard ]; then
/usr/local/bin/ironhide-enablecard
fi
if [ -f /usr/bin/ironhide-enablecard ]; then
/usr/bin/ironhide-enablecard
fi
fi
${MODPROBE} nvidia-current
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 0 ] ; then
if [ `LD_LIBRARY_PATH=/usr/lib/nvidia-current /usr/lib/nvidia-current/bin/nvidia-xconfig --query-gpu-info | grep "Display Devices" | cut -f2 -d":"` -gt 0 ] ; then
CONNECTEDMONITOR=`LD_LIBRARY_PATH=/usr/lib/nvidia-current /usr/lib/nvidia-current/bin/nvidia-xconfig --query-gpu-info | grep "Display Device 0" | cut -f2 -d\( | cut -f1 -d\)`
fi
fi
${MODPROBE} -r nvidia
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 0 ]; then
if [ -f /usr/local/bin/ironhide-disablecard ]; then
/usr/local/bin/ironhide-disablecard
fi
if [ -f /usr/bin/ironhide-disablecard ]; then
/usr/bin/ironhide-disablecard
fi
fi
if [ "$CONNECTEDMONITOR" != "CRT-0" ] && [ "$CONNECTEDMONITOR" != "DFP-0" ];then
sed -i "s/\([ \t]*Option[ \t]*\"ConnectedMonitor\"[ \t]*\)".*"/\1\"CRT-0\"/g" /etc/X11/xorg.conf.nvidia
/etc/init.d/ironhide enable
ERRORS=`cat /var/log/Xorg.\`echo $VGL_DISPLAY |cut -f2 -d:\`.log |grep EE |grep -v kbd |grep -v MIT-SCREEN-SAVER |grep -v "not implemented" | wc -l`
/etc/init.d/ironhide disable
if [[ $ERRORS != 0 ]]; then
sed -i "s/\([ \t]*Option[ \t]*\"ConnectedMonitor\"[ \t]*\)".*"/\1\"DFP-0\"/g" /etc/X11/xorg.conf.nvidia
/etc/init.d/ironhide enable
ERRORS=`cat /var/log/Xorg.\`echo $VGL_DISPLAY |cut -f2 -d:\`.log |grep EE |grep -v kbd |grep -v MIT-SCREEN-SAVER |grep -v "not implemented" | wc -l`
/etc/init.d/ironhide disable
if [[ $ERRORS != 0 ]]; then
CONNECTEDMONITOR="DFP-0"
fi
else
CONNECTEDMONITOR="CRT-0"
fi
fi
if [ "$CONNECTEDMONITOR" != "CRT-0" ] && [ "$CONNECTEDMONITOR" != "DFP-0" ];then
x="message --width $WIDTH --height $HEIGHT"
${x} "The device for the nVidia monitor could not be detected, please\n"\
"manually choose the device, if your having problems, try another."
x="menu -w $WIDTH -h $HEIGHT"
${x} "CRT-0" "DFP-0" "Manually Enter"
choice="$(0< "${dir_tmp}/${file_tmp}" )"
case "$choice" in
"CRT-0")
CONNECTEDMONITOR="CRT-0"
;;
"DFP-0")
CONNECTEDMONITOR="DFP-0"
;;
*)
x="input -w $WIDTH -h $HEIGHT 1"
${x} "Enter nVidia monitor device."
CONNECTEDMONITOR="$(0< "${dir_tmp}/${file_tmp}" )"
;;
esac
fi
sed -i "s/\([ \t]*Option[ \t]*\"ConnectedMonitor\"[ \t]*\)".*"/\1\"$CONNECTEDMONITOR\"/g" /etc/X11/xorg.conf.nvidia
#
# Always try to enable the card before switching scripts
#
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 1 ]; then
if [ -f /usr/local/bin/ironhide-enablecard ] ; then
/usr/local/bin/ironhide-enablecard
fi
if [ -f /usr/bin/ironhide-enablecard ] ; then
/usr/bin/ironhide-enablecard
fi
fi
x="message --width $WIDTH --height $HEIGHT"
${x} "The Image Transport is how the images are transferred from the\n"\
"nVidia card to the Intel card, people has different experiences of\n"\
"performance, but just select the default if you are in doubt.\n\n"\
"I recently discovered that yuv and jpeg both has some lagging\n"\
"this is only noticable in fast moving games, such as 1st person\n"\
"shooters and for me, its only good enough with xv, even though\n"\
"xv brings down performance a little."
x="menu -w $WIDTH -h $HEIGHT"
${x} "YUV" "JPEG" "PROXY" "XV (Default)" "RGB"
choice="$(0< "${dir_tmp}/${file_tmp}" )"
case "$choice" in
"YUV")
IMAGETRANSPORT="yuv"
;;
"JPEG")
IMAGETRANSPORT="jpeg"
;;
"PROXY")
IMAGETRANSPORT="proxy"
;;
"XV (Default)")
IMAGETRANSPORT="xv"
;;
"RGB")
IMAGETRANSPORT="rgb"
;;
*)
IMAGETRANSPORT="xv"
;;
esac
if [ -f ~/$LOCALECONFIGFILE ];then
sed -i 's/VGL_COMPRESS.*/VGL_COMPRESS='$IMAGETRANSPORT'/' ~/$LOCALECONFIGFILE
fi
chown $SUDO_USER:$SUDO_USER ~/$LOCALECONFIGFILE
sed -i 's/VGL_COMPRESS.*/VGL_COMPRESS='$IMAGETRANSPORT'/' $CONFIGURATIONFILE
if [ -f /usr/local/bin/ironhide-enablecard ] ; then
mv /usr/local/bin/ironhide-enablecard /usr/local/bin/ironhide-enablecard.old
x="message --width $WIDTH --height $HEIGHT"
${x} "nVidia card enable-script: /usr/local/bin/ironhide-enablecard exists.\n"\
"Moved old script to /usr/local/bin/ironhide-enablecard.old."
fi
if [ -f /usr/local/bin/ironhide-disablecard ]; then
mv /usr/local/bin/ironhide-disablecard /usr/local/bin/ironhide-disablecard.old
x="message --width $WIDTH --height $HEIGHT"
${x} "nVidia card enable-script: /usr/local/bin/ironhide-disablecard exists.\n"\
"Moving old script to /usr/local/bin/ironhide-disablecard.old."
fi
# Test basic functionality
/etc/init.d/ironhide enable
ERRORS=`cat /var/log/Xorg.\`echo $VGL_DISPLAY |cut -f2 -d:\`.log |grep EE |grep -v kbd |grep -v MIT-SCREEN-SAVER |grep -v "not implemented" | wc -l`
/etc/init.d/ironhide disable
if [[ $ERRORS == 0 ]]; then
x="message --width $WIDTH --height $HEIGHT"
${x} "Initial Testing seems ok..\n\n"\
"We're now going to test the basic functionality of Ironhide.\n"\
"After pressing OK, some gears should start rotating on your screen.\n"\
"They will run for five seconds, and will then prompt for the result."
if [[ $GLXGEARS != "" ]]; then
optirun $GLXGEARS &
x=wait_seconds
${x} 5
killall glxgears
x="question --width $WIDTH --height $HEIGHT"
${x} "Did some running gears show up??..\n\n"\
"If not, please do NOT continue and try another profile, or report this problem...:\n\n"\
"https://github.com/MrMEEE/ironhide/issues"
answer="${?}"
if [ ${answer} -eq 1 ]; then
exit 0
fi
else
x="question --width $WIDTH --height $HEIGHT"
${x} "We could't find glxgears on the system. Please install the mesa-utils package..\n\n"\
"Do you want to continue without completing the simple tests?? (not recommended)."
answer="${?}"
if [ ${answer} -eq 1 ]; then
exit 0
fi
fi
else
# Add some more Error handling
x="message --width $WIDTH --height $HEIGHT"
${x} "Initial tests failed..\n\n"\
"Please do report this problem..:\n"\
"https://github.com/MrMEEE/ironhide/issues"
fi
if [[ $POWERSTATUS != "UNAVAILABLE" ]] ; then
echo $POWERON | xxd -r -p > /usr/local/bin/ironhide-enablecard
echo $POWEROFF | xxd -r -p > /usr/local/bin/ironhide-disablecard
else
x="message --width $WIDTH --height $HEIGHT"
${x} "No power-on/off configuration has been reported for your machine,\n"\
"please manually enter configuration in:\n\n"\
"/usr/local/bin/ironhide-enablecard and /usr/local/bin/ironhide-disablecard\n\n"\
"Some examples are available in $EXAMPLEFOLDER."
cp $EXAMPLEFOLDER/ironhide-enablecard.template /usr/local/bin/ironhide-enablecard
cp $EXAMPLEFOLDER/ironhide-disablecard.template /usr/local/bin/ironhide-disablecard
fi
chmod +x /usr/local/bin/ironhide*
if [ `$LSPCI -v -s $NVIDIABUSIDCUT |grep ! |wc -l` = 0 ]; then
if [ -f /usr/local/bin/ironhide-disablecard ]; then
/usr/local/bin/ironhide-disablecard
fi
if [ -f /usr/bin/ironhide-disablecard ]; then
/usr/bin/ironhide-disablecard
fi
fi
/etc/init.d/ironhide enable
ERRORS=`cat /var/log/Xorg.\`echo $VGL_DISPLAY |cut -f2 -d:\`.log |grep EE |grep -v kbd |grep -v MIT-SCREEN-SAVER |grep -v "not implemented" | wc -l`
/etc/init.d/ironhide disable
if [[ $ERRORS == 0 ]];then
if [[ $POWERSTATUS != "UNAVAILABLE" ]]; then
x="message --width $WIDTH --height $HEIGHT"
${x} "Quick Testing of Ironhide with power management seems ok..\n\n"\
"After pressing OK, gears should again start rotating on your screen.\n"\
"They will run for five seconds, and will then prompt for the result."
if [ -f $GLXGEARS ]; then
optirun $GLXGEARS &
x=wait_seconds
${x} 5
killall glxgears
x="question --width $WIDTH --height $HEIGHT"
${x} "Did some running gears show up??..\n\n"\
"If not, please do NOT continue and try another profile, or report this problem...:\n\n"\
"https://github.com/MrMEEE/ironhide/issues"
answer="${?}"
if [ ${answer} -eq 1 ]; then
exit 0
fi
else
x="question --width $WIDTH --height $HEIGHT"
${x} "We could't find glxgears on the system. Please install the mesa-utils package..\n\n"\
"Do you want to continue without completing the power configuration tests?? (not recommended)."
answer="${?}"
if [ ${answer} -eq 1 ]; then
/usr/local/bin/ironhide-enablecard
cp $EXAMPLEFOLDER/ironhide-enablecard.template /usr/local/bin/ironhide-enablecard
cp $EXAMPLEFOLDER/ironhide-disablecard.template /usr/local/bin/ironhide-disablecard
#"We have replaced the"
exit 0
fi
fi
fi
else
# Add some more Error handling
x="message --width $WIDTH --height $HEIGHT"
${x} "Power configuration tests failed..\n\n"\
"Please do report this problem..:\n"\
"https://github.com/MrMEEE/ironhide/issues"
fi
update-rc.d ironhide defaults
#
# Set userrights
#
if [ "`grep ironhide /etc/group`" == "" ] ; then
groupadd ironhide
fi
gpasswd -a `env |grep SUDO_USER |cut -f2 -d=` ironhide
#
# That's all folks
#
x="message --width $WIDTH --height $HEIGHT"
${x} "Ironhide is now configured.\n\n"\
"If your system is working, please run the ironhide-submitsystem script\n\n"\
"If you have any problems, please run ironhide-bugreport\n\n"\
"Have fun...."
if [ -f ~/$LOCALECONFIGFILE ];then
sed -i "s/IRONHIDE_CONFIGURED=.*/IRONHIDE_CONFIGURED=1/g" ~/$LOCALECONFIGFILE
fi
sed -i "s/IRONHIDE_CONFIGURED=.*/IRONHIDE_CONFIGURED=1/g" $CONFIGURATIONFILE
chown $SUDO_USER:$SUDO_USER ~/$LOCALECONFIGFILE