Skip to content

Commit

Permalink
scripts/bindhosts: add crond killer on disable_cron
Browse files Browse the repository at this point in the history
this way we can prevent multiple crond running
and we clean only our own crond
  • Loading branch information
backslashxx committed Dec 16, 2024
1 parent c66d241 commit 777afe5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions module/bindhosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ enable_cron() {
}

disable_cron() {
# kill busybox crond that we enabled
# super leet gamma knife
for i in $(pidof busybox); do
grep -q "bindhosts" /proc/$i/cmdline > /dev/null 2>&1 && {
echo "[x] killing pid $i"
kill -9 $i
}
done
# clean entry
if grep -q "bindhosts.sh" $PERSISTENT_DIR/crontabs/root > /dev/null 2>&1; then
echo "[>] $(head -n1 $PERSISTENT_DIR/crontabs/root) "
# todo: find a way to kill busybox crond
# with just toybox ps
rm -rf $PERSISTENT_DIR/crontabs
echo "[x] crontab entry removed!"
else
Expand Down

0 comments on commit 777afe5

Please sign in to comment.