From c041a073fe44baafa4ebcb516c7d377d52fff054 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 28 Jan 2013 10:29:42 -0500 Subject: [PATCH] fixed references to scripts directory and added linux package lister command. --- scripts/buildor/buildor_strip_code.sh | 2 +- scripts/core/functions.sh | 22 ++++++++++++++++------ scripts/core/variables.sh | 4 ++-- scripts/generator/whack_build.sh | 2 +- scripts/system/list_packages.sh | 24 ++++++++++++++++++++++++ scripts/system/write_uptime_report.sh | 2 +- 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 scripts/system/list_packages.sh diff --git a/scripts/buildor/buildor_strip_code.sh b/scripts/buildor/buildor_strip_code.sh index eb5c6d47..e82206e7 100644 --- a/scripts/buildor/buildor_strip_code.sh +++ b/scripts/buildor/buildor_strip_code.sh @@ -1,6 +1,6 @@ #!/bin/bash -source "$FEISTY_MEOW_DIR/scripts/build/seek_all_source.sh" +source "$FEISTY_MEOW_SCRIPTS/build/seek_all_source.sh" function strip_file { file="$1" diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 1cb2a2e4..aa9c512a 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -172,15 +172,25 @@ if [ -z "$skip_all" ]; then # we always remove dos slashes in favor of forward slashes. echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' } - - # su function: makes su perform a login. - # for some OSes, this transfers the X authority information to the new login. - function su() { + + # returns a successful value (0) if this system is debian or ubuntu. + function debian_like() { # decide if we think this is debian or ubuntu or a variant. DEBIAN_LIKE=$(if [ ! -z "$(grep -i debian /etc/issue)" \ -o ! -z "$(grep -i ubuntu /etc/issue)" ]; then echo 1; else echo 0; fi) - if [ $DEBIAN_LIKE -eq 1 ]; then + # success; this is debianish. + return 0 + else + # this seems like some other OS. + return 1 + fi + } + + # su function: makes su perform a login. + # for some OSes, this transfers the X authority information to the new login. + function su() { + if debian_like; then # debian currently requires the full version which imports X authority # information for su. @@ -230,7 +240,7 @@ if [ -z "$skip_all" ]; then if [ -z "$wheres_nechung" ]; then echo "The nechung oracle program cannot be found. You may want to consider" echo "rebuilding the feisty meow applications with this command:" - echo " bash $FEISTY_MEOW_DIR/scripts/generator/bootstrap_build.sh" + echo " bash $FEISTY_MEOW_SCRIPTS/generator/bootstrap_build.sh" else $wheres_nechung fi diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index 7c67e440..bb7878c9 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -63,7 +63,7 @@ if [ -z "$NECHUNG" ]; then if [ -z "$FEISTY_MEOW_DIR" ]; then if [ -d "$HOME/feisty_meow" ]; then export FEISTY_MEOW_DIR="$HOME/feisty_meow" - export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts" + export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_SCRIPTS" fi fi @@ -142,7 +142,7 @@ if [ -z "$NECHUNG" ]; then # we need to know the feisty meow directory, or we bail. if [ -z "$FEISTY_MEOW_DIR" ]; then return; fi # pick from our expected generator folder, but make sure it's there... - buildvars="$FEISTY_MEOW_DIR/scripts/generator/build_variables.sh" + buildvars="$FEISTY_MEOW_SCRIPTS/generator/build_variables.sh" if [ -f "$buildvars" ]; then # yep, that one looks good, so pull in the build defs. source "$buildvars" "$buildvars" diff --git a/scripts/generator/whack_build.sh b/scripts/generator/whack_build.sh index 0778fb6d..0647b0ab 100644 --- a/scripts/generator/whack_build.sh +++ b/scripts/generator/whack_build.sh @@ -49,7 +49,7 @@ function whack_single_build_area() if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN" ]; then echo $(date): " ** aggressive cleaning activated..." - perl "$FEISTY_MEOW_DIR/scripts/files/zapdirs.pl" "$FEISTY_MEOW_DIR" >>"$CRUDFILE" + perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" "$FEISTY_MEOW_DIR" >>"$CRUDFILE" fi echo $(date): "cleaned [$choprepo]." diff --git a/scripts/system/list_packages.sh b/scripts/system/list_packages.sh new file mode 100644 index 00000000..6b3222f1 --- /dev/null +++ b/scripts/system/list_packages.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" + +if debian_like; then + dpkg -la | grep $* + exit $? +fi + +rpm_available="$(which rpm)" +if [ ! -z "$rpm_available" ]; then +#is that the right phrase for rpm? somewhat forgotten. + rpm -qa | grep $* + exit $? +fi + +yum_available="$(which yum)" +if [ ! -z "$yum_available" ]; then + yum list | grep $* + exit $? +fi + +echo "Could not deduce what type of OS this is; missing package listing commands." +exit 1 diff --git a/scripts/system/write_uptime_report.sh b/scripts/system/write_uptime_report.sh index e5dfb355..e9627f5f 100644 --- a/scripts/system/write_uptime_report.sh +++ b/scripts/system/write_uptime_report.sh @@ -1,7 +1,7 @@ #!/bin/bash # writes an uptime report to a file in the home directory which is named # after the current machine's hostname. -source "$FEISTY_MEOW_DIR/scripts/core/functions.sh" +source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" export hosty=$(hostname | sed -e 's/^\([^.]*\).*$/\1/') export REPORT_FILE="$HOME/${hosty}_uptime.log" echo "$(date_stringer) -- $(uptime)" >>"$REPORT_FILE" 2>&1 -- 2.34.1