mirror of
https://github.com/m8tin/cis.git
synced 2025-12-06 15:58:26 +01:00
Revised and CIS introduced
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
# Note that an unprivileged user can use this script successfully,
|
||||
# if no user has to be added to the host because it already exists.
|
||||
function addToCrontabEveryHour() {
|
||||
local _ROOT _MINUTE_VALUE _STRING
|
||||
_ROOT="${0%%/core/*}/" #Removes longest matching pattern '/core/*' from the end
|
||||
local _CIS_ROOT _MINUTE_VALUE _STRING
|
||||
_CIS_ROOT="${0%%/core/*}/" #Removes longest matching pattern '/core/*' from the end
|
||||
! [ -z "${2##*[!0-9]*}" ] && _MINUTE_VALUE=$((${2}%60)) # if second parameter is integer then (minute-value % 60) as safe guard
|
||||
_STRING="${_MINUTE_VALUE:?"Missing MINUTE_VALUE"} * * * * ${1:?"Missing first parameter COMMAND"} > /dev/null 2>&1"
|
||||
readonly _ROOT _MINUTE_VALUE _STRING
|
||||
readonly _CIS_ROOT _MINUTE_VALUE _STRING
|
||||
|
||||
[ "$(id -u)" == "0" ] \
|
||||
&& crontab -l | grep -qF "${_STRING:?"Missing CRON_STRING"}" \
|
||||
@@ -21,11 +21,11 @@ function addToCrontabEveryHour() {
|
||||
&& return 0
|
||||
|
||||
[ "$(id -u)" == "0" ] \
|
||||
&& echo "${_ROOT:?"Missing ROOT"}" | grep "home" &> /dev/null \
|
||||
&& echo "${_CIS_ROOT:?"Missing CIS_ROOT"}" | grep "home" &> /dev/null \
|
||||
&& echo "SUCCESS: Although the entry will be skipped: ("$(readlink -f ${0})")" \
|
||||
&& echo " - '${_STRING}'" \
|
||||
&& echo " that is because the current environment is:" \
|
||||
&& echo " - ${_ROOT}" \
|
||||
&& echo " - ${_CIS_ROOT}" \
|
||||
&& return 0
|
||||
|
||||
[ "$(id -u)" == "0" ] \
|
||||
@@ -47,4 +47,6 @@ function addToCrontabEveryHour() {
|
||||
addToCrontabEveryHour \
|
||||
"$(echo ${1} | sed -E 's|[^a-zA-Z0-9/:@._-]*||g')" \
|
||||
"$(echo ${2} | sed -E 's|[^a-zA-Z0-9/:@._-]*||g')" \
|
||||
&& exit 0 || exit 1
|
||||
&& exit 0
|
||||
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user