From fe038e66197671e7ba00f71998bf2d8d7793d36d Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 5 Nov 2017 16:20:51 -0500 Subject: [PATCH] nice mod for sudo in snarf linux config also prints out the command to use if they forgot to sudo. --- scripts/archival/snarf_linux_config.pl | 7 +++++++ scripts/core/functions.sh | 20 -------------------- scripts/core/variables.sh | 11 +++++------ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/scripts/archival/snarf_linux_config.pl b/scripts/archival/snarf_linux_config.pl index 0fe2eaca..1c7ad042 100644 --- a/scripts/archival/snarf_linux_config.pl +++ b/scripts/archival/snarf_linux_config.pl @@ -19,6 +19,13 @@ require "shared_snarfer.pl"; use Env qw(HOME); +# make sure we are running as root. otherwise we have no access to look at many things in /etc. +if ($< != 0) { + printf "This script must be run as root or sudo. Try this:\n"; + printf " sudo -E PERLLIB=\$PERLLIB perl $0 @ARGV\n"; + exit 1; +} + &initialize_snarfer; # get the number we use and increment it for the next use. diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 6c8bc68a..97516a69 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -645,26 +645,6 @@ alias "${@}" return 0 } - # defines a variable within the feisty meow environment and remembers that - # this is a new or modified definition. if the feisty meow codebase is - # unloaded, then so are all the variables that were defined. - # this function always exports the variables it defines. -# function define_yeti_variable() -# { -## if variable exists already, save old value for restore, -## otherwise save null value for restore, -## have to handle unsetting if there was no prior value of one -## we newly defined. -## add variable name to a list of feisty defined variables. -# -##hmmm: first implem just sets it up and exports the variable. -## i.e., this method always exports. -#export "${@}" -# -# -#return 0 -# } - ############## #hmmm: this points to an extended functions file being needed; not all of these are core. diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index b5ea3456..cf25fa22 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -17,17 +17,16 @@ # this function always exports the variables it defines. function define_yeti_variable() { -# if variable exists already, save old value for restore, + #hmmm: simple implem just sets it up and exports the variable. + # i.e., this method always exports. + export "${@}" + +#hmmm: eventual approach-- if variable exists already, save old value for restore, # otherwise save null value for restore, # have to handle unsetting if there was no prior value of one # we newly defined. # add variable name to a list of feisty defined variables. -#hmmm: first implem just sets it up and exports the variable. -# i.e., this method always exports. -export "${@}" - - return 0 } -- 2.34.1