
Ubuntu日本語フォーラム

ログインしていません。
起動時のOS選択メニューを簡素化したいのですが、間違えるととんでもないことになりそうなので、触れません。
どこにある、どういうファイルを、どういうソフトで編集したらいいのか、どなたか教えてください。
オフライン
こんにちは
swesanさん による投稿:
起動時のOS選択メニューを簡素化したい
1 OSはUbuntu? Windows7 or Vista or Xpはある?
2 OSはUbuntuだとして、9.10 or other?
3 OSは9.10 だとして、BootLoaderはGrub or other?
4 Grubだとして、2 or Regacy?
という具合で、OSやBootLoaderによって設定ファイルが異なりますので、もう少し書いてください。
オフライン
ありがとうございます。
1. OSはUbuntu 9.10と Windows XP SP3
2. BootLoaderが何か知りません。昨年末、CDを使って、Windowsに共存させる形でインストールしました。
申し訳ありませんが、どういうApplicationか、どんなVersionか、どうやって調べるのかも知りません。Systemフォルダーの中を調べればいいですか?
すみませんね、要領を得ない回答で。
オフライン
root フォルダー の中に grubというフォルダーがあって、その中に、grub.cfgというのがありますが、開いてみても、2 なのか Regacyなのか記述はありません。
オフライン
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-20-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-20-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro quiet splash
initrd /boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-20-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-20-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro single
initrd /boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-19-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-19-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro quiet splash
initrd /boot/initrd.img-2.6.31-19-generic
}
menuentry "Ubuntu, Linux 2.6.31-19-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-19-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro single
initrd /boot/initrd.img-2.6.31-19-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set cf764df6-bf51-4e7e-a8a8-60e930f64106
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=cf764df6-bf51-4e7e-a8a8-60e930f64106 ro single
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 7e0412da041294ed
drivemap -s (hd0) ${root}
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###以上が grub.cfg の内容です。
オフライン
All executable files in this directory are processed in shell expansion order. 00_*: Reserved for 00_header. 10_*: Native boot entries. 20_*: Third party apps (e.g. memtest86+). The number namespace in-between is configurable by system installer and/or administrator. For example, you can add an entry to boot another OS as 01_otheros, 11_otheros, etc, depending on the position you want it to occupy in the menu; and then adjust the default setting via /etc/default/grub.
以上が、etc の中の grub.d というフォルダーにあるREADME の中身です。
環境がご理解いただけるでしょうか?
オフライン
簡素化したいという具体的意味は、Ubuntuのメニューだけでもリカバリー用とか幾つもあります。
OSが壊れたら、再インストールすればいいと、簡単に考えております。
Ubuntuの勉強がてら、使う気もない同じようなメニューを画面から消してしまいたいのです。
よろしくお願いします。
オフライン
※規約違反により追放されたユーザの投稿は、ログインユーザにのみ表示されます。
オフライン
swesanさん、今晩は。(今回は文書力のカバーにBBcodeを多様してみました)
kiyopさんのURLにも変則的な事を書いていますが、別の変化球もどうぞ。
grub.cfgは各セクションを担当するファイルがupdate-grubの実行時などにgrub.cfgに拾い集めたデータを書き込んでいます。
書き込む順番は「あいうえお順」(降順?昇順?)なので、ファイル名の先頭に数字を付けて順番を決めています。
/etc/grub.d 配下の
00_header、05_debian_theme、10_linux、20_memtest86+、30_os-prober、40_custom
がgrub.cfgに順番に書き込まれていきます。
### BEGIN /etc/grub.d/00_header ###(ここから00_headerの内容が反映されます)
~内容~
### END /etc/grub.d/00_header ###(00_headerここまで。)
こんな感じで書き込まれていくのですが、メインの起動項目を担当しているのが10_linuxです。
こいつは「カーネルバージョンの高い(新しい)ものから順に読み込んで書き込む」を繰り返すので、「繰り返す」のを止めさせれば、古いカーネルを残してシステム又は手動のアップデートでも更新が有った場合は最新の物に書き換わります。
方法は単純で「半角英数で[#]を2ヶ所に記入」するだけです。
$ sudo gedit /etc/grub.d/10_linux
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
#
# GRUB 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.
#
# GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
. ${libdir}/grub/grub-mkconfig_lib
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
/dev/loop/*|/dev/loop[0-9])
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
# We can't cope with devices loop-mounted from files here.
case ${GRUB_DEVICE} in
/dev/*) ;;
*) exit 0 ;;
esac
;;
esac
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
# add crashkernel option if we have the required tools
if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then
GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
fi
linux_entry ()
{
cat << EOF
menuentry "$1" {
recordfail=1
if [ -n \${have_grubenv} ]; then save_env recordfail; fi
EOF
if [ "x$3" = "xquiet" ]; then
cat << EOF
set quiet=1
EOF
fi
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2
EOF
if test -n "${initrd}" ; then
cat << EOF
initrd ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF
}
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
#while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
echo "Found linux image: $linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
initrd=
for i in "initrd.img-${version}" "initrd-${version}.img" \
"initrd-${version}" "initrd.img-${alt_version}" \
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
fi
done
if test -n "${initrd}" ; then
echo "Found initrd image: ${dirname}/${initrd}" >&2
else
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
linux_root_device_thisversion=${GRUB_DEVICE}
fi
linux_entry "${OS}, Linux ${version}" \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
quiet
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}, Linux ${version} (recovery mode)" \
"single ${GRUB_CMDLINE_LINUX}"
fi
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
#done
オフライン
こいつは「カーネルバージョンの高い(新しい)ものから順に読み込んで書き込む」を繰り返すので、「繰り返す」のを止めさせれば、古いカーネルを残してシステム又は手動のアップデートでも更新が有った場合は最新の物に書き換わります。
古いカーネルを削除すること無く、起動メニューには新しいバージョンのカーネルを表示する。
(と言う意味です)
#文書力はBBcodeでカバー出来ないのですね、すこしブルーな気分です。
オフライン
皆さんありがとうございます。
じっくり勉強しながら挑戦します。
手元には、他に2台Ubuntuがありますから、失敗しても被害の少ない(一番使ってない)ものから始めてみます。
都度、結果は報告します。
行き詰まったら、また支援してください。
オフライン
hir0さん
このご指導はsynapticパッケージマネージャで変更を実施した後の、新しいアップデートに対応するものと考えていいでしょうか?
#を二つ追記変更後は
$ sudo update-grub
これを実行する必要がありますか?
オフライン
ご支援いただいた皆さん、有難うございました。
おかげさまで、次の二つに簡素化できました。
Ubuntu, Linux 2.6.31-20-generic
Windows XP
実施したステップは次のとおりです。
1. synapticパッケージマネージャで不要なメニューを削除
2. 端末から
$ sudo gedit /etc/default/grubで,
#GRUB_DISABLE_LINUX_RECOVERY="true" の先頭の「#」を取り除き、保存しました。
(リカバリーメニューも削除のため)
3. 同じく端末から
$ sudo gedit /etc/grub.d/10_linuxで、#9で指導いただいた、二つの#を追加
(今後のアップデートに対応するため?)
4. 同じく端末から
$ sudo update-grub を実行
以上ですが、どこか間違えておりますでしょうか? 再起動しても、目下問題ありません。
ご指導有難うございました。Ubuntuの入り口が少し理解できたような気がしてます。
オフライン
※規約違反により追放されたユーザの投稿は、ログインユーザにのみ表示されます。
オフライン
連休を利用して作って見ました。
中身の記述は素人の趣味なので恥ずかしいのですが、、、
***************************************************
GRUB 2 Adjust of menu
***************************************************
[ 0] プロファイルの表示と変更の摘要
[ 1] デフォルトのメニューエントリーの選択
[ 2] デフォルトのエントリーが起動されるまでの秒数
[ 3] 起動オプションの追加
[ 4] 起動オプション"quiet splash"の削除と変更
[ 5] リカバリーモードの表示と非表示
[ 6] OSの検出機能の"ON","OFF"
[ 7] memtest86+ の表示と非表示
[ 8] 最新のバージョンのみ表示
[ Q] 終了 変更は破棄します
入力:
よろしければEnter
StartUP-Manager が、そのうちGRUB 2 に対応すると思いますが、なかなか対応しませんねぇ。
それまでの代用になれば嬉しいのですが、誰かの目に止まることを期待しつつ、使用方法を。
任意の名前でスクリプトを保存。ホームフォルダに「menu-adjust」で保存したとします。
管理者権限が必要なので端末から
$ sudo ~/menu-sdlust
もしくは明確にパスを指定して
$ sudo /home/(ユーザー名)/menu-sdlust
GUI上では上部パネルで右クリックでランチャを生成して「コマンド欄に」上記のコマンドを記入。
メニュー画面の整理は旧GRUB の頃のメニューの設定と同様な事は出来ると思います(多分)
[参考URL]
https://forums.ubuntulinux.jp/viewtopic.php?id=6092
https://forums.ubuntulinux.jp/viewtopic.php?pid=52509#p52509
オフライン
#!/bin/bash
clear
declare af_defaultmenu
declare af_sec
declare af_option
declare af_defaultoption=1
declare af_single
declare af_os
declare af_memtest
declare af_newkernel
entry1='GRUB_DEFAULT='
entry2='GRUB_TIMEOUT='
entry3='GRUB_CMDLINE_LINUX='
entry4='GRUB_CMDLINE_LINUX_DEFAULT='
entry5='GRUB_DISABLE_LINUX_RECOVERY="true"'
entry6='GRUB_DISABLE_OS_PROBER=true'
if test -e /boot/grub/grub.cfg
then flgs01=0
else flgs01=1
fi
if test -e /usr/share/doc/grub-pc/examples/grub.cfg
then flgs02=2
else flgs02=4
fi
resize -s 30 80
sel=0
reset
#------------------------------------------------------------------------------------
# Title
#------------------------------------------------------------------------------------
TITLE () {
echo -e ' ***************************************************'
echo -e "`tput bold` GRUB 2 Adjust of menu `tput sgr0` "
echo -e ' ***************************************************'
return 0
}
#-------------------------------------------------------------------------------------
flgs=$((${flgs02} + ${flgs01}))
case "${flgs}" in
4)
TITLE
echo -e '\tGRUB2 がインストールされていません\n\tPlease input the command. grub-install [Device file]\n
\n\t[終了]Please any key'
read a
exit ;;
5)
TITLE
echo -e '\tGRUB2 がインストールされていません\n\tPlease input the command. apt-get install grub2\n
\n\t[終了]Please any key'
read a
exit ;;
3)
TITLE
echo -e '\t/boot/grub/grub.cfg を確認して下さい\n\tこのシステムはGRUBを採用していません\n
\n\t[終了]Please any key'
read a
exit ;;
esac
#***************************************************************************************
line=$(cat /etc/default/grub|grep 'GRUB_DISABLE_OS_PROBER=')
if [ -z ${line} ]; then
echo '#GRUB_DISABLE_OS_PROBER=true' >> /etc/default/grub
fi
grub='/etc/default/grub'
#***************************************************************************************
#---------------------------------------------------------------------------------------
# MAIN_MENU
#---------------------------------------------------------------------------------------
MAIN_MENU() {
echo -e ' [ 0] プロファイルの表示と変更の摘要'
echo -e ' [ 1] デフォルトのメニューエントリーの選択'
echo -e ' [ 2] デフォルトのエントリーが起動されるまでの秒数'
echo -e ' [ 3] 起動オプションの追加'
echo -e ' [ 4] 起動オプション"quiet splash"の削除と変更'
echo -e ' [ 5] リカバリーモードの表示と非表示'
echo -e ' [ 6] OSの検出機能の"ON","OFF"'
echo -e ' [ 7] memtest86+ の表示と非表示'
echo -e ' [ 8] 最新のバージョンのみ表示'
echo -e '\n [ Q] 終了 変更は破棄します\n'
echo -e '入力: \nよろしければEnter'
tput cuf1;tput cuu1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
key=(0 1 2 3 4 5 6 7 8 q Q)
for ((i=0; i < ${#key[*]}; i ++))
do
if [ "$a" = ${key[$i]} ]; then
flg=$a
break
else
flg='false'
fi
done
return 0
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 1]デフォルトエントリー
#----------------------------------------------------------------------------------------
ENTRY_1() {
while :
do
echo -e '[登録されているエントリー]\n'
count=$(cat /boot/grub/grub.cfg|grep menuentry|wc -l)
cat /boot/grub/grub.cfg|grep 'menuentry'|cut -f 2 -d \"|cat -b
echo -e "\nデフォルトで起動するエントリーを「1-${count}」から選んでください"
echo -e "入力: \nよろしければEnter(m:M でメインメニューへ) "
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "1" ]&&[ "$a" -le "${count}" ]; then
af_defaultmenu="$a"
clear
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
reset
done
return 0
}
#***************************************************************************************
#---------------------------------------------------------------------------------------
# [ 2]秒数
#---------------------------------------------------------------------------------------
ENTRY_2() {
tmp=$(cat $grub|grep 'GRUB_TIMEOUT='|sed 's/\"//g')
sec=$(echo $tmp|sed 's/GRUB_TIMEOUT=//')
while :
do
echo -e "起動までのメニュー表示時間\n"
echo -e "[現在の設定:${sec}秒]\n"
echo -e '入力: 秒[-1秒~90秒] \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge -1 ]&&[ "$a" -le 90 ]; then
af_sec=$a
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 3]起動オプションの追加
#----------------------------------------------------------------------------------------
ENTRY_3() {
tmp=$(cat $grub|grep 'GRUB_CMDLINE_LINUX='|sed 's/\"//g')
opt=$(echo $tmp|sed 's/GRUB_CMDLINE_LINUX=//')
while :
do
echo -e "[デフォルト以外の起動オプションの変更]\n"
if [ ${opt} ]; then
echo -e "[現在のオプション:${opt}]\n"
else
echo -e "[現在指定されているオプションは有りません]\n"
fi
echo -e ""
echo -e "[複数指定の場合、オプションとオプションの間は半角スペースを]\n"
echo -e "[Option]:${opt} "
echo -e '\n\tよろしければEnterでメニュー画面に戻ります'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
tput cuf1;tput cuf1;tput cuu1;tput cuf1
read a
af_option=$a
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 4]デフォルトのオプション
#----------------------------------------------------------------------------------------
ENTRY_4() {
tmp=$(cat $grub|grep 'GRUB_CMDLINE_LINUX_DEFAULT='|sed 's/\"//g')
dfopt=$(echo $tmp|sed 's/GRUB_CMDLINE_LINUX_DEFAULT=//')
while :
do
echo -e "[デフォルトのオプションは quiet splash の変更]\n"
if [ "$dfopt" ]; then
echo -e "[現在の状況:${dfopt} が指定されています ]"
else
echo -e "[現在指定されているオプションは有りません]"
fi
echo -e "[\"quiet\" \"splash\"は問題がある場合のみ変更してください]\n"
echo -e " [0] quiet splash"
echo -e " [1] quiet "
echo -e " [2] splash"
echo -e " [3] オプション無し"
echo -e '\n[0~3]を選択して下さい、よろしければEnterでメニュー画面に戻ります'
echo -e '入力: \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "0" ]&&[ "$a" -le "3" ]; then
if [ "$a" = "0" ]; then
af_defaultoption='quiet splash'
elif [ "$a" = "1" ]; then
af_defaultoption='quiet'
elif [ "$a" = "2" ]; then
af_defaultoption='splash'
else
af_defaultoption=''
fi
echo ${af_defaultoption}
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 5]リカバリーモードの表示と非表示
#----------------------------------------------------------------------------------------
ENTRY_5() {
echo -e "[リカバリーモードの表示 or 非表示]\n\n"
echo -e " [0] リカバリーモードの表示\n"
echo -e " [1] リカバリーモードの非表示\n\n"
while :
do
echo -e '入力: \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "0" ]&&[ "$a" -le "1" ]; then
if [ "$a" = "0" ]; then
comment='on'
af_single='表示'
elif [ "$a" = "1" ]; then
af_single='非表示'
comment='off'
fi
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 6]OSの検出のON、OFF
#----------------------------------------------------------------------------------------
ENTRY_6() {
echo -e "[他パーティションのオペレーションシステムの検知]\n\n"
echo -e " [0] OSの検知 ON\n"
echo -e " [1] OSの検知 OFF\n\n"
while :
do
echo -e '入力: \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "0" ]&&[ "$a" -le "1" ]; then
if [ "$a" = "0" ]; then
comment='on'
af_os='表示'
elif [ "$a" = "1" ]; then
af_os='非表示'
comment='off'
fi
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 7]memtest86+ の表示と非表示
#----------------------------------------------------------------------------------------
ENTRY_7() {
echo -e "[memtest86+ の表示と非表示]\n"
echo -e " [0] memtest86+ の表示\n"
echo -e " [1] memtest86+ の非表示\n\n"
while :
do
echo -e '入力: \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "0" ]&&[ "$a" -le "1" ]; then
if [ "$a" = "0" ]; then
comment='on'
af_memtest='表示'
elif [ "$a" = "1" ]; then
af_memtest='非表示'
comment='off'
fi
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#****************************************************************************************
#----------------------------------------------------------------------------------------
# [ 8]古いカーネルの表示
#----------------------------------------------------------------------------------------
ENTRY_8(){
echo -e "[古いカーネルの表示と非表示]\n"
echo -e " [0] 最新のカーネルのみ表示\n"
echo -e " [1] 全てのカーネルを表示\n\n"
while :
do
echo -e '入力: \nよろしければEnter(m:M でメインメニューへ)\t\t'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" -ge "0" ]&&[ "$a" -le "1" ]; then
if [ "$a" = "0" ]; then
comment='on'
af_newkernel='最新を表示'
elif [ "$a" = "1" ]; then
af_newkernel='全て表示'
comment='off'
fi
echo '変更を受け付けました、メインメニューに戻ります '
sleep 2
reset
TITLE
MAIN_MENU
break
elif
[ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
fi
clear
tput cuu1;tput cuu1
return 0
done
}
#***************************************************************************************
#---------------------------------------------------------------------------------------
# [ 0]プロファイル
#---------------------------------------------------------------------------------------
PROFILE_0() {
kernel=$(uname -r)
defaultmenu=$(($(cat $grub|grep $entry1|cut -f 2 -d '=') + 1 ))
sec=$(cat $grub|grep $entry2|cut -f 2 -d '='|sed 's/\"//g')
option=$(cat $grub|grep $entry3|cut -f 2 -d '='|sed 's/\"//g')
defaultoption=$(cat $grub|grep $entry4|cut -f 2 -d '='|sed 's/\"//g')
chsingle=$(cat $grub|grep $entry5|cut -b 1)
chos=$(cat $grub|grep $entry6|cut -b 1)
chmemtest=$(ls -l /etc/grub.d/20_memtest86+|cut -b 4)
chnewkernel=$(cat /etc/grub.d/10_linux|grep while|cut -b 1)
#----------------------------------------------------------------------------------------
if [ "$chsingle" = '#' ];then
single='表示'
else
single='非表示'
fi
if [ "$chos" = '#' ]; then
os='表示'
else
os='非表示'
fi
if [ "$chmemtest" = 'x' ]; then
memtest='表示'
else
memtest='非表示'
fi
if [ "$chnewkernel" = '#' ]; then
newkernel='最新を表示'
else
newkernel='全て表示'
fi
#--------------------------------------------------------
if [ $sel = "0" ]; then
af_defaultmenu=$defaultmenu
af_sec=$sec
af_option=$option
af_defaultoption=$defaultoption
af_single=$single
af_os=$os
af_memtest=$memtest
af_newkernel=$newkernel
fi
if [ -z "$af_defaultmenu" ]; then
$af_defaultmenu="0"
elif [ -z "$af_sec" ]; then
$af_sec= "0"
fi
sel=1
}
#----------------------------------------------------------------------------------------
PROFILE() {
reset
echo "----------------------------------------------------------------------------"
printf "\t%-80s\n" " 現在起動しているカーネル [${kernel}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " デフォルトのエントリー"
printf "%20s" ''
printf "%-20s" "現在の設定[${defaultmenu}]"
printf "\t%-20s\n" " 変更後[${af_defaultmenu}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " 起動するまでの時間(-1 でキー入力が有るまでメニューを表示します)"
printf "%20s" ''
printf "%20s" "現在の設定[${sec} 秒]"
printf "\t%-20s\n" " 変更後[${af_sec} 秒]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " 追加の起動オプション"
printf "%20s" ''
printf "%20s" "現在の設定[${option}]"
printf "\t%-20s\n" " 変更後[${af_option}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " デフォルトのオプション(quiet splashを外すと起動状況がテキスト流れます)"
printf "%20s" ''
printf "%20s" "現在の設定[${defaultoption}]"
printf "\t%-20s\n" " 変更後[${af_defaultoption}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " リカバリーモードの表示 "
printf "%20s" ''
printf "%20s" "現在の設定[${single}]"
printf "\t%-20s\n" " 変更後[${af_single}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " OSを検知して表示する(他パーティションにあるOS(Windows,Linux)の検知)"
printf "%20s" ''
printf "%20s" "現在の設定[${os}]"
printf "\t%-20s\n" " 変更後[${af_os}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " memtest86+の表示 "
printf "%20s" ''
printf "%20s" "現在の設定[${memtest}]"
printf "\t%-20s\n" " 変更後[${af_memtest}]"
echo "----------------------------------------------------------------------------"
printf "%-79s\n" " 最新のカーネルだけを表示"
printf "%20s" ''
printf "%20s" "現在の設定[${newkernel}]"
printf "\t%-20s\n" " 変更後[${af_newkernel}]"
echo "----------------------------------------------------------------------------"
while :
do
echo -e '入力: \nよろしければEnter(w:W で変更を適用します。 m:M でメインメニューへ)'
tput cuf1;tput cuu1;tput cuf1;tput cuu1;tput cuf1;tput cuf1;tput cuf1;tput cuf1
read a
if [ "$a" = 'm' ] || [ "$a" = 'M' ]; then
reset
TITLE
MAIN_MENU
break
#----------------------------------------------------------------------------------------
elif
[ "$a" = 'w' ] || [ "$a" = 'W' ]; then
#entry1
entrynum=$(($af_defaultmenu - 1))
cat $grub|sed "s/${entry1}$defaultmenu/${entry1}$entrynum/" -i $grub
#-----------------------------------------------------------------------------------------------
#entry2
cat $grub|sed "s/${entry2}\"$sec\"/${entry2}\"$af_sec\"/" -i $grub
#-----------------------------------------------------------------------------------------------
#entry3
cat $grub|sed "s/${entry3}\"$option\"/${entry3}\"$af_option\"/" -i $grub
#-----------------------------------------------------------------------------------------------
#entry4
cat $grub|sed "s/${entry4}\"$defaultoption\"/${entry4}\"$af_defaultoption\"/" -i $grub
#-----------------------------------------------------------------------------------------------
#entry5
if [ "$comment" = "on" ] && [ "$chsingle" != '#']; then
cat $grub|sed "s/${entry5}/\#${entry5}/" -i $grub
elif [ "$comment" = "off" ] && [ "$chsingle" = '#' ]; then
cat $grub|sed "s/\#${entry5}/${entry5}/" -i $grub
fi
#-----------------------------------------------------------------------------------------------
#entry6
if [ "$comment" = "on" ] && [ "$chos" != '#' ]; then
cat $grub|sed "s/${entry6}/\#${entry6}/" -i $grub
elif [ "$comment" = "off" ] && [ "$chos" = '#' ]; then
cat $grub|sed "s/\#${entry6}/${entry6}/" -i $grub
fi
#-----------------------------------------------------------------------------------------------
#entry7
if [ "$comment" = "on" ] && [ "$chmemtest" != 'x' ]; then
chmod +x /etc/grub.d/20_memtest86+
elif [ "$comment" = "off" ] && [ "$chmemtest" = 'x' ]; then
chmod -x /etc/grub.d/20_memtest86+
fi
#-----------------------------------------------------------------------------------------------
#entry8
if [ "$comment" = "on" ] && [ "$chnewkernel" != '#' ]; then
check=$(cat -n /etc/grub.d/10_linux|grep 'while \[ \"x$list\" != \"x\" \] ; do')
num=$(echo $check|cut -f 1 -d " " )
if [ -n "$check" ]; then
cat /etc/grub.d/10_linux|sed "${num}s/^/#/" -i /etc/grub.d/10_linux
u=0
fi
checks=$(cat /etc/grub.d/10_linux|tail -n 1|cut -f 2 )
if [ "$u" = "0" ] && [ $checks = 'done' ]; then
check=$(cat -n /etc/grub.d/10_linux|tail -n 1)
num=$(echo $check|cut -f 1 -d " " )
cat /etc/grub.d/10_linux|sed "${num}s/^/#/" -i /etc/grub.d/10_linux
unset u
fi
elif [ "$comment" = "off" ] && [ "$chnewkernel" = '#' ]; then
check=$(cat -n /etc/grub.d/10_linux|grep 'while \[ \"x$list\" != \"x\" \] ; do')
num=$(echo $check|cut -f 1 -d " " )
if [ -n "$check" ]; then
cat /etc/grub.d/10_linux|sed "${num}s/^#//" -i /etc/grub.d/10_linux
checks=$(cat /etc/grub.d/10_linux|tail -n 1|cut -f 2 )
check=$(cat -n /etc/grub.d/10_linux|tail -n 1)
num=$(echo $check|cut -f 1 -d " " )
cat /etc/grub.d/10_linux|sed "${num}s/^#//" -i /etc/grub.d/10_linux
fi
fi
#-----------------------------------------------------------------------------------------------
clear
TITLE
update-grub && echo '変更されました、メインメニューに戻ります'
sleep 2
reset
TITLE
MAIN_MENU
break
fi
tput cuu1
done
return 0
}
#***************************************************************************************
# main
#***************************************************************************************
#---------------------------------------------------------------------------------------
PROFILE_0
TITLE
MAIN_MENU
while :
do
if [ "$flg" = 'false' ]; then
clear
echo '??再入力'
sleep 1
reset
TITLE
MAIN_MENU
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "0" ]; then
reset
PROFILE_0
PROFILE
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "1" ]; then
sel=1
reset
ENTRY_1
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "2" ]; then
sel=1
reset
ENTRY_2
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "3" ]; then
sel=1
reset
ENTRY_3
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "4" ]; then
sel=1
reset
ENTRY_4
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "5" ]; then
sel=1
reset
ENTRY_5
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "6" ]; then
sel=1
reset
ENTRY_6
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "7" ]; then
sel=1
reset
ENTRY_7
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = "8" ]; then
sel=1
reset
ENTRY_8
fi
#---------------------------------------------------------------------------------------
if [ "$flg" = 'q' ] || [ "$flg" = 'Q' ]; then
exit
fi
done
オフライン
※規約違反により追放されたユーザの投稿は、ログインユーザにのみ表示されます。
オフライン
kiyopさん、コメントありがとうございます。
内容については整理していないし、思いつきの付け足し、変更だらけでボロボロです。
必要の無い宣言や重複のコードとか、、、
まー整理した所で、悲しいかな私の文書力と同じ程度のものなので意味はないかなorz
恥ずかしいので、その辺はピックアップしないでスルーして下さい。
何かご指摘の箇所が有れば今後の自分の糧にしたいと思いますので宜しくお願いします。
オフライン
※規約違反により追放されたユーザの投稿は、ログインユーザにのみ表示されます。
オフライン