#!/bin/bash #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//dos_/THIS!0.!c # #/*************************************************************************** # dos_ THIS # +++++++++ # # purpose : dos_-functions # # begin : Mon Dec 03 10:00:00 CEST 2007 # # changes : * Sat Aug 24 19:18:47 CEST 2013 Thomas Bruecker # : # added new functions: "dos_()", "dos_-v()", # "dos_isExecutable()", "dos_isOs()", # "dos_isOsConditionOP()", # "dos_isOsConditionOPE()"; # Version 0.1.0 . # # copyright : (C) 2007 by Thomas Bruecker # # email : public0x05bf@bluewin.ch # # version : 0.1.0 # #***************************************************************************/ #/*************************************************************************** # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU General Public License as published by * # * the Free Software Foundation; either version 2 of the License, or * # * (at your option) any later version. * # * * # * This program is distributed in the hope that it will be useful, but * # * WITHOUT ANY WARRANTY; without even the implied warranty of * # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * # * General Public License for more details. * # * * # * You should have received a copy of the GNU General Public License * # * along with this program; if not, write to the Free Software * # * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * # * * # ***************************************************************************/ # MyHash("linux//dos_/THIS") = 0x091C # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. Copyright0x091C="Copyright (C) 2007 by Thomas Bruecker," Copyright0x091C="$Copyright0x091C " SCRIPTS=root/bin ThisPath0x091C="/${SCRIPTS}/dos_/THIS" Title0x091C="dos_-functions" Version0x091C="Version 0.1.0" . /$SCRIPTS/dos_/GLOBALS . /$SCRIPTS/string_/THIS dos_() { # prints information to stdout. local Information # introduction: Information="\nTo learn more about \"$ThisPath0x091C\", read the following" Information="${Information} contents of that\nfile:\n\n" # + file contents: Information="${Information}Contents of \"$ThisPath0x091C\":\n\n" Information="${Information}$(cat $ThisPath0x091C)" echo -e "$Information" | less } dos_-v() { # prints version-information to stdout. echo "$Title0x091C, $Version0x091C" echo $Copyright0x091C } dos_isExecutable() { # $1 : maybe-name of executable to check; # * returns true (0) and prints the full path of the executable denoted by # "maybe-name of executable", if this executable exists somewhere in the # system. local qExecutableName Result ResultString # ?ExecutableName: # maybe-executable-name. qExecutableName="$1" ResultString="$(/usr/bin/which "$qExecutableName" 2>/dev/null)" Result=$? # do not print errors. echo "$ResultString" return $Result } dos_isOs() { # $1: maybe-os-name to check; # * returns true (0), if "maybe-os-name to check" corresponds to the current # OS-name. local OsName qOsName # ?OsName: maybe-os-name. qOsName="$(string_2Uppercase "$1")" # canonicalize qOsName. # the linux case: if uname -o | grep -iq linux; then # check result of "grep". OsName="LINUX" fi # else [ "$OsName" == "$qOsName" ] || return $IncorrectOs0x09E8 # return result of the first } # command (0) or return # . dos_isOsConditionOP() { # "OP": OS, package. # $1: maybe-os-name to check; # $2: maybe-package-name to check; # * returns true (0), if # * "maybe-name" corresponds to the current OS-name and # * the package denoted by "maybe-package-name" exists. local qOsName qPackageName RpmPath # * ?OsName: maybe-os-name, # * ?PackageName: # maybe-package-name. qOsName="$1" qPackageName="$2" dos_isOs "$qOsName" || return # continue or return result # else # of the first command. # works only with linux at the moment: if ! uname -o | grep -iq linux; then # check result of "grep"; return 255 # don't know how to search fi # for packages in a non- # else # linux OS ! # to get a result, we need the executable "rpm": RpmPath="$(dos_rpm_isTheExecutable)" || return 254 # else # check for the package # manager "rpm"; don't know # how to search for packages # without "rpm"! -- if not # found, return 254 . # check for package via direct rpm-query: $RpmPath -q "$qPackageName" >/dev/null 2>/dev/null \ || return $IncorrectPackage0x09E8 # do not print errors, # return result of the first } # command (0) or return # . dos_isOsConditionOPE() { # "OPE": OS, package, # executable. # $1: maybe-os-name to check; # $2: maybe-package-name to check; # $3: maybe-executable-name to check; # * returns true (0), if # * "maybe-name" corresponds to the current OS-name, # * the package denoted by "maybe-package-name" exists # * and the executable denoted by "maybe-executable-name" # exists in that package. local PackageName qExecutableName qOsName qPackageName RequiredPackageName # * ?ExecutableName: # maybe-executable-name, # * ?OsName: maybe-os-name, # * ?PackageName: # maybe-package-name. qExecutableName="$3" qOsName="$1" qPackageName="$2" dos_isOsConditionOP "$qOsName" "$qPackageName" || return # return if the package-name # else # has not been found. # here, the existence of "$qPackageName" is asserted, so we set: RequiredPackageName="$qPackageName" # check for the executable in any package: PackageName="$(dos_rpm_Executable2PackageName "$qExecutableName")" \ || return $IncorrectExecutable0x09E8 [ "$RequiredPackageName" == "$PackageName" ] return # return result of above } # command. #^ dos_isOsConditionOPF() { # "OPF": OS, package, file. # $1: maybe-os-name to check; # $2: maybe-package-name to check; # $3: maybe-file-name to check; dos_SECURITY() { local Command0x0XXX . /$SCRIPTS/dos_/security/THIS Command0x0XXX=dos_security_$1 shift 1 $Command0x0XXX "$@" return # return result of previous # command. } dos_TestKill() { kill -$2 $1 } dos_TestTraps() # signal #1 --> login-shell is killed. # signal #2 : . --> login-shell is not killed. # signal #3 : . --> login-shell is not killed. # signal #4 --> login-shell is killed. # signal #9 is not trappable ! --> login-shell is killed. # signal #16: stack faults ! # signal #17 is not trapped ! --> login-shell is not killed. # signal #19 is not trappable ! --> login-shell is neither killed nor stopped. # signal #20 : . --> login-shell is neither killed nor stopped. { for I in \ 1 2 3 4 \ 5 6 7 8 \ 9 10 11 12 \ 13 14 15 17 \ 18 19 20 21 \ 22 23 24 25 \ 26 27 28 29 \ 30 31 32 33 34 \ 35 36 37 38 \ 39 40 41 42 \ 43 44 45 46 \ 47 48 49 50 \ 51 52 53 54 \ 55 56 57 58 \ 59 60 61 62 \ 63 do trap "echo -e '\nkilled by $I' > /dev/tty1" $I done trap while : do : done }