From 9bf3ec989f14b632159a0632e1e360e9a997e60a Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 2 Oct 2018 21:01:12 -0500 Subject: [PATCH] . --- default.inc | 13 +++++++++++++ test.sh | 23 ++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100755 default.inc diff --git a/default.inc b/default.inc new file mode 100755 index 0000000..253645a --- /dev/null +++ b/default.inc @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +do_with_root() { + if [[ `whoami` = 'root' ]]; then + $* + elif [[ -x /bin/sudo || -x /usr/bin/sudo ]]; then + echo "sudo $*" + sudo $* + else + echo -e "${BOrange}Please run this script as root.${Color_Off}" + exit 1 + fi +} \ No newline at end of file diff --git a/test.sh b/test.sh index 754eddc..01616b0 100755 --- a/test.sh +++ b/test.sh @@ -1,10 +1,27 @@ #!/usr/bin/env bash -#curl -sL https://git.schroedercity.com/voltron/Misc-Scripts/raw/master/colors.inc | source - source /dev/stdin <<< "$(curl -sL http://scity.xyz/colorsinc)" +# Detect distribution name +if [[ `which lsb_release 2>/dev/null` ]]; then + # lsb_release available + distrib_name=`lsb_release -is` +else + # lsb_release not available + lsb_files=`find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null` + for file in $lsb_files; do + if [[ $file =~ /etc/(.*)[-_] ]]; then + distrib_name=${BASH_REMATCH[1]} + break + else + echo -e "${BOrange}Sorry, GlancesAutoInstall script is not compliant with your system.${Color_Off}" + echo -e "${BOrange}Please read: https://github.com/nicolargo/glances#installation${Color_Off}" + exit 1 + fi + done +fi + +echo -e "$${CS[color,LightGreen]}Detected system: $distrib_name${CS[color,Default]}" -echo -e "${CS[color,LightBlue]}Testing TESTING ${CS[style,Bold]}REALLY TESTING${CS[style,Reset]}${CS[color,Default]}" exit 0 \ No newline at end of file