[UPDATE] - base function check
This commit is contained in:
parent
98b48eac23
commit
ed23d23c48
5
Apply/server/1/1.1.1.1.0/run.sh
Normal file
5
Apply/server/1/1.1.1.1.0/run.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## 1.1.1.1 Ensure cramfs kernel module is not available (Automated)
|
||||||
|
|
||||||
|
echo '/bin/true' > /etc/modprobe.d/cramfs.conf
|
||||||
1
Apply/workstation/1/1.1.1.1.0
Symbolic link
1
Apply/workstation/1/1.1.1.1.0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../server/1/1.1.1.1.0/
|
||||||
7
Check/server/1/1.1.1.1.0/run.sh
Normal file
7
Check/server/1/1.1.1.1.0/run.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## 1.1.1.1 Ensure cramfs kernel module is not available (Automated)
|
||||||
|
|
||||||
|
[[ ! -f /etc/modprobe.d/cramfs.conf ]] && ((CptErr++))
|
||||||
|
[[ -z $(cat /etc/modprobe.d/cramfs.conf|grep '/bin/true') ]] && ((CptErr++))
|
||||||
|
Check ${CptErr}
|
||||||
1
Check/workstation/1/1.1.1.1.0
Symbolic link
1
Check/workstation/1/1.1.1.1.0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../server/1/1.1.1.1.0
|
||||||
6
pem-cyber-linux.d/config
Normal file
6
pem-cyber-linux.d/config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DirFct=$(realpath $(dirname $0))/$(echo $(basename $0)| sed 's/.sh/.d/g')/
|
||||||
|
DirCheck=$(realpath $(dirname $0))/Check
|
||||||
|
DirApply=$(realpath $(dirname $0))/Apply
|
||||||
|
Debug='-x'
|
||||||
|
LogDir=/var/log/$(echo $(basename $0) |sed 's/.sh//g')/$(date +%H%m%d%H%M%S)/
|
||||||
57
pem-cyber-linux.d/function
Normal file
57
pem-cyber-linux.d/function
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
function Usage(){
|
||||||
|
echo "$(basename $0) [-c/-a] -l [1/2]"
|
||||||
|
echo "-c : Check the system"
|
||||||
|
echo "-a : Apply cyber"
|
||||||
|
echo "-l : Level (1 or 2)"
|
||||||
|
echo "-t : Type (desktop/server)"
|
||||||
|
|
||||||
|
[[ ! -z $1 ]] && echo "ERROR [$1] $2"
|
||||||
|
exit $1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function LogTest() {
|
||||||
|
# LogTest ${Res} ${Action} ${TEST}
|
||||||
|
if [[ ${1} -ne 0 ]]
|
||||||
|
then
|
||||||
|
echo -e "\n### ${2} - [RESULT] - ${3} : FAILED"
|
||||||
|
else
|
||||||
|
echo -e "\n### ${2} - [RESULT] - ${3} : SUCESS"
|
||||||
|
fi | tee -a ${LogDir}/${3}.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetArg(){
|
||||||
|
OPTSTRING="hcal:t:"
|
||||||
|
while getopts ${OPTSTRING} opt; do
|
||||||
|
case ${opt} in
|
||||||
|
a) Action=Apply;;
|
||||||
|
c) Action=Check;;
|
||||||
|
l) Level=${OPTARG};;
|
||||||
|
t) Type=${OPTARG};;
|
||||||
|
h) Usage;;
|
||||||
|
?) echo "Invalid option: -${OPTARG}."; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function CheckArg(){
|
||||||
|
|
||||||
|
[[ -z ${Level} ]] && Usage 2 ": No Level selected"
|
||||||
|
[[ -z ${Action} ]] && Usage 1 ": No action selected"
|
||||||
|
[[ -z ${Type} ]] && Usage 3 ": No Type selected"
|
||||||
|
[[ ${Level} -gt 2 ]] && Usage 4 ": Level need to be 1 or 2"
|
||||||
|
true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function GetRoot() {
|
||||||
|
|
||||||
|
if [[ $(id -u) -ne 0 ]]
|
||||||
|
then
|
||||||
|
Usage 5 ": You need to be root"
|
||||||
|
fi
|
||||||
|
}
|
||||||
0
pem-cyber-linux.d/function_Apply
Normal file
0
pem-cyber-linux.d/function_Apply
Normal file
9
pem-cyber-linux.d/function_Check
Normal file
9
pem-cyber-linux.d/function_Check
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
function Check(){
|
||||||
|
CheckRes=0
|
||||||
|
if [[ $1 -ne 0 ]]
|
||||||
|
then
|
||||||
|
CheckRes=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
export -f Check
|
||||||
43
pem-cyber-linux.sh
Executable file
43
pem-cyber-linux.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
## source de la configuration
|
||||||
|
|
||||||
|
source $(realpath $(dirname $0))/$(echo $(basename $0)| sed 's/.sh/.d/g')/config
|
||||||
|
|
||||||
|
## source des functions de base
|
||||||
|
|
||||||
|
source ${DirFct}/function
|
||||||
|
|
||||||
|
|
||||||
|
GetRoot
|
||||||
|
OPTSTRING="hcal:t:"
|
||||||
|
while getopts ${OPTSTRING} opt; do
|
||||||
|
case ${opt} in
|
||||||
|
a) Action=Apply;;
|
||||||
|
c) Action=Check;;
|
||||||
|
l) Level=${OPTARG};;
|
||||||
|
t) Type=${OPTARG};;
|
||||||
|
h) Usage;;
|
||||||
|
?) echo "Invalid option: -${OPTARG}."; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
CheckArg
|
||||||
|
|
||||||
|
|
||||||
|
source ${DirFct}/function_${Action}
|
||||||
|
|
||||||
|
[[ $Level -eq 2 ]] && RealLevel=\* || RealLevel=1
|
||||||
|
DirAction=$(realpath $(dirname $0))/${Action}/${Type}/${RealLevel}
|
||||||
|
|
||||||
|
[[ ! -d ${LogDir} ]] && mkdir -p ${LogDir} || true
|
||||||
|
|
||||||
|
for File in $(find ${DirAction} -type f -name run.sh| sort -n)
|
||||||
|
do
|
||||||
|
cd $(dirname ${File})
|
||||||
|
Test=$(basename $(dirname ${File}))
|
||||||
|
export CptErr=0
|
||||||
|
bash ${Debug} ./run.sh &> ${LogDir}/${Test}.log
|
||||||
|
LogTest ${?} ${Action} ${Test}
|
||||||
|
done
|
||||||
Loading…
x
Reference in New Issue
Block a user