Skip to content
Snippets Groups Projects
ncov-daemon.fish 769 B
Newer Older
Recolic Keghart's avatar
Recolic Keghart committed
#!/usr/bin/fish
## This daemon will be autostart-ed on gnome startup.
## It help you submit ncov in completely automatic way.

while true
    set fname /tmp/hust-ncov-mark-(env TZ=Asia/Shanghai date +%j)
    set fails 0
    if not test -f $fname
        echo 'CALL HUST-NCOV'
        timeout 3m /usr/mybin/hust_ncov_submit        
        and begin
            echo 1 > $fname
            echo 'SUCCESS'
            set fails 0
        end; or begin
            set fails (math 1+$fails)
            echo "fails=$fails"
            test $fails -ge 14
                and /usr/mybin/recolic_email_notify root@recolic.net "RECOLIC NCOV NOTIFY" "hust-ncov daily auto submit has been failing for $fails times. Please fix the script!"
        end
    end
    sleep 300
end