ALT Linux Bugzilla
– Attachment 8007 Details for
Bug 36048
Добавить в пакет скрипт grub-entries
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
Варинт скрипта с опциями и проверкой
grub-entries (text/plain), 3.06 KB, created by
Leonid Krivoshein
on 2019-02-08 16:41:13 MSK
(
hide
)
Description:
Варинт скрипта с опциями и проверкой
Filename:
MIME Type:
Creator:
Leonid Krivoshein
Created:
2019-02-08 16:41:13 MSK
Size:
3.06 KB
patch
obsolete
>#!/bin/sh -efu >### This file is covered by the GNU General Public License >### version 2 or later. >### >### Copyright (C) 2019 ALT Linux Team >### Author: Leonid Krivoshein <klark@altlinux.org> > >numbers_only=0 >titles_only=0 >search_item= >progname="${0##*/}" >grubmenu="/boot/grub/grub.cfg" > > >show_help() { > cat <<-EOF >$progname - Show default or specified grub menu. > >Usage: $progname [options] > >Options: > -f, --config= Specify path to the grub config. > -n, --numbers Show only numbers of the items. > -t, --titles Show only titles of the items. > -c, --check= Specify item name to validate. > -V, --version Show script version and exit. > -h, --help Show this help message and exit. >EOF > exit 0 >} > >show_version() { > cat <<-EOF >$progname version 0.9 >Copyright (C) 2019, ALT Linux Team >EOF > exit 0 >} > >show_usage() { > [ -z "$*" ] || echo "$*" >&2 > echo "Try '$progname --help' for more information." >&2 > exit 1 >} > >parse_args() { > local opts="+f:,n,t,c:,V,h" > local longopts="config:,numbers,titles,check:,version,help" > > opts=$(getopt -n "$progname" -o "$opts" -l "$longopts" -- "$@") || > show_usage "Invalid command-line arguments." > eval set -- "$opts" > while [ $# -gt 0 ]; do > case "$1" in > -f|--config) shift; grubmenu="$1";; > -n|--numbers) numbers_only=1; titles_only=0;; > -t|--titles) numbers_only=0; titles_only=1;; > -c|--check) shift; search_item="$1";; > -V|--version) show_version;; > -h|--help) show_help;; > --) shift; break;; > -*) show_usage "Unrecognized option: '$1'";; > *) break;; > esac > shift > done > [ $# -eq 0 ] || show_usage "To many arguments: '$*'" >} > >show_menu() { > local mode title number prefix entry=0 itemno=0 > > cat "$grubmenu" | sed \ > -re '/^\s*(menuentry\s+|submenu\s+|})/!d' \ > -re "s/^\s*menuentry\s+'([^']+)'.*\$/M\t\1/g" \ > -re 's/^\s*menuentry\s+"([^"]+)".*$/M\t\1/g' \ > -re "s/^\s*submenu\s+'([^']+)'.*\$/S\t\1/g" \ > -re 's/^\s*submenu\s+"([^"]+)".*$/S\t\1/g' \ > -re "s/^\s*}\s*\$/E\t-/g" | > while read mode title; do > case "$mode" in > M) if [ $numbers_only -ne 0 ]; then > echo -e "${number}${itemno}" > elif [ $titles_only -ne 0 ]; then > echo -e "${prefix}${title}" > else > echo -e "${number}${itemno}\t${prefix}${title}" > fi > itemno=$(($itemno + 1)) > entry=1 > ;; > S) number="${number}${itemno}>" > prefix="${prefix}${title}>" > itemno=0 > ;; > *) if [ $entry -ne 0 ]; then > entry=0 > elif [ -n "$number" ]; then > number="${number%>}" > prefix="${prefix%>}" > case "$number" in > *">"*) itemno="${number##*>}" > number="${number%>*}>" > prefix="${prefix%>*}>" > itemno=$(($itemno + 1)) > ;; > *) itemno=$number > itemno=$(($itemno + 1)) > prefix= > number= > ;; > esac > fi > ;; > esac > done >} > >check_item() { > case "$search_item" in > [0-9]*) numbers_only=1; titles_only=0;; > *) numbers_only=0; titles_only=1;; > esac > local cnt=$(show_menu | grep -swc "$search_item") > if [ $cnt -eq 0 ]; then > echo "$search_item: menu item not found." >&2 > exit 1 > fi > exit 0 >} > > >parse_args "$@" >[ -r "$grubmenu" ] || show_usage "$grubmenu: config file not found." >[ -z "$search_item" ] || check_item >show_menu >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 36048
:
7989
|
7990
|
7996
|
7998
|
7999
|
8000
|
8001
|
8002
|
8003
|
8004
| 8007 |
8008
|
8009