Skip to content

Commit c18c6b4

Browse files
committed
feat #46: add self update option
1 parent bb7ca7d commit c18c6b4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Arguments:
4848
is supplied it will search for that
4949
-u [VERSION] Uninstall the specified kernel version. If version is omitted,
5050
a list of max 10 installed kernel versions is displayed
51+
--update Update this script by redownloading it from github
5152
-h Show this message
5253
5354
Optional:

ubuntu-mainline-kernel.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sign_kernel=0
1212
mokKey="/var/lib/shim-signed/mok/MOK-Kernel.priv"
1313
mokCert="/var/lib/shim-signed/mok/MOK-Kernel.pem"
1414

15+
self_update_url="https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh"
16+
1517
# If quiet=1 then no log messages are printed (except errors)
1618
quiet=0
1719

@@ -241,6 +243,9 @@ while (( "$#" )); do
241243
debug_target="/dev/stderr"
242244
quiet=0
243245
;;
246+
--update)
247+
run_action="update"
248+
;;
244249
-h|--help)
245250
run_action="help"
246251
;;
@@ -463,6 +468,7 @@ Arguments:
463468
is supplied it will search for that
464469
-u [VERSION] Uninstall the specified kernel version. If version is omitted,
465470
a list of max 10 installed kernel versions is displayed
471+
--update Update this script by redownloading it from github
466472
-h Show this message
467473
468474
Optional:
@@ -482,7 +488,21 @@ Optional:
482488
"
483489
exit 2
484490
;;
491+
update)
492+
check_environment
493+
494+
self="$(readlink -f "$0")"
495+
$wget -q -O "$self.tmp" "$self_update_url"
485496

497+
if [ ! -s "$self.tmp" ]; then
498+
rm "$self.tmp"
499+
err "Update failed, downloaded file is empty"
500+
exit 1
501+
else
502+
mv "$self.tmp" "$self"
503+
echo "Script updated"
504+
fi
505+
;;
486506
check)
487507
check_environment
488508

0 commit comments

Comments
 (0)