wowzers
This commit is contained in:
parent
57323e8a56
commit
674e65f068
5
builder/builder.sh
Normal file
5
builder/builder.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=1
|
||||
|
||||
echo "KVS Builder $VERSION"
|
74
builder/menu/factory_install.sh
Executable file
74
builder/menu/factory_install.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# KVS: Kernel Version Switcher
|
||||
# Written by kxtzownsu / kxtz#8161
|
||||
# https://kxtz.dev
|
||||
# Licensed under GPLv3
|
||||
|
||||
version=1
|
||||
GITHUB_URL="https://github.com/kxtzownsu/KVS"
|
||||
|
||||
# give me thy kernver NOW
|
||||
case "$(crossystem tpm_kernver)" in
|
||||
"0x00000000")
|
||||
kernver="0"
|
||||
;;
|
||||
"0x00010001")
|
||||
kernver="1"
|
||||
;;
|
||||
"0x00010002")
|
||||
kernver="2"
|
||||
;;
|
||||
"0x00010003")
|
||||
kernver="3"
|
||||
;;
|
||||
*)
|
||||
panic "invalid-kernver"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
source functions.sh
|
||||
source tpmutil.sh
|
||||
|
||||
# detect if booted from usb boot or from recovery boot
|
||||
if [ "$(crossystem mainfw_type)" == "recovery" ]; then
|
||||
source tpmutil.sh
|
||||
mkdir /mnt/state &2> /dev/zero
|
||||
mount /dev/disk/by-label/KVS /mnt/state
|
||||
elif [ "$(crossystem mainfw_type)" == "developer" ]; then
|
||||
# echo "Please run this shim using the Recovery Boot method. (ESC+REFRESH+PWR)"
|
||||
echo ""
|
||||
clear
|
||||
fi
|
||||
|
||||
credits(){
|
||||
echo "KVS: Kernel Version Switcher"
|
||||
echo "V$version"
|
||||
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
|
||||
echo "kxtzownsu - Writing KVS, Providing kernver 0 & kernver 1 files."
|
||||
echo "??? - Providing kernver 2 files."
|
||||
echo "TBD - Providing kernver 3 files."
|
||||
echo "Google - Writing the `tpmc` command :3"
|
||||
}
|
||||
|
||||
endkvs(){
|
||||
# reboot now
|
||||
stopwatch
|
||||
}
|
||||
|
||||
|
||||
main(){
|
||||
echo "KVS: Kernel Version Switcher v$version"
|
||||
echo "Current kernver: $kernver"
|
||||
echo "=-=-=-=-=-=-=-=-=-=-"
|
||||
echo "1) Set New kernver"
|
||||
echo "2) Backup kernver (WIP, Kinda Broken)"
|
||||
echo "3) Credits"
|
||||
echo "4) Exit"
|
||||
read -rep "> " sel
|
||||
|
||||
selection $sel
|
||||
}
|
||||
|
||||
|
||||
panic mount-error
|
114
builder/menu/functions.sh
Executable file
114
builder/menu/functions.sh
Executable file
@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
style_text() {
|
||||
printf "\e[31m\033[1m\033[5m$1\e[0m\n"
|
||||
}
|
||||
|
||||
panic(){
|
||||
case "$1" in
|
||||
"invalid-kernver")
|
||||
style_text "KVS PANIC"
|
||||
printf "\e[31mERR\e[0m"
|
||||
printf ": Invalid Kernel Version. Please make a GitHub issue at \e[3;34m$GITHUB_URL\e[0m with a picture of this information.\n"
|
||||
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-="
|
||||
echo "tpm_kernver: $(crossystem tpm_kernver)"
|
||||
echo "fwid: $(crossystem ro_fwid)"
|
||||
echo "date: $(date)"
|
||||
echo "model: $(cat /sys/class/dmi/id/product_name) $(cat /sys/class/dmi/id/product_version)"
|
||||
echo "Please shutdown your device now using REFRESH+PWR"
|
||||
sleep infinity
|
||||
;;
|
||||
"mount-error")
|
||||
style_text "KVS PANIC"
|
||||
printf "\e[31mERR\e[0m"
|
||||
printf ": Unable to mount stateful. Please make a GitHub issue at \e[3;34m$GITHUB_URL\e[0m with a picture of this information.\n"
|
||||
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-="
|
||||
echo "tpm_kernver: $(crossystem tpm_kernver)"
|
||||
echo "fwid: $(crossystem ro_fwid)"
|
||||
echo "state mounted: $([ -d /mnt/state/ ] && grep -qs '/mnt/state ' /proc/mounts && echo true || echo false)"
|
||||
echo "date: $(date)"
|
||||
echo "model: $(cat /sys/class/dmi/id/product_name) $(cat /sys/class/dmi/id/product_version)"
|
||||
echo "Please shutdown your device now using REFRESH+PWR"
|
||||
sleep infinity
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
stopwatch() {
|
||||
display_timer() {
|
||||
printf "[%02d:%02d:%02d]\n" $hh $mm $ss
|
||||
}
|
||||
hh=0 #hours
|
||||
mm=0 #minutes
|
||||
ss=0 #seconds
|
||||
|
||||
while true; do
|
||||
clear
|
||||
echo "Initiated reboot, if this doesn't reboot please manually reboot with REFRESH+PWR"
|
||||
echo "Time since reboot initiated:"
|
||||
display_timer
|
||||
ss=$((ss + 1))
|
||||
# if seconds reach 60, increment the minutes
|
||||
if [ $ss -eq 60 ]; then
|
||||
ss=0
|
||||
mm=$((mm + 1))
|
||||
fi
|
||||
# if minutes reach 60, increment the hours
|
||||
if [ $mm -eq 60 ]; then
|
||||
mm=0
|
||||
hh=$((hh + 1))
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
selection(){
|
||||
case $1 in
|
||||
"1")
|
||||
echo "Please Enter Target kernver (0-3)"
|
||||
read -r kernver
|
||||
case $kernver in
|
||||
"0")
|
||||
echo "Setting kernver 0"
|
||||
;;
|
||||
"1")
|
||||
echo "Setting kernver 1"
|
||||
;;
|
||||
"2")
|
||||
echo "Setting kernver 2"
|
||||
;;
|
||||
"3")
|
||||
echo "Setting kernver 3"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid kernver. Please check your input."
|
||||
main
|
||||
;;
|
||||
esac ;;
|
||||
"2")
|
||||
if [ $currentkernver == "0x00000000" ]; then
|
||||
echo "Current kernver: 0"
|
||||
echo "Outputting to stateful/kernver-out"
|
||||
cp /mnt/state/versions/kernver0 /mnt/state/kernver-out
|
||||
elif [ $currentkernver == "0x00010001" ]; then
|
||||
echo "Current kernver: 1"
|
||||
echo "Outputting to stateful/kernver-out"
|
||||
cp /mnt/state/versions/kernver1 /mnt/state/kernver-out
|
||||
elif [ $currentkernver == "0x00010002" ]; then
|
||||
echo "Current kernver: 2"
|
||||
echo "Outputting to stateful/kernver-out"
|
||||
cp /mnt/state/versions/kernver2 /mnt/state/kernver-out
|
||||
elif [ $currentkernver == "0x00010003" ]; then
|
||||
echo "Current kernver: 3"
|
||||
echo "Outputting to stateful/kernver-out"
|
||||
cp /mnt/state/versions/kernver3 /mnt/state/kernver-out
|
||||
fi
|
||||
;;
|
||||
"3")
|
||||
credits
|
||||
;;
|
||||
"4")
|
||||
endkvs
|
||||
;;
|
||||
esac
|
||||
}
|
15
builder/menu/tpmutil.sh
Executable file
15
builder/menu/tpmutil.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
write_tpm(){
|
||||
local index=$1
|
||||
local data=$2
|
||||
|
||||
tpmc write "$index" "$data"
|
||||
}
|
||||
|
||||
read_tpm(){
|
||||
local index=$1
|
||||
local bytes=$2
|
||||
|
||||
tpmc read "$index" "$bytes"
|
||||
}
|
1
builder/menu/versions/kernver0
Normal file
1
builder/menu/versions/kernver0
Normal file
@ -0,0 +1 @@
|
||||
02 4c 57 52 47 0 0 0 0 0 0 0 e8
|
BIN
builder/menu/versions/kernver0.raw
Normal file
BIN
builder/menu/versions/kernver0.raw
Normal file
Binary file not shown.
1
builder/menu/versions/kernver1
Normal file
1
builder/menu/versions/kernver1
Normal file
@ -0,0 +1 @@
|
||||
02 4c 57 52 47 0 0 0 0 0 0 0 0
|
BIN
builder/menu/versions/kernver1.raw
Normal file
BIN
builder/menu/versions/kernver1.raw
Normal file
Binary file not shown.
1
builder/menu/versions/kernver2
Normal file
1
builder/menu/versions/kernver2
Normal file
@ -0,0 +1 @@
|
||||
02 4c 57 52 47 1 0 1 0 0 0 0 55
|
BIN
builder/menu/versions/kernver2.raw
Normal file
BIN
builder/menu/versions/kernver2.raw
Normal file
Binary file not shown.
1
builder/menu/versions/kernver3
Normal file
1
builder/menu/versions/kernver3
Normal file
@ -0,0 +1 @@
|
||||
02 4c 57 52 47 3 0 1 0 0 0 0 EC
|
BIN
builder/menu/versions/kernver3.raw
Normal file
BIN
builder/menu/versions/kernver3.raw
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user