fix outproc exit and show script on ps

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-19 17:31:55 +02:00
parent beb77a4b65
commit 7190c6e330
2 changed files with 10 additions and 5 deletions

View File

@ -12,7 +12,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.80-dev3-5-g83623ec
#### $$VERSION$$ v0.80-dev3-6-gbeb77a4
#
# Exit Codes:
# - 0 sucess (hopefully)
@ -391,6 +391,9 @@ bot_init() {
local OLDTMP="${BASHBOT_VAR:-.}/tmp-bot-bash"
[ -d "${OLDTMP}" ] && { mv -n "${OLDTMP}/"* "${TMPDIR}"; rmdir "${OLDTMP}"; }
[ -f "modules/inline.sh" ] && rm -f "modules/inline.sh"
# shellcheck disable=SC2009
oldbot="$(ps -ef | grep startbot | grep -v -e 'grep' -e '\-startbot' )"
[ "${oldbot}" != "" ] && echo -e "${ORANGE}Warning: Old TMUX bot is running! You must kill it manually first:${NC}\\n$${oldbot}" && exit 5
#setup bashbot
[[ "${UID}" -eq "0" ]] && RUNUSER="nobody"
echo -n "Enter User to run basbot [$RUNUSER]: "
@ -442,7 +445,7 @@ if [ "$1" != "source" ]; then
"outproc") # forward output from interactive and jobs to chat
[ "$3" = "" ] && echo "No file to read from" && exit 3
[ "$2" = "" ] && echo "No chat to send to" && exit 3
while read -r -t 10 line ;do
while read -r line ;do
[ "$line" != "" ] && send_message "$2" "$line"
done
rm -f -r "${TMPDIR:-.}/$3"

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.80-dev3-4-ge7d2eff
#### $$VERSION$$ v0.80-dev3-6-gbeb77a4
# source from commands.sh if you want ro use interactive or background jobs
@ -51,8 +51,10 @@ start_proc() {
local fifo; fifo="${TMPDIR:-.}/$(procname "$1" "$3")"
kill_proc "$1" "$3"
mkfifo "${fifo}"
nohup bash -c "{ tail -f \"${fifo}\" | $2 \"\" \"\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"
rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" &
nohup bash &>>"${fifo}.log" <<HEREDOC &
{ tail -f < "${fifo}" | $2 "" "" "$fifo" | "${SCRIPT}" outproc "${1}" "${fifo}"
rm "${fifo}"; [ -s "${fifo}.log" ] || rm -f "${fifo}.log"; }
HEREDOC
}