Commit f54c398c1885e975b46a3e8a26e8f97d22ec2fd0

Authored by Georg Hopp
1 parent 492503ac

introduce a first directory structure for organizing the files

1   -#!/bin/dash
2   -
3   -. ./utils.sh
4   -include_once classes.sh
5   -
6 1 gather_cpu_info() {
7 2 [ -z "${NCPUS}" ] || return
8 3
... ...
1   -#!/bin/dash
2   -
3   -. ./utils.sh
4   -
5 1 ##
6 2 # if we are on a linux try to figure out wich distribution we are
7 3 # running.
... ...
1   -#!/bin/dash
2   -
3   -. ./utils.sh
4   -
5 1 ##
6 2 # start guessing the system type via uname and export it.
7 3 #
... ...
1   -#!/bin/dash
2   -
3   -##
4   -# This creates function that will gather some system informations
5   -# and propagate them as environment variables.
6   -#
7   -
8   -. ./utils.sh
9   -
10 1 ##
11 2 # retrieve interfaces. I prefer using ip if it is
12 3 # available, else I fallback to ifconfig... don't know
... ...
1   -#!/bin/dash
  1 +. utils/file.sh
2 2
3   -. ./utils.sh
4   -
5   -include_once host_information.sh
6   -include_once dist_information.sh
7   -include_once cpu_information.sh
8   -include_once interface_information.sh
  3 +include_once utils/programs.sh
  4 +include_once utils/classes.sh
  5 +include_once gatherer/host_information.sh
  6 +include_once gatherer/dist_information.sh
  7 +include_once gatherer/cpu_information.sh
  8 +include_once gatherer/interface_information.sh
9 9
10 10 gather_information() {
11 11 gather_host_info
... ...
... ... @@ -9,10 +9,10 @@
9 9 # flavours and maybe FreeBSD.
10 10 #
11 11
12   -. ./utils.sh
  12 +. utils/file.sh
13 13
14   -include_once system_information.sh
15   -include_once network_tools.sh
  14 +include_once gatherer/system_information.sh
  15 +include_once utils/network_tools.sh
16 16
17 17 gather_information
18 18
... ...
1   -#!/bin/dash
2   -
3   -##
4   -# This creates function that will gather some system informations
5   -# and propagate them as environment variables.
6   -#
7   -
8   -. ./utils.sh
9   -include_once system_information.sh
10   -include_once interface_information.sh
11   -
12 1 has_class() {
13 2 if [ 1 -ne $# ]
14 3 then
... ...
1   -#!/bin/dash
2   -
3 1 ##
4   -# make definitions only when not already defined
  2 +# some functions for file handling...this includes a kind of
  3 +# include_once for shell scripts. This one also includes the
  4 +# utils/program.sh file as it is needed in all scripts.
5 5 #
6   -
7 6 command -v filename2symbol >/dev/null
8 7 if [ $? -ne 0 ]
9 8 then
... ... @@ -77,29 +76,7 @@ then
77 76 fi
78 77 }
79 78
80   - ##
81   - # get and export the locations of used programs and export them
82   - # I assume that on every UNIX/shell variant at least [ is globally
83   - # available. I will use it throughout all other scripts without
84   - # checking for existence.
85   - # I also assume through all scripts that eval is available.
86   - #
87   - [ -z "${WHICH}" ] && WHICH="/usr/bin/which"
88   - [ -z "${UNAME}" ] && UNAME="$(${WHICH} uname)"
89   - [ -z "${GREP}" ] && GREP="$(${WHICH} grep)"
90   - [ -z "${AWK}" ] && AWK="$(${WHICH} awk)"
91   - [ -z "${SED}" ] && SED="$(${WHICH} sed)"
92   - [ -z "${ECHO}" ] && ECHO="$(${WHICH} echo)"
93   - [ -z "${SORT}" ] && SORT="$(${WHICH} sort)"
94   - [ -z "${TR}" ] && TR="$(${WHICH} tr)"
95   - [ -z "${PRINTF}" ] && PRINTF="$(${WHICH} printf)"
96   - [ -z "${LOGGER}" ] && LOGGER="$(${WHICH} logger)"
97   - [ -z "${NPROC}" ] && NPROC="$(${WHICH} nproc)"
98   - [ -z "${LSCPU}" ] && LSCPU="$(${WHICH} lscpu)"
99   - [ -z "${IP}" ] && IP="$(${WHICH} ip)"
100   - [ -z "${IFCONFIG}" ] && IFCONFIG="$(${WHICH} ifconfig)"
101   -
102   - export WHICH UNAME GREP AWK SED ECHO SORT TR PRINTF LOGGER NPROC LSCPU IP IFCONFIG
  79 + include_once utils/programs.sh
103 80 fi
104 81
105 82 # vim: set ts=4 sw=4:
... ...
1   -#!/bin/dash
2   -
3   -. ./utils.sh
  1 +. utils/file.sh
4 2
5 3 ##
6 4 # Function calculates number of bit in a netmask
... ...
  1 +##
  2 +# get and export the locations of used programs and export them
  3 +# I assume that on every UNIX/shell variant at least [ is globally
  4 +# available. I will use it throughout all other scripts without
  5 +# checking for existence.
  6 +# I also assume through all scripts that eval is available.
  7 +#
  8 +[ -z "${WHICH}" ] && WHICH="/usr/bin/which"
  9 +[ -z "${UNAME}" ] && UNAME="$(${WHICH} uname)"
  10 +[ -z "${GREP}" ] && GREP="$(${WHICH} grep)"
  11 +[ -z "${AWK}" ] && AWK="$(${WHICH} awk)"
  12 +[ -z "${SED}" ] && SED="$(${WHICH} sed)"
  13 +[ -z "${ECHO}" ] && ECHO="$(${WHICH} echo)"
  14 +[ -z "${SORT}" ] && SORT="$(${WHICH} sort)"
  15 +[ -z "${TR}" ] && TR="$(${WHICH} tr)"
  16 +[ -z "${PRINTF}" ] && PRINTF="$(${WHICH} printf)"
  17 +[ -z "${LOGGER}" ] && LOGGER="$(${WHICH} logger)"
  18 +[ -z "${NPROC}" ] && NPROC="$(${WHICH} nproc)"
  19 +[ -z "${LSCPU}" ] && LSCPU="$(${WHICH} lscpu)"
  20 +[ -z "${IP}" ] && IP="$(${WHICH} ip)"
  21 +[ -z "${IFCONFIG}" ] && IFCONFIG="$(${WHICH} ifconfig)"
  22 +
  23 +export WHICH UNAME GREP AWK SED ECHO SORT TR PRINTF LOGGER NPROC LSCPU IP IFCONFIG
  24 +
  25 +# vim: set ts=4 sw=4:
... ...
Please register or login to post a comment