-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathlynis-devkit
executable file
·159 lines (131 loc) · 4.27 KB
/
lynis-devkit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
set -o nounset
CONFIG_FILE="config"
MODE="do-nothing"
MY_USER_ID=$(id -u)
VERBOSE=0
DEVKIT_RELEASE="20201005"
DEVKIT_VERSION="1.0.6"
# Lynis variables
SHOW_WARNINGS_ONLY=0
LOGTEXT=1
QUIET=0
CRONJOB=0
ECHOCMD="echo"
YELLOW=""
NORMAL=""
SECTION="${YELLOW}"
LOGFILE="./lynis-dev.log"
DISPLAY_LANG="$LANG"
if [ "${MY_USER_ID}" = "0" ]; then echo "Do not run this as root"; exit 1; fi
if [ ! -f "${CONFIG_FILE}" ]; then echo "Could not open config file: ${CONFIG_FILE}"; exit 1; fi
CHECK_VERBOSE=$(awk -F= '/^verbose=/ { print $2 }' ${CONFIG_FILE} | egrep -i "yes") && VERBOSE=1
LYNIS_PATH=$(awk -F= '/^lynis-directory=/ { print $2 }' ${CONFIG_FILE})
if [ "${LYNIS_PATH}" = "" -o ! -d "${LYNIS_PATH}" ]; then echo "Could not find the Lynis directory"; exit 1; fi
if [ ! -f ${LYNIS_PATH}/lynis ]; then echo "Could not find Lynis (tried: ${LYNIS_PATH}/lynis)"; exit 1; fi
LYNIS_VERSION=$(grep "PROGRAM_VERSION=" ${LYNIS_PATH}/lynis | awk -F= '{print $2}' | sed 's/"//g')
echo "======================================================================"
echo "Development kit: ${DEVKIT_VERSION} [${DEVKIT_RELEASE}]"
echo "Lynis directory: ${LYNIS_PATH}"
echo "Lynis version: ${LYNIS_VERSION}"
echo "Verbose: $VERBOSE"
echo "======================================================================"
FUNCTIONS_FILE="${LYNIS_PATH}/include/functions"
if [ -f "${FUNCTIONS_FILE}" ]; then
. ${FUNCTIONS_FILE}
fi
FUNCTIONS_FILE="./include/devkit-functions"
if [ -f "${FUNCTIONS_FILE}" ]; then
. ${FUNCTIONS_FILE}
fi
INCLUDE_FILES="./include/parameters "
for FILE in ${INCLUDE_FILES}; do
if [ -f ${FILE} ]; then
echo "Including ${FILE}"
. ${FILE}
else
echo "Fatal: could not find ${FILE}"
exit 1
fi
done
case ${MODE} in
"build-all")
SDKBuildPackageDEB
SDKBuildPackageRPM
;;
"build-deb" | "build-dpkg")
SDKBuildPackageDEB
;;
"build-rpm")
SDKBuildPackageRPM
;;
"do-nothing")
echo ""; echo ""
echo "Help"
echo "============================="
echo ""
echo "Build Packages"
echo " $0 build deb"
echo " $0 build rpm"
echo ""
echo "Languages"
echo " $0 update language-files"
echo ""
echo "Quality Testing"
echo " $0 run checks"
echo " $0 run linters"
echo " $0 run spelling-check"
echo " $0 run unit-tests"
echo ""; echo ""
;;
"run-checks")
FILES=$(find ./checks -name "check-*" -type f -print)
for FILE in ${FILES}; do
. ${FILE}
Assert
if [ $? -gt 0 ]; then
echo "[X] One or more checks failed"
exit 1
fi
done
;;
"run-linters")
echo "Running linters"
if [ -d ./linters ]; then
FILES=$(find ./linters -type f -name "linter-*")
for FILE in ${FILES}; do
InsertSection "Linter - ${FILE}"
. ${FILE}
done
fi
;;
"run-spelling-check")
. ./grammar/grammar-check-spelling
;;
"run-unit-tests")
FILES=$(find ./unit-tests -name "tests-*" -type f -print)
for FILE in ${FILES}; do
. ${FILE}
Assert
if [ $? -gt 0 ]; then
echo "[X] One or more unit test failed"
exit 1
fi
done
;;
"update-language-files")
FILES=$(find ./languages -name "languages-*" -type f -print)
for FILE in ${FILES}; do
. ${FILE}
UpdateLanguageFiles
done
;;
esac
printf "\n"
Display --text "End of Program" --result "OK"
#Tests using the double-bracket test operator, e.g. [[ "${SOMEVAR}" == "test value" ]]
#Arrays, e.g. foo=( 1 2 3 )
#The declare built-in command
#Using the function keyword to define a shell function (you should never use this though, even with bash)
#Brace expansion, e.g. echo {a,b}{c,d}
# EOF