Browse Source

introduce a first directory structure for organizing the files

master
Georg Hopp 12 years ago
parent
commit
f54c398c18
  1. 23
      classes.sh
  2. 5
      gatherer/cpu_information.sh
  3. 4
      gatherer/dist_information.sh
  4. 4
      gatherer/host_information.sh
  5. 9
      gatherer/interface_information.sh
  6. 17
      gatherer/system_information.sh
  7. 0
      notes/cf-engine-classes.txt
  8. 6
      run.sh
  9. 17
      system_information.sh
  10. 12
      utils/classes.sh
  11. 31
      utils/file.sh
  12. 4
      utils/network_tools.sh
  13. 25
      utils/programs.sh

23
classes.sh

@ -1,23 +0,0 @@
#!/bin/dash
##
# This creates function that will gather some system informations
# and propagate them as environment variables.
#
. ./utils.sh
include_once system_information.sh
include_once interface_information.sh
has_class() {
if [ 1 -ne $# ]
then
logger -p syslog.err 'has_class: no class given'
exit 1
fi
local CHECK=" ${CLASSES}"
test "${CHECK}" != "${CHECK% ${1} *}"
}
# vim: set ts=4 sw=4:

5
cpu_information.sh → gatherer/cpu_information.sh

@ -1,8 +1,3 @@
#!/bin/dash
. ./utils.sh
include_once classes.sh
gather_cpu_info() { gather_cpu_info() {
[ -z "${NCPUS}" ] || return [ -z "${NCPUS}" ] || return

4
dist_information.sh → gatherer/dist_information.sh

@ -1,7 +1,3 @@
#!/bin/dash
. ./utils.sh
## ##
# if we are on a linux try to figure out wich distribution we are # if we are on a linux try to figure out wich distribution we are
# running. # running.

4
host_information.sh → gatherer/host_information.sh

@ -1,7 +1,3 @@
#!/bin/dash
. ./utils.sh
## ##
# start guessing the system type via uname and export it. # start guessing the system type via uname and export it.
# #

9
interface_information.sh → gatherer/interface_information.sh

@ -1,12 +1,3 @@
#!/bin/dash
##
# This creates function that will gather some system informations
# and propagate them as environment variables.
#
. ./utils.sh
## ##
# retrieve interfaces. I prefer using ip if it is # retrieve interfaces. I prefer using ip if it is
# available, else I fallback to ifconfig... don't know # available, else I fallback to ifconfig... don't know

17
gatherer/system_information.sh

@ -0,0 +1,17 @@
. utils/file.sh
include_once utils/programs.sh
include_once utils/classes.sh
include_once gatherer/host_information.sh
include_once gatherer/dist_information.sh
include_once gatherer/cpu_information.sh
include_once gatherer/interface_information.sh
gather_information() {
gather_host_info
gather_dist_info
gather_cpu_info
gather_interface_info
}
# vim: set ts=4 sw=4:

0
cf-engine-classes.txt → notes/cf-engine-classes.txt

6
run.sh

@ -9,10 +9,10 @@
# flavours and maybe FreeBSD. # flavours and maybe FreeBSD.
# #
. ./utils.sh
. utils/file.sh
include_once system_information.sh
include_once network_tools.sh
include_once gatherer/system_information.sh
include_once utils/network_tools.sh
gather_information gather_information

17
system_information.sh

@ -1,17 +0,0 @@
#!/bin/dash
. ./utils.sh
include_once host_information.sh
include_once dist_information.sh
include_once cpu_information.sh
include_once interface_information.sh
gather_information() {
gather_host_info
gather_dist_info
gather_cpu_info
gather_interface_info
}
# vim: set ts=4 sw=4:

12
utils/classes.sh

@ -0,0 +1,12 @@
has_class() {
if [ 1 -ne $# ]
then
logger -p syslog.err 'has_class: no class given'
exit 1
fi
local CHECK=" ${CLASSES}"
test "${CHECK}" != "${CHECK% ${1} *}"
}
# vim: set ts=4 sw=4:

31
utils.sh → utils/file.sh

@ -1,9 +1,8 @@
#!/bin/dash
## ##
# make definitions only when not already defined
# some functions for file handling...this includes a kind of
# include_once for shell scripts. This one also includes the
# utils/program.sh file as it is needed in all scripts.
# #
command -v filename2symbol >/dev/null command -v filename2symbol >/dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
@ -77,29 +76,7 @@ then
fi fi
} }
##
# get and export the locations of used programs and export them
# I assume that on every UNIX/shell variant at least [ is globally
# available. I will use it throughout all other scripts without
# checking for existence.
# I also assume through all scripts that eval is available.
#
[ -z "${WHICH}" ] && WHICH="/usr/bin/which"
[ -z "${UNAME}" ] && UNAME="$(${WHICH} uname)"
[ -z "${GREP}" ] && GREP="$(${WHICH} grep)"
[ -z "${AWK}" ] && AWK="$(${WHICH} awk)"
[ -z "${SED}" ] && SED="$(${WHICH} sed)"
[ -z "${ECHO}" ] && ECHO="$(${WHICH} echo)"
[ -z "${SORT}" ] && SORT="$(${WHICH} sort)"
[ -z "${TR}" ] && TR="$(${WHICH} tr)"
[ -z "${PRINTF}" ] && PRINTF="$(${WHICH} printf)"
[ -z "${LOGGER}" ] && LOGGER="$(${WHICH} logger)"
[ -z "${NPROC}" ] && NPROC="$(${WHICH} nproc)"
[ -z "${LSCPU}" ] && LSCPU="$(${WHICH} lscpu)"
[ -z "${IP}" ] && IP="$(${WHICH} ip)"
[ -z "${IFCONFIG}" ] && IFCONFIG="$(${WHICH} ifconfig)"
export WHICH UNAME GREP AWK SED ECHO SORT TR PRINTF LOGGER NPROC LSCPU IP IFCONFIG
include_once utils/programs.sh
fi fi
# vim: set ts=4 sw=4: # vim: set ts=4 sw=4:

4
network_tools.sh → utils/network_tools.sh

@ -1,6 +1,4 @@
#!/bin/dash
. ./utils.sh
. utils/file.sh
## ##
# Function calculates number of bit in a netmask # Function calculates number of bit in a netmask

25
utils/programs.sh

@ -0,0 +1,25 @@
##
# get and export the locations of used programs and export them
# I assume that on every UNIX/shell variant at least [ is globally
# available. I will use it throughout all other scripts without
# checking for existence.
# I also assume through all scripts that eval is available.
#
[ -z "${WHICH}" ] && WHICH="/usr/bin/which"
[ -z "${UNAME}" ] && UNAME="$(${WHICH} uname)"
[ -z "${GREP}" ] && GREP="$(${WHICH} grep)"
[ -z "${AWK}" ] && AWK="$(${WHICH} awk)"
[ -z "${SED}" ] && SED="$(${WHICH} sed)"
[ -z "${ECHO}" ] && ECHO="$(${WHICH} echo)"
[ -z "${SORT}" ] && SORT="$(${WHICH} sort)"
[ -z "${TR}" ] && TR="$(${WHICH} tr)"
[ -z "${PRINTF}" ] && PRINTF="$(${WHICH} printf)"
[ -z "${LOGGER}" ] && LOGGER="$(${WHICH} logger)"
[ -z "${NPROC}" ] && NPROC="$(${WHICH} nproc)"
[ -z "${LSCPU}" ] && LSCPU="$(${WHICH} lscpu)"
[ -z "${IP}" ] && IP="$(${WHICH} ip)"
[ -z "${IFCONFIG}" ] && IFCONFIG="$(${WHICH} ifconfig)"
export WHICH UNAME GREP AWK SED ECHO SORT TR PRINTF LOGGER NPROC LSCPU IP IFCONFIG
# vim: set ts=4 sw=4:
Loading…
Cancel
Save