From d142dcb18015c94e796797bcde14070a5ee1a9c8 Mon Sep 17 00:00:00 2001 From: hazcod Date: Fri, 19 Mar 2021 07:57:28 +0100 Subject: [PATCH 1/2] feat: add list cronjobs --- maclaunch.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/maclaunch.sh b/maclaunch.sh index 72e29bd..0eaca8f 100755 --- a/maclaunch.sh +++ b/maclaunch.sh @@ -55,6 +55,30 @@ function getKernelExtensions { kmutil showloaded --no-kernel-components --list-only --sort --show loaded 2>/dev/null | tr -s ' ' | grep -v 'com\.apple\.' } +function getCronjobs { + crontab -l 2>/dev/null | cut -d ' ' -f 6 +} + +function listCronJobs { + local filter="$1" + + getCronjobs | while IFS= read -r extLine; do + + if [ -n "$filter" ] && ! [[ "$extName" =~ $filter ]]; then + continue + fi + + extName="${extLine}" + loaded="${ORANGE}enabled${NC}" + + echo -e "${BOLD}> ${extName}${NC}" + echo -e " Type : cronjob" + echo -e " User : $(whoami)" + echo -e " Launch: ${loaded}" + echo " File : n/a" + done +} + function listKernelExtensions { local filter="$1" @@ -445,6 +469,8 @@ case "$1" in usage fi fi + + listCronJobs listLaunchItems "$1" "$2" listKernelExtensions "$2" listSystemExtensions "$2" @@ -454,6 +480,7 @@ case "$1" in if [ $# -ne 2 ]; then usage fi + disableLaunchItems "$2" disableKernelExtensions "$2" disableSystemExtensions "$2" @@ -463,6 +490,7 @@ case "$1" in if [ $# -ne 2 ]; then usage fi + enableLaunchItems "$2" enableKernelExtensions "$2" enableSystemExtensions "$2" From 1685a14dd3f7e8a1b7a4571269c815f8d010d2e1 Mon Sep 17 00:00:00 2001 From: hazcod Date: Fri, 19 Mar 2021 08:02:44 +0100 Subject: [PATCH 2/2] chore: fix shellcheck suggestions --- maclaunch.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/maclaunch.sh b/maclaunch.sh index 0eaca8f..c21a68c 100755 --- a/maclaunch.sh +++ b/maclaunch.sh @@ -62,19 +62,16 @@ function getCronjobs { function listCronJobs { local filter="$1" - getCronjobs | while IFS= read -r extLine; do + getCronjobs | while IFS= read -r name; do - if [ -n "$filter" ] && ! [[ "$extName" =~ $filter ]]; then + if [ -n "$filter" ] && ! [[ "$name" =~ $filter ]]; then continue fi - extName="${extLine}" - loaded="${ORANGE}enabled${NC}" - - echo -e "${BOLD}> ${extName}${NC}" + echo -e "${BOLD}> ${name}${NC}" echo -e " Type : cronjob" echo -e " User : $(whoami)" - echo -e " Launch: ${loaded}" + echo -e " Launch: ${ORANGE}enabled${NC}" echo " File : n/a" done } @@ -470,7 +467,7 @@ case "$1" in fi fi - listCronJobs + listCronJobs "$2" listLaunchItems "$1" "$2" listKernelExtensions "$2" listSystemExtensions "$2"