[UPDATE] - base function check
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user