From 3277d71fa0bc2791f4ea93d18e9df7b0fe242c33 Mon Sep 17 00:00:00 2001 From: axtloss Date: Thu, 11 Jan 2024 22:56:06 +0100 Subject: [PATCH 1/2] feat: add warning when fsguard fails --- includes.container/fsguard_config.patch | 12 ---------- includes.container/usr/sbin/init | 32 +++++++++++++++++++++++++ modules/03-fswarn.yml | 9 +++++++ recipe.yml | 1 + 4 files changed, 42 insertions(+), 12 deletions(-) delete mode 100644 includes.container/fsguard_config.patch mode change 100644 => 100755 includes.container/usr/sbin/init create mode 100644 modules/03-fswarn.yml diff --git a/includes.container/fsguard_config.patch b/includes.container/fsguard_config.patch deleted file mode 100644 index b03e142..0000000 --- a/includes.container/fsguard_config.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/config/config.go b/config/config.go -index 35291d7..1dda59d 100644 ---- a/config/config.go -+++ b/config/config.go -@@ -1,6 +1,6 @@ - package config - --var FileListPath = "/FsGuard/filelist" -+var FileListPath = "/.system/FsGuard/filelist" - var InitLocation = "/usr/bin/init" - var PostInitExec = "/usr/lib/systemd/systemd" - var RunPostInit = true diff --git a/includes.container/usr/sbin/init b/includes.container/usr/sbin/init old mode 100644 new mode 100755 index b191d6c..84b4acc --- a/includes.container/usr/sbin/init +++ b/includes.container/usr/sbin/init @@ -1,3 +1,35 @@ #!/bin/bash + +function failed() { + #tput civis + squashfs="/.system/boot/fswarn.squash" + tmp="$(mktemp -d)" + chmod 0755 "$tmp" + mount -t squashfs -o loop $squashfs $tmp 2> /dev/null > /dev/null + mount --rbind /dev $tmp/dev 2> /dev/null > /dev/null + + resolution=$(chroot "$tmp" /bin/bash -c '/usr/sbin/fbset | /bin/grep "mode " | /bin/sed "s/\"//g" | /bin/sed "s/-0//g" | /usr/bin/gawk '\''BEGIN{FS=" "}; {print $2}'\''') + chroot $tmp /bin/bash -c "convert -resize $resolution -background black -gravity center -extent $resolution /verification_failed.png bgra:/dev/fb0" + tput civis + read -sn1 input + if [[ "$input" == "c" ]]; then + tput cnorm + chroot $tmp /bin/bash -c "convert -resize $resolution -background black -gravity center -extent $resolution /continue_confirm.png bgra:/dev/fb0" + tput civis + read -sn1 input + if [[ "$input" == "y" ]]; then + return + else + poweroff -f + fi + else + poweroff -f + fi + tput cnorm +} + /usr/sbin/FsGuard verify /.system/FsGuard/filelist +if [[ $? -ne 0 ]]; then + failed +fi exec /usr/lib/systemd/systemd "$@" diff --git a/modules/03-fswarn.yml b/modules/03-fswarn.yml new file mode 100644 index 0000000..35b9727 --- /dev/null +++ b/modules/03-fswarn.yml @@ -0,0 +1,9 @@ +name: fswarn +type: shell +commands: + - mkdir -p /boot/ + - cp /sources/fswarn-x86_64.squash /boot/fswarn.squash +source: + type: tar + url: https://github.com/Vanilla-OS/fswarn/releases/download/v1.0-1/fswarn.tar.xz + checksum: 52f66710132138c21b81b56cb2d6edc7e59ad6eef4a4065b81af0f852d827dab diff --git a/recipe.yml b/recipe.yml index 08d7c06..4aff825 100644 --- a/recipe.yml +++ b/recipe.yml @@ -44,6 +44,7 @@ modules: - modules/00-vanilla-apx-gui - modules/00-vanilla-sideload - modules/02-waydroid-modules + - modules/03-fswarn - modules/10-vanilla-abroot-rollback-notifier - modules/20-gnome-core - modules/30-gnome-essentials From a80b68daa5777681eb7d970c2843782a439e091b Mon Sep 17 00:00:00 2001 From: axtloss Date: Thu, 11 Jan 2024 23:08:54 +0100 Subject: [PATCH 2/2] chore: remove commented line --- includes.container/usr/sbin/init | 1 - 1 file changed, 1 deletion(-) diff --git a/includes.container/usr/sbin/init b/includes.container/usr/sbin/init index 84b4acc..14fb19e 100755 --- a/includes.container/usr/sbin/init +++ b/includes.container/usr/sbin/init @@ -1,7 +1,6 @@ #!/bin/bash function failed() { - #tput civis squashfs="/.system/boot/fswarn.squash" tmp="$(mktemp -d)" chmod 0755 "$tmp"