mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-29 02:36:26 +00:00
test if script/job exist and is executable, more cleanup on startup
This commit is contained in:
parent
9482bd62bf
commit
3c5ffdb506
@ -12,7 +12,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-pre-1-gb8ae9ec
|
#### $$VERSION$$ v0.80-pre-2-g9482bd6
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -364,8 +364,9 @@ start_bot() {
|
|||||||
[[ "${DEBUG}" = *"debug" ]] && exec &>>"DEBUG.log"
|
[[ "${DEBUG}" = *"debug" ]] && exec &>>"DEBUG.log"
|
||||||
[ "${DEBUG}" != "" ] && date && echo "Start BASHBOT in Mode \"${DEBUG}\""
|
[ "${DEBUG}" != "" ] && date && echo "Start BASHBOT in Mode \"${DEBUG}\""
|
||||||
[[ "${DEBUG}" = "xdebug"* ]] && set -x
|
[[ "${DEBUG}" = "xdebug"* ]] && set -x
|
||||||
#cleaup old pipes
|
#cleaup old pipes and empty logfiles
|
||||||
find "${TMPDIR}" -type p -delete
|
find "${TMPDIR}" -type p -delete
|
||||||
|
find "${TMPDIR}" -size 0 -name "*.log" -delete
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
UPDATE="$(getJson "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n)"
|
UPDATE="$(getJson "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n)"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-pre-0-gdd7c66d
|
#### $$VERSION$$ v0.80-pre-2-g9482bd6
|
||||||
|
|
||||||
# source from commands.sh if you want ro use interactive or background jobs
|
# source from commands.sh if you want ro use interactive or background jobs
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ start_back() {
|
|||||||
# $3 prefix
|
# $3 prefix
|
||||||
start_proc() {
|
start_proc() {
|
||||||
[ "$2" = "" ] && return
|
[ "$2" = "" ] && return
|
||||||
|
[ -x "${2%% *}" ] || return 1
|
||||||
local fifo; fifo="${TMPDIR:-.}/$(procname "$1" "$3")"
|
local fifo; fifo="${TMPDIR:-.}/$(procname "$1" "$3")"
|
||||||
kill_proc "$1" "$3"
|
kill_proc "$1" "$3"
|
||||||
mkfifo "${fifo}"
|
mkfifo "${fifo}"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# files: mycommands.sh.dist
|
# files: mycommands.sh.dist
|
||||||
# copy to mycommands.sh and add all your commands and functions here ...
|
# copy to mycommands.sh and add all your commands and functions here ...
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-pre-0-gdd7c66d
|
#### $$VERSION$$ v0.80-pre-2-g9482bd6
|
||||||
#
|
#
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# uncomment the following lines to overwrite info and help messages
|
||||||
@ -30,7 +30,7 @@ if [ "$1" != "source" ];then
|
|||||||
'/question'*) # start interactive questions
|
'/question'*) # start interactive questions
|
||||||
checkproc
|
checkproc
|
||||||
if [ "$res" -gt 0 ] ; then
|
if [ "$res" -gt 0 ] ; then
|
||||||
startproc "examples/question.sh"
|
startproc "examples/question.sh" || _message "Can't start question."
|
||||||
else
|
else
|
||||||
send_normal_message "${CHAT[ID]}" "$MESSAGE already running ..."
|
send_normal_message "${CHAT[ID]}" "$MESSAGE already running ..."
|
||||||
fi
|
fi
|
||||||
@ -39,7 +39,7 @@ if [ "$1" != "source" ];then
|
|||||||
'/run_notify'*) # start notify background job
|
'/run_notify'*) # start notify background job
|
||||||
myback="notify"; checkback "$myback"
|
myback="notify"; checkback "$myback"
|
||||||
if [ "$res" -gt 0 ] ; then
|
if [ "$res" -gt 0 ] ; then
|
||||||
background "examples/notify.sh 60" "$myback" # notify every 60 seconds
|
background "examples/notify.sh 60" "$myback" || _message "Can't start notify."
|
||||||
else
|
else
|
||||||
send_normal_message "${CHAT[ID]}" "Background command $myback already running ..."
|
send_normal_message "${CHAT[ID]}" "Background command $myback already running ..."
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user