File tree Expand file tree Collapse file tree 2 files changed +68
-4
lines changed
Expand file tree Collapse file tree 2 files changed +68
-4
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ Re-generate your initramfs
43431 . Install initramfs scripts.
4444
4545 ``` shell
46- sudo ./initramfs/ubuntu/setup
46+ sudo ./initramfs/ubuntu/setup install
4747 ```
48482 . Re-generate initramfs.
4949
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+ log () {
3+ local CODE=$?
4+ echo >&2 " $* "
5+ return $CODE
6+ }
7+ print-help () {
8+ log " \
9+ usage: ${0##*/ } [-h] [--] (install|uninstall)
10+ Install initramfs scripts for Ubuntu.
211
3- SCRIPT_DIR=" $( cd -P -- " $( dirname -- " $BASH_SOURCE " ) " && pwd) "
4- install {" $SCRIPT_DIR " ,/etc/initramfs-tools}/hooks/grub-btrfs-overlay
5- install {" $SCRIPT_DIR " ,/etc/initramfs-tools}/scripts/local-bottom/grub-btrfs-overlay
12+ # Options
13+ -h display this help & exit
14+
15+ # Subcommands
16+ install install initramfs scripts
17+ uninstall remove initramfs scripts"
18+ }
19+ usage-error () {
20+ print-help
21+ exit 2
22+ }
23+ action-install () {
24+ local SCRIPT_DIR=" $( cd -P -- " $( dirname -- " $BASH_SOURCE " ) " && pwd) "
25+ install {" $SCRIPT_DIR " ,/etc/initramfs-tools}/hooks/grub-btrfs-overlay
26+ install {" $SCRIPT_DIR " ,/etc/initramfs-tools}/scripts/local-bottom/grub-btrfs-overlay
27+ }
28+ action-uninstall () {
29+ rm -f /etc/initramfs-tools/{hooks,scripts/local-bottom}/grub-btrfs-overlay
30+ }
31+ set -e
32+ while getopts h OPT
33+ do case " $OPT " in
34+ h)
35+ print-help
36+ exit
37+ ;;
38+ * )
39+ usage-error
40+ esac done
41+ shift $(( OPTIND - 1 ))
42+ OPTIND=1
43+ ACTION=
44+ case " $# " in
45+ 0)
46+ log event: a subcommand is required
47+ usage-error
48+ ;;
49+ 1)
50+ case " $1 " in
51+ install|uninstall)
52+ ACTION=" action-$1 "
53+ ;;
54+ * )
55+ log " \
56+ event: unknown subcommand
57+ subcommand: $1 "
58+ usage-error
59+ esac
60+ ;;
61+ * )
62+ log " \
63+ event: too many arguments
64+ arguments: $* "
65+ usage-error
66+ esac
67+ " $ACTION " || log " \
68+ event: execution failure
69+ suggestion: rerun with sudo"
You can’t perform that action at this time.
0 commit comments