Dash:
[t2.git] / package / boot / kboot / stone_mod_kboot.sh
blob08ebb898a12ba14bb169b167c7f1fd39975c05f3
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/*/kboot/stone_mod_kboot.sh
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 # [MAIN] 70 kboot kBoot Loader Setup
16 # [SETUP] 90 kboot
18 create_kernel_list() {
19 first=1
20 for x in `(cd /boot/; ls vmlinux-* ) | sort -r`; do
21 if [ $first = 1 ]; then
22 label=t2sde; first=0
23 else
24 label=t2sde-${x/vmlinux-/}
26 ver=${x/vmlinux-}
27 cat << EOT
28 $label='$bootpath/$x initrd=$bootpath/initrd-${ver} root=$rootdev' # video=ps3fb:mode:13
29 EOT
30 done
33 create_kboot_conf() {
34 mkdir -p $etcpath/etc/
35 create_kernel_list > $etcpath/etc/kboot.conf
37 gui_message "This is the new $etcpath/etc/kboot.conf file:
39 $(< $etcpath/etc/kboot.conf)"
42 device4() {
43 local dev="`sed -n "s,\([^ ]*\) $1 .*,\1,p" /proc/mounts | tail -n 1`"
44 if [ ! "$dev" ]; then # try the higher dentry
45 local try="`dirname $1`"
46 dev="`grep \" $try \" /proc/mounts | tail -n 1 | \
47 cut -d ' ' -f 1`"
49 if [ -h "$dev" ]; then
50 echo "/dev/`readlink $dev`"
51 else
52 echo $dev
56 realpath() {
57 dir="`dirname $1`"
58 file="`basename $1`"
59 dir="`dirname $dir`/`readlink $dir`"
60 dir="`echo $dir | sed 's,[^/]*/\.\./,,g'`"
61 echo $dir/$file
64 main() {
65 rootdev="`device4 /`"
66 bootdev="`device4 /boot`"
68 [ "$rootdev" != "$bootdev" ] && etcpath=/boot || bootpath=/boot
70 if [ ! -f /boot/etc/kboot.conf ]; then
71 if gui_yesno "kBoot does not appear to be configured.
72 Automatically configure kboot now?"; then
73 create_kboot_conf
77 while
79 gui_menu kboot 'kBoot Loader Setup' \
80 "Following settings only for expert use: (default)" ""\
81 "Root Device ........... $rootdev" "" \
82 "Boot Device ........... $bootdev" "" \
83 '' '' \
84 "(Re-)Create default $etcpath/etc/kboot.conf" 'create_kboot_conf' \
85 '' '' \
86 "Edit $etcpath/etc/kboot.conf (Config file)" \
87 "gui_edit 'kBoot Configuration' $etcpath/etc/kboot.conf"
88 do : ; done