some changes

master
serr 2025-04-13 16:59:05 +03:00
parent dfdf3b0b35
commit 2d6f9a788f
1 changed files with 10 additions and 10 deletions

20
eye.sh
View File

@ -15,16 +15,16 @@ CLEANUP_DONE=0
# Вывод в синем цвете # Вывод в синем цвете
blue() { blue() {
echo -e "\033[34m$1\033[0m" echo -e "\033[34mEYE | $1\033[0m"
} }
# Очистка при завершении работы скрипта # Очистка при завершении работы скрипта
cleanup() { cleanup() {
[ $CLEANUP_DONE -eq 1 ] && exit 0 [ $CLEANUP_DONE -eq 1 ] && exit 0
blue "EYE | cleanup..." blue "cleanup..."
kill_proc $1 kill_proc $1
rm -f $BINARY_PATH rm -f $BINARY_PATH
blue "EYE | see you later!" blue "see you later!"
CLEANUP_DONE=1 CLEANUP_DONE=1
exit 0 exit 0
} }
@ -34,7 +34,7 @@ kill_proc() {
local pid=$1 local pid=$1
if [ -n "$pid" ] && kill -0 $pid 2>/dev/null; then if [ -n "$pid" ] && kill -0 $pid 2>/dev/null; then
kill $pid kill $pid
blue "EYE | process killed (PID: $pid)" blue "process killed (PID: $pid)"
fi fi
} }
@ -60,7 +60,7 @@ check_changes() {
changed=1 changed=1
LAST_MODS["$target"]=$current_mod LAST_MODS["$target"]=$current_mod
LAST_COUNTS["$target"]=$current_count LAST_COUNTS["$target"]=$current_count
[ -n "$1" ] && blue "EYE | changes detected in \033[94m$target\033[0m" [ -n "$1" ] && blue "changes detected in \033[94m$target\033[0m"
fi fi
done done
@ -83,23 +83,23 @@ main() {
LAST_MODS["$target"]=0 LAST_MODS["$target"]=0
LAST_COUNTS["$target"]=$(find "$target" -type f 2>/dev/null | wc -l) LAST_COUNTS["$target"]=$(find "$target" -type f 2>/dev/null | wc -l)
fi fi
blue "EYE | started watching \033[94m$target\033[0m" blue "started watching \033[94m$target\033[0m"
done done
# Основной цикл работы скрипта # Основной цикл работы скрипта
while true; do while true; do
check_changes $pid check_changes $pid
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
blue "EYE | rebuilding..." blue "rebuilding..."
$BUILD_CMD $BUILD_CMD
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
blue "EYE | build successful. restarting..." blue "build successful. restarting..."
kill_proc $pid kill_proc $pid
$BINARY_PATH & $BINARY_PATH &
pid=$! pid=$!
blue "EYE | started new process (PID: $pid)" blue "started new process (PID: $pid)"
else else
blue "EYE | build failed" blue "build failed"
fi fi
fi fi