-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel-switch
More file actions
784 lines (739 loc) · 21.5 KB
/
kernel-switch
File metadata and controls
784 lines (739 loc) · 21.5 KB
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
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
#! /bin/bash
#function: check currently installed kernel(s) in specified location (/boot or /mnt/mc00)
function check_installed_kernels {
if [ -z $1 ]
then
echo "Kernel location missing!"
return 1
fi
LOC=""
if [ "$1" = "boot" ]
then
LOC="/boot"
elif [ "$1" = "mc00" ]
then
LOC="/mnt/mc00"
else
echo "Invalid Kernel location!"
return 2
fi
if [ "$LOC" = "/mnt/mc00" ] && [ -z "$MOUNTED" ]
then
echo " Memory Card 0 not mounted!"
return 3
fi
KERNELS=""
for f in `find "$LOC" -type f 2>/dev/null`
do
VER=""
F_TYPE=`file -b "$f" | cut -d"," -f 1`
if [ "$F_TYPE" = "ELF 32-bit LSB executable" ] #raw kernel files
then
VER=`strings "$f" | grep -E "Linux version [a-zA-Z0-9\-_\.]{1,} \(" | cut -d" " -f 3`
if [ ! -z "$VER" ]
then
KERNELS="$KERNELS $VER,"
fi
elif [ "$F_TYPE" = "gzip compressed data" ] && [ "$LOC" = "/mnt/mc00" ] #gzipped kernel files on mc00
then
VER=`gzip -dc "$f" | strings | grep -E "Linux version [a-zA-Z0-9\-_\.]{1,} \(" | cut -d" " -f 3`
if [ ! -z "$VER" ]
then
KERNELS="$KERNELS $VER (gzipped),"
fi
fi
unset F_TYPE
unset VER
done
if [ ! -z "$KERNELS" ]
then
echo "$KERNELS" | tr "," "\n" | tr -d " " | sort -n | sort -u | perl -pe "s/\(/ \(/" | perl -pe "s/\n/, /" | cut -d"," -f 2- | rev | cut -d"," -f 2- | rev
else
echo -n " None"
if [ "$LOC" = "/mnt/mc00" ]
then
echo " (or not root)"
else
echo ""
fi
fi
unset LOC
unset KERNELS
return 0
}
#function: check running PS2 Linux version
function check_linux_version {
export LINUXVER=""
if [ -f /etc/ps2-release ]
then
VER=`head -n 1 /etc/ps2-release | perl -pe "s/ $//" | rev | cut -d" " -f 1 | rev`
if [ "$VER" = "1.0beta" ]
then
LINUXVER="Beta"
elif [ "$VER" = "1.0" ]
then
LINUXVER="Release"
else
LINUXVER="UNKNOWN"
fi
unset VER
else
LINUXVER="UNKNOWN"
fi
}
#function: find requested kernel version file in /boot. If multiple files of same version found, prompt for desired file.
function select_kernel_in_boot {
export KERNEL=""
for f in `find /boot -type f 2>/dev/null`
do
F_TYPE=`file -b "$f" | cut -d"," -f 1`
if [ "$F_TYPE" = "ELF 32-bit LSB executable" ]
then
VER=`strings "$f" | grep -E "Linux version $VERSION \(" | cut -d" " -f 3`
if [ ! -z "$VER" ]
then
KERNEL="$KERNEL $f"
fi
unset VER
fi
unset F_TYPE
done
KERNEL=`echo "$KERNEL" | cut -d" " -f 2-`
if [ -z "$KERNEL" ] #requested kernel version not installed in /boot
then
return 5
else
echo "$KERNEL" | grep " " > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo -e "\nMultiple $VERSION Kernel files found! Select correct Kernel file:"
i=1
for k in `echo $KERNEL | tr " " "\n"`
do
echo "$i) $k"
i=$((i+1))
done
i=$((i-1))
echo -en "\n(`seq 1 $i | tr "\n" "/" | rev | cut -d"/" -f 2- | rev`): "
read -r CHOICE
case $CHOICE in
[`seq 1 $i`])
KERNEL=`echo -n $KERNEL | cut -d" " -f $CHOICE`;;
*)
echo -n "Invalid Kernel file specified"
return 6;;
esac
unset k
unset i
unset CHOICE
fi
fi
return 0
}
#function: print usage information
function usage {
echo "Usage: $1 [OPTIONS] [KERNEL_VERSION]"
echo -e "\nOptions:"
echo "-t: Check links/config files and print which Kernel is currently configured (does not require a KERNEL_VERSION argument)"
echo "-c: Configure system for requested Kernel, but do not install Kernel on Memory Card 0"
echo "-k: Install Kernel file on Memory Card 0, but do not configure system for installed kernel"
echo "-r: Install requested Kernel without gzip compression"
echo "-s: Do not set newly-installed Kernel as default boot option"
echo -e "\nKERNEL_VERSION values:"
echo "2.2.1: Kernel 2.2.1"
echo "2.2.19: Kernel 2.2.19"
echo "2.4.17: Kernel 2.4.17_mvl21"
echo "2.4.17_mvl21: Kernel 2.4.17_mvl21"
}
#BEGIN kernel-switch
#check for root privileges
ADM="root"
if [ "$(whoami)" != "root" ]
then
echo -e "$0 must be run as root!\n"
ADM=""
fi
#declare vars for command line options
CHECK_CONFIGURATION=""
CONFIGURE_ONLY=""
INSTALL_ONLY=""
RAW_KERNEL=""
NO_DEFAULT_BOOT=""
#check for command line arguments
export VERSION=""
check_linux_version
export MOUNTED=`mount | grep mc00`
if [ $# -eq 0 ] #if none, print usage information, current PS2 Linux version, currently installed kernel(s), and currently running kernel, then exit
then
usage $0
echo -en "\nRunning PS2 Linux Version: "
if [ "$LINUXVER" = "Beta" ]
then
echo "Beta Release 1"
elif [ "$LINUXVER" = "Release" ]
then
echo "Release 1.0"
else
echo "$LINUXVER"
fi
echo "Running Kernel: `uname -r`"
echo -n "Kernel(s) installed in /boot:"
check_installed_kernels boot
echo -n "Kernel(s) installed on memory card:"
check_installed_kernels mc00
echo ""
unset LINUXVER
unset MOUNTED
exit 4
else
i=1
for ARG in "$@"
do
case $ARG in
"-t") CHECK_CONFIGURATION="check";;
"-r")
if [ $i -ne $# ]
then
RAW_KERNEL="raw"
else
echo -e "$ARG option requires KERNEL_VERSION argument!\n"
usage $0
exit 1
fi;;
"-s")
if [ $i -ne $# ]
then
NO_DEFAULT_BOOT="skip"
else
echo -e "$ARG option requires KERNEL_VERSION argument!\n"
usage $0
exit 1
fi;;
"-c")
if [ $i -ne $# ]
then
CONFIGURE_ONLY="configure"
else
echo -e "$ARG option requires KERNEL_VERSION argument!\n"
usage $0
exit 1
fi;;
"-k")
if [ $i -ne $# ]
then
INSTALL_ONLY="install"
else
echo -e "$ARG option requires KERNEL_VERSION argument!\n"
usage $0
exit 1
fi;;
"2.2.1")
if [ $i -eq $# ]
then
VERSION="2.2.1"
else
echo -e "$ARG: invalid option!\n"
usage $0
exit 1
fi;;
"2.2.19")
if [ $i -eq $# ]
then
VERSION="2.2.19"
else
echo -e "$ARG: invalid option!\n"
usage $0
exit 1
fi;;
"2.4.17")
if [ $i -eq $# ]
then
VERSION="2.4.17_mvl21"
else
echo -e "$ARG: invalid option!\n"
usage $0
exit 1
fi;;
"2.4.17_mvl21")
if [ $i -eq $# ]
then
VERSION="2.4.17_mvl21"
else
echo -e "$ARG: invalid option!\n"
usage $0
exit 1
fi;;
*)
if [ $i -eq $# ]
then
echo -e "$ARG: invalid requested Kernel version!\n"
else
echo -e "$ARG: invalid option!\n"
fi
usage $0
exit 1;;
esac
i=$((i+1))
done
unset i
fi
#detect conflicting arguments
if [ ! -z "$CHECK_CONFIGURATION" ]
then
if [ ! -z "$RAW_KERNEL" ] || [ ! -z "$NO_DEFAULT_BOOT" ] || [ ! -z "$CONFIGURE_ONLY" ] || [ ! -z "$INSTALL_ONLY" ]
then
echo -e "-t argument cannot be used in conjunction with any other options!\n"
exit 1
fi
fi
if [ ! -z "$CONFIGURE_ONLY" ]
then
if [ ! -z "$RAW_KERNEL" ] || [ ! -z "$NO_DEFAULT_BOOT" ]
then
echo -e "-c argument cannot be used in conjunction with any other options!\n"
exit 1
fi
fi
if [ ! -z "$CONFIGURE_ONLY" ] && [ ! -z "$INSTALL_ONLY" ]
then
echo -e "-c argument and -k argument cannot be used in conjunction with one another!\n"
exit 1
fi
#abort execution if not running as root
if [ -z "$ADM" ]
then
unset LINUXVER
exit 3
fi
unset ADM
#abort execution of Memory Card 0 is not mounted (unless -c option is set)
if [ -z "$MOUNTED" ] && [ -z "$CONFIGURE_ONLY" ]
then
echo "Memory Card 0 not mounted! Mount Memory Card 0 and try again!"
exit 2
fi
#if -t option is set: print current system configuration and exit
if [ ! -z "$CHECK_CONFIGURATION" ]
then
echo -e "\nChecking current system configuration"
#check default boot entry in /mnt/mc00/p2lboot.opt
echo -n "Default boot entry (in p2lboot.opt): "
grep -E "^prevent=" /mnt/mc00/p2lboot.opt > /dev/null 2>&1
if [ $? -eq 0 ]
then
grep -E "^prevent=" /mnt/mc00/p2lboot.opt | cut -d"%" -f 1 | cut -d"=" -f 2-
else
echo "None (no \"prevent\" entry in p2lboot.opt file)"
fi
#check /boot links for Release 1.0
if [ "$LINUXVER" != "Beta" ]
then
echo -n "/boot/vmlinux link: "
VER=""
if [ -L "/boot/vmlinux" ]
then
BOOT_LN=`ls -l /boot/vmlinux | rev | cut -d" " -f 1 | rev`
case $BOOT_LN in
"vmlinux-2.2.1_ps2") echo "2.2.1 (set to $BOOT_LN)";;
"vmlinux-2.2.19_ps2") echo "2.2.19 (set to $BOOT_LN)";;
"vmlinux-2.4.17_mvl21") echo "2.4.17_mvl21 (set to $BOOT_LN)";;
*) echo "Unknown Kernel! (set to $BOOT_LN)"
esac
else
echo "Not set! Recommend creating it manually, or automatically by installing/configuring kernel with $0"
fi
echo -n "/boot/System.map link: "
if [ -L "/boot/System.map" ]
then
BOOT_LN=`ls -l /boot/System.map | rev | cut -d" " -f 1 | rev`
case $BOOT_LN in
"System.map-2.2.1_ps2") echo "2.2.1 (set to $BOOT_LN)";;
"System.map-2.2.19_ps2") echo "2.2.19 (set to $BOOT_LN)";;
"System.map-2.4.17_mvl21") echo "2.4.17_mvl21 (set to $BOOT_LN)";;
*) echo "Unknown Kernel! (set to $BOOT_LN)"
esac
else
echo "Not set! Recommend creating it manually, or automatically by installing/configuring kernel with $0"
fi
fi
#check /usr/src/linux link
echo -n "/usr/src/linux link: "
if [ -L /usr/src/linux ]
then
SRC_LN=`ls -l /usr/src/linux | rev | cut -d" " -f 1 | rev`
case $SRC_LN in
"linux-2.2.1_ps2") echo "2.2.1 Kernel (set to $SRC_LN)";;
"linux-2.2.19_ps2") echo "2.2.19 Kernel (set to $SRC_LN)";;
"linux-2.4.17_ps2") echo "2.4.17_mvl21 Kernel (set to $SRC_LN)";;
*) echo "Unknown Kernel! ($SRC_LN)";;
esac
else
echo "Not set! Recommend creating it manually, or automatically with $0 using the -c option"
fi
#check /dev/mouse and /dev/usbmouse links
echo -n "/dev/mouse link: Set to "
if [ -L /dev/mouse ]
then
MOUSE=`ls -l /dev/mouse | rev | cut -d" " -f 1 | rev`
if [ "$MOUSE" = "usbmouse" ]
then
echo "$MOUSE (recommended)"
else
echo "$MOUSE. Recommend manually setting target to /dev/usbmouse, or automatically re-creating with $0 using the -c option"
fi
else
echo "Not set! Recommend creating it manually with target set to /dev/usbmouse, or automatically with $0 using the -c option"
fi
echo -n "/dev/usbmouse link: "
if [ -L /dev/usbmouse ]
then
USBMOUSE=`ls -l /dev/usbmouse | rev | cut -d" " -f 1 | rev`
case $USBMOUSE in
"usbmouse0")
echo "2.2.1 Kernel (set to $USBMOUSE)";;
"usbmouse0-2.2.19")
echo "2.2.19 Kernel (set to $USBMOUSE)";;
"input/mice")
echo "2.4.17_mvl21 Kernel (set to $USBMOUSE)";;
*)
echo "Unknown Kernel! (set to $USBMOUSE)";;
esac
unset USBMOUSE
else
echo "Not set! Recommend creating it manually, or automatically with $0 using the -c option"
fi
#check /etc/modules.conf file
echo -n "/etc/modules.conf file: "
MODULES_CONF=""
MODULES_2_1=`grep "char-major-10-32" /etc/modules.conf | grep -v "#"`
MODULES_2_19=`grep "char-major-13-32" /etc/modules.conf | grep -v "#"`
MODULES_4_17=`grep "char-major-13-63" /etc/modules.conf | grep -v "#"`
if [ ! -z "$MODULES_2_1" ] || [ ! -z "$MODULES_2_19" ] || [ ! -z "$MODULES_4_17" ]
then
if [ ! -z "$MODULES_2_1" ]
then
MODULES_CONF="2.2.1"
fi
if [ ! -z "$MODULES_2_19" ]
then
if [ -z "$MODULES_CONF" ]
then
MODULES_CONF="2.2.19"
else
MODULES_CONF="$MODULES_CONF 2.2.19"
fi
fi
if [ ! -z "$MODULES_4_17" ]
then
if [ -z "$MODULES_CONF" ]
then
MODULES_CONF="2.4.17_mvl21"
else
MODULES_CONF="$MODULES_CONF 2.4.17_mvl21"
fi
fi
echo $MODULES_CONF | grep " " >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo -e "$MODULES_CONF Kernels\n\tWarning: multiple Kernels observed configured in /etc/modules.conf. Recommend manually editing file to set single mousedev line, or set automatically with $0 using -c option"
else
echo "$MODULES_CONF Kernel"
fi
else
grep mousedev /etc/modules.conf | grep -vE "^#" >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "None! No uncommented mousedev line present in file. Recommend creating this manually, or automatically with $0 using -c option"
else
echo "Unknown Kernel! Unrecognized mousedev line present in file."
fi
fi
unset MODULES_CONF
unset MODULES_2_1
unset MODULES_2_19
unset MODULES_4_17
echo -e "\nTo check Kernel files installed in /boot and on Memory Card 0, execute $0 without arguments"
exit 0
fi
# if -c option is not set: perform necessary preliminary operations to install kernel
OUTFILE=""
if [ -z "$CONFIGURE_ONLY" ]
then
#set kernel destination filename on mc00
case $VERSION in
"2.2.1") OUTFILE="vmlinux";; #if 2.2.1 kernel should be copied as vmlinux-2.2.1 or vmlinux-2.2.1.gz, comment this line out
*) OUTFILE="vmlinux-$VERSION";;
esac
if [ -z "$RAW_KERNEL" ]
then
OUTFILE="${OUTFILE}.gz"
fi
echo "Locating Kernel $VERSION file(s) in /boot"
select_kernel_in_boot
RES=$?
if [ $RES -eq 5 ]
then
echo "Kernel $VERSION not found in /boot! Ensure Kernel file is in /boot directory before attempting to install to Memory Card!"
unset KERNEL
exit 5
elif [ $RES -eq 6 ]
then
echo ", aborting!"
unset KERNEL
exit 6
fi
#confirm enough freespace on mc00
echo -en "\nConfirming sufficient free space on Memory Card 0 to install Kernel $VERSION: "
MC_SPACE=`df --block-size=1 /mnt/mc00 | tr -s " " | grep mc00 | cut -d" " -f 4`
KERNEL_SIZE=`ls -l "$KERNEL" | tr -s " " | grep "$KERNEL" | cut -d" " -f 5`
if [ -z "$RAW_KERNEL" ]
then
gzip -c9 "$KERNEL" > "/tmp/${OUTFILE}"
chmod 700 "/tmp/${OUTFILE}"
KERNEL_SIZE=`ls -l "/tmp/${OUTFILE}" | tr -s " " | grep "/tmp/${OUTFILE}" | cut -d" " -f 5`
fi
if [ -f "/mnt/mc00/${OUTFILE}" ]
then
OLD_KERNEL_SIZE=`ls -l "/mnt/mc00/${OUTFILE}" | tr -s " " | grep "/mnt/mc00/${OUTFILE}" | cut -d" " -f 5`
KERNEL_SIZE=$((KERNEL_SIZE-OLD_KERNEL_SIZE))
unset OLD_KERNEL_SIZE
fi
if [ $MC_SPACE -lt $KERNEL_SIZE ] #not enough freespace on memory card
then
echo "Not enough free space , aborting!"
rm -f "/tmp/${OUTFILE}"
exit 7
else
echo "Done"
fi
unset MC_SPACE
unset KERNEL_SIZE
fi
#begin installation
if [ ! -z "$CONFIGURE_ONLY" ]
then
echo -e "\nConfiguring Kernel $VERSION"
elif [ ! -z "$INSTALL_ONLY" ]
then
echo -e "\nInstalling Kernel $VERSION"
else
echo -e "\nInstalling and configuring Kernel $VERSION"
fi
# if -c option is not set: install requested kernel to memory card and perform additional necessary operations (if requested)
ENTRY=""
if [ -z "$CONFIGURE_ONLY" ]
then
#copy kernel to memory card (gzipped if requested)
if [ -f "/mnt/mc00/${OUTFILE}" ]
then
echo "Warning: Overwriting existing $OUTFILE Kernel file present on Memory Card 0"
fi
if [ -z "$RAW_KERNEL" ]
then
cp -f "/tmp/${OUTFILE}" "/mnt/mc00/${OUTFILE}"
rm -f "/tmp/${OUTFILE}"
else
cp -f "$KERNEL" "/mnt/mc00/${OUTFILE}"
fi
chmod 700 "/mnt/mc00/${OUTFILE}"
#check for boot entry in /mnt/mc00/p2lboot.cnf, create one if not present
grep "$OUTFILE \"\"" /mnt/mc00/p2lboot.cnf >/dev/null 2>&1
if [ "$?" -eq 0 ]
then
ENTRY=`grep "$OUTFILE \"\"" /mnt/mc00/p2lboot.cnf | cut -d"\"" -f 2`
else #copy p2lboot.cnf to /tmp for editing, as ps2mcfs does not appear to allow in-place editing of files
ENTRY="$VERSION"
PART=`grep " / " /etc/fstab | cut -d" " -f 1`
cp /mnt/mc00/p2lboot.cnf /tmp/p2lboot.cnf
chmod 700 /tmp/p2lboot.cnf
echo -e "\"$VERSION\"\t$OUTFILE \"\"\t203 $PART \"\" $VERSION Kernel" >> /tmp/p2lboot.cnf
cp /tmp/p2lboot.cnf /mnt/mc00/p2lboot.cnf
rm -f /tmp/p2lboot.cnf
chmod 700 /mnt/mc00/p2lboot.cnf
echo "Warning: pre-existing boot entry for $VERSION Kernel not found in /mnt/mc00/p2lboot.cnf, so new \"$ENTRY\" entry was created."
fi
#set default boot entry in /mnt/mc00/p2lboot.opt to newly-installed kernel (unless -s option is specified); copy p2lboot.opt to /tmp for editing, as ps2mcfs does not appear to allow in-place editing of files
if [ -z "$NO_DEFAULT_BOOT" ]
then
cp /mnt/mc00/p2lboot.opt /tmp/p2lboot.opt
chmod 700 /tmp/p2lboot.opt
grep -E "^prevent=" /mnt/mc00/p2lboot.opt > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "prevent=${ENTRY}%mc0:/BWLINUX/${OUTFILE}%" >> /tmp/p2lboot.opt
else
perl -i -pe "s/prevent=.*/prevent=${ENTRY}\%mc0:\/BWLINUX\/${OUTFILE}\%/" /tmp/p2lboot.opt
fi
cp /tmp/p2lboot.opt /mnt/mc00/p2lboot.opt
rm -f /tmp/p2lboot.opt
chmod 700 /mnt/mc00/p2lboot.opt
fi
fi
#if -k option is not set: perform configuration operations
if [ -z "$INSTALL_ONLY" ]
then
#for Release 1.0: set /boot/vmlinux and /boot/System.map symlinks
if [ "$LINUXVER" != "Beta" ]
then
if [ -L "/boot/vmlinux" ]
then
rm -f /boot/vmlinux
fi
if [ -L "/boot/System.map" ]
then
rm -f /boot/System.map
fi
if [ -z $KERNEL ]
then
select_kernel_in_boot
RES=$?
if [ $RES -eq 5 ]
then
echo "Kernel $VERSION not found in /boot! Ensure Kernel file is in /boot directory before attempting to configure system!"
unset KERNEL
exit 5
elif [ $RES -eq 6 ]
then
echo "!"
unset KERNEL
exit 6
fi
fi
ln -s "`echo $KERNEL | rev | cut -d"/" -f 1 | rev`" /boot/vmlinux
SYSTEM_MAP="System.map`echo $KERNEL | rev | cut -d"/" -f 1 | rev | cut -d"x" -f 2`"
if [ ! -f "/boot/$SYSTEM_MAP" ]
then
echo -e "\nWarning: expected $SYSTEM_MAP file not found in /boot, so not setting /boot/System.map symbolic link!"
else
ln -s "$SYSTEM_MAP" /boot/System.map
fi
unset SYSTEM_MAP
fi
#set kernel source link
SRC_LN=$(ls -d /usr/src/linux-`echo $VERSION | cut -d"_" -f 1`_ps2 2>/dev/null | rev | cut -d"/" -f 1 | rev)
if [ ! -z "$SRC_LN" ]
then
if [ -L /usr/src/linux ]
then
rm -f /usr/src/linux
fi
ln -s "$SRC_LN" /usr/src/linux
else
echo "Warning: /usr/src/linux symbolic link could not be created because Kernel $VERSION source directory was not detected by name (expected \"linux-${VERSION}_ps2\" directory in /usr/src). Recommend manually creating link."
fi
#set mouse link
OUTFILE=""
rm -f /dev/usbmouse
case $VERSION in
"2.2.1")
OUTFILE="usbmouse0"
if [ ! -c "/dev/usbmouse0" ]
then
mknod /dev/usbmouse0 c 10 32
fi;;
"2.2.19")
OUTFILE="usbmouse0-2.2.19"
if [ ! -c "/dev/usbmouse0-2.2.19" ]
then
mknod /dev/usbmouse0-2.2.19 c 13 32
fi;;
"2.4.17_mvl21")
OUTFILE="input/mice"
if [ ! -c "/dev/input/mice" ]
then
mkdir -p /dev/input
mknod /dev/input/mice c 13 63
fi;;
esac
ln -s "$OUTFILE" /dev/usbmouse
if [ -L /dev/mouse ]
then
if [ "`ls -l /dev/mouse | rev | cut -d" " -f 1 | rev`" != "usbmouse" ]
then
echo "Warning: /dev/mouse symbolic link target is not /dev/usbmouse. Recommend manually setting /dev/mouse target to /dev/usbmouse"
fi
else
ln -s usbmouse /dev/mouse
fi
#edit /etc/modules.conf with correct "mousedev" line enabled
case $VERSION in
"2.2.1")
perl -i -pe "s/^alias[ \t]{1,}char-major-13-32[ \t]{1,}mousedev$/#alias\tchar-major-13-32\tmousedev/" /etc/modules.conf
perl -i -pe "s/^alias[ \t]{1,}char-major-13-63[ \t]{1,}mousedev$/#alias\tchar-major-13-63\tmousedev/" /etc/modules.conf
grep "char-major-10-32" /etc/modules.conf >/dev/null 2>&1
if [ $? -eq 0 ]
then
perl -i -pe "s/^#alias[ \t]{1,}char-major-10-32[ \t]{1,}mousedev$/alias\tchar-major-10-32\tmousedev/" /etc/modules.conf
else
touch /tmp/modules.conf
chmod 600 /tmp/modules.conf
( echo -e "alias\tchar-major-10-32\tmousedev" && cat /etc/modules.conf ) > /tmp/modules.conf
cp /tmp/modules.conf /etc/modules.conf
chmod 644 /etc/modules.conf
rm /tmp/modules.conf
fi;;
"2.2.19")
perl -i -pe "s/^alias[ \t]{1,}char-major-10-32[ \t]{1,}mousedev$/#alias\tchar-major-10-32\tmousedev/" /etc/modules.conf
perl -i -pe "s/^alias[ \t]{1,}char-major-13-63[ \t]{1,}mousedev$/#alias\tchar-major-13-63\tmousedev/" /etc/modules.conf
grep "char-major-13-32" /etc/modules.conf >/dev/null 2>&1
if [ $? -eq 0 ]
then
perl -i -pe "s/^#alias[ \t]{1,}char-major-13-32[ \t]{1,}mousedev$/alias\tchar-major-13-32\tmousedev/" /etc/modules.conf
else
touch /tmp/modules.conf
chmod 600 /tmp/modules.conf
( echo -e "alias\tchar-major-13-32\tmousedev" && cat /etc/modules.conf ) > /tmp/modules.conf
cp /tmp/modules.conf /etc/modules.conf
chmod 644 /etc/modules.conf
rm /tmp/modules.conf
fi;;
"2.4.17_mvl21")
perl -i -pe "s/^alias[ \t]{1,}char-major-10-32[ \t]{1,}mousedev$/#alias\tchar-major-10-32\tmousedev/" /etc/modules.conf
perl -i -pe "s/^alias[ \t]{1,}char-major-13-32[ \t]{1,}mousedev$/#alias\tchar-major-13-32\tmousedev/" /etc/modules.conf
grep "char-major-13-63" /etc/modules.conf >/dev/null 2>&1
if [ $? -eq 0 ]
then
perl -i -pe "s/^#alias[ \t]{1,}char-major-13-63[ \t]{1,}mousedev$/alias\tchar-major-13-63\tmousedev/" /etc/modules.conf
else
touch /tmp/modules.conf
chmod 600 /tmp/modules.conf
( echo -e "alias\tchar-major-13-63\tmousedev" && cat /etc/modules.conf ) > /tmp/modules.conf
cp /tmp/modules.conf /etc/modules.conf
chmod 644 /etc/modules.conf
rm /tmp/modules.conf
fi;;
esac
fi
if [ ! -z "$CONFIGURE_ONLY" ]
then
echo -e "\nSystem configured for Kernel $VERSION. Recommend immediate reboot into newly configured Kernel $VERSION.\n"
if [ "`uname -r`" != "2.2.1" ]
then
echo -e "Alternatively, boot the newly configured kernel via AKMem.\n"
fi
elif [ ! -z "$INSTALL_ONLY" ]
then
echo -e "\nKernel $VERSION installed. Recommend reconfiguring system for newly installed Kernel before rebooting into Kernel."
else
echo -e "\nReboot and select \"$ENTRY\" boot entry to use newly installed and configured Kernel $VERSION."
if [ "`uname -r`" != "2.2.1" ]
then
echo -e "Alternatively, boot the newly installed kernel via AKMem.\n"
else
echo -en "\n"
fi
fi
if [ "$VERSION" = "2.4.17_mvl21" ] && [ "$LINUXVER" = "Beta" ]
then
echo -e "\nWarning: Kernel $VERSION will not boot directly from the PS2 Linux Beta Release 1 DVD-ROM! This Kernel can instead be booted from:"
echo -e "\t* The PS2 Linux Release 1.0 DVD-ROM\n\t* Another Kernel with AKMem support (such as 2.2.19) via AKMem\n\t* BB Navigator via AKMem\n"
fi
unset MOUNTED
unset VERSION
unset KERNEL
unset LINUXVER
unset ENTRY
unset OUTFILE
unset SRC_LN
exit 0
#END kernel-switch