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 gather_cpu_info() { 1 gather_cpu_info() {
7 [ -z "${NCPUS}" ] || return 2 [ -z "${NCPUS}" ] || return
8 3
1 -#!/bin/dash  
2 -  
3 -. ./utils.sh  
4 -  
5 ## 1 ##
6 # if we are on a linux try to figure out wich distribution we are 2 # if we are on a linux try to figure out wich distribution we are
7 # running. 3 # running.
1 -#!/bin/dash  
2 -  
3 -. ./utils.sh  
4 -  
5 ## 1 ##
6 # start guessing the system type via uname and export it. 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 # retrieve interfaces. I prefer using ip if it is 2 # retrieve interfaces. I prefer using ip if it is
12 # available, else I fallback to ifconfig... don't know 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 gather_information() { 10 gather_information() {
11 gather_host_info 11 gather_host_info
@@ -9,10 +9,10 @@ @@ -9,10 +9,10 @@
9 # flavours and maybe FreeBSD. 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 gather_information 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 has_class() { 1 has_class() {
13 if [ 1 -ne $# ] 2 if [ 1 -ne $# ]
14 then 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 command -v filename2symbol >/dev/null 6 command -v filename2symbol >/dev/null
8 if [ $? -ne 0 ] 7 if [ $? -ne 0 ]
9 then 8 then
@@ -77,29 +76,7 @@ then @@ -77,29 +76,7 @@ then
77 fi 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 fi 80 fi
104 81
105 # vim: set ts=4 sw=4: 82 # vim: set ts=4 sw=4:
1 -#!/bin/dash  
2 -  
3 -. ./utils.sh 1 +. utils/file.sh
4 2
5 ## 3 ##
6 # Function calculates number of bit in a netmask 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