From 181a6424796b1cafc87a8d74aad197135381a389 Mon Sep 17 00:00:00 2001 From: Patrick Schleizer Date: Sun, 22 Oct 2023 10:01:38 -0400 Subject: [PATCH] root check --- usr/bin/remount-secure | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/usr/bin/remount-secure b/usr/bin/remount-secure index bf3c105..0279e18 100755 --- a/usr/bin/remount-secure +++ b/usr/bin/remount-secure @@ -13,17 +13,22 @@ set -e set -o pipefail set -o nounset -if test -o xtrace ; then - output_command=true -else - output_command=echo -fi +init() { + if test -o xtrace ; then + output_command=true + else + output_command=echo + fi -mkdir --parents "/run/remount-secure" + if [ "$(id -u)" != "0" ]; then + $output_command "ERROR: must be run as root! sudo $0" + exit 1 + fi -exit_code=0 - -mount_output="$(mount)" + mkdir --parents "/run/remount-secure" + exit_code=0 + mount_output="$(mount)" +} parse_options() { ## Thanks to: @@ -138,6 +143,7 @@ end() { } main() { + init "$@" parse_options "$@" _home "$@" _run "$@"