mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-28 04:45:00 +00:00
hooks: enbable more shellcheck tests and fix resulting ${xxx} warnings
This commit is contained in:
parent
14fa2c7635
commit
5f50011891
21
bashbot.rc
21
bashbot.rc
@ -5,7 +5,7 @@
|
||||
#
|
||||
# tested on: ubuntu, opensuse, debian
|
||||
#
|
||||
#### $$VERSION$$ v1.21-0-gc85af77
|
||||
#### $$VERSION$$ v1.25-dev-9-g14fa2c7
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
@ -30,8 +30,8 @@ runcmd="echo Dry run:" # not activated until you edit lines below
|
||||
runas="nobody"
|
||||
|
||||
# uncomment one of the example lines to fit your system
|
||||
# runcmd="su $runas -s /bin/bash -c " # runasuser with *su*
|
||||
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with *runuser*
|
||||
# runcmd="su ${runas} -s /bin/bash -c " # runasuser with *su*
|
||||
# runcmd="runuser ${runas} -s /bin/bash -c " # runasuser with *runuser*
|
||||
|
||||
# edit the values of the following lines to fit your config:
|
||||
start="cd /usr/local/telegram-bot-bash; /usr/local/telegram-bot-bash/bashbot.sh" # location of your bashbot.sh script
|
||||
@ -40,24 +40,26 @@ name='' # your bot name as given to botfather, e.g. mysomething_bot
|
||||
# END Configuration
|
||||
#######################
|
||||
|
||||
[ "$name" = "" ] && name="$runas"
|
||||
[ "${name}" = "" ] && name="${runas}"
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# shellcheck disable=SC2250
|
||||
$runcmd "$start start" # >/dev/null 2>&1 </dev/null
|
||||
RETVAL=$?
|
||||
;;
|
||||
'stop')
|
||||
# shellcheck disable=SC2250
|
||||
$runcmd "$start stop"
|
||||
RETVAL=$?
|
||||
;;
|
||||
'status')
|
||||
ps -f -u "$runas" | grep "$name" | grep -qF "bashbot.sh startbot"
|
||||
ps -f -u "${runas}" | grep "${name}" | grep -qF "bashbot.sh startbot"
|
||||
if [ "$?" = "0" ]; then
|
||||
printf "bashbot (%s) is runningi\n" "$name"
|
||||
printf "bashbot (%s) is runningi\n" "${name}"
|
||||
RETVAL=0
|
||||
else
|
||||
printf "bashbot (%s) is stopped\n" "$name"
|
||||
printf "bashbot (%s) is stopped\n" "${name}"
|
||||
RETVAL=1
|
||||
fi
|
||||
;;
|
||||
@ -70,12 +72,13 @@ case "$1" in
|
||||
RETVAL=$?
|
||||
;;
|
||||
'suspendback'|'resumeback'|'killback')
|
||||
# shellcheck disable=SC2250
|
||||
$runcmd "$start $1"
|
||||
RETVAL=$?
|
||||
# kill inotifywait from runuser
|
||||
if [ "$1" != "resumeback" ]; then
|
||||
# shellcheck disable=SC2046
|
||||
kill -9 $(ps -u "$runas" | grep inotifywait | sed 's/ .*//') >/dev/null 2>&1
|
||||
kill -9 $(ps -u "${runas}" | grep inotifywait | sed 's/ .*//') >/dev/null 2>&1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@ -83,4 +86,4 @@ case "$1" in
|
||||
RETVAL=1
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
||||
exit "${RETVAL}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.21-0-gc85af77
|
||||
#### $$VERSION$$ v1.25-dev-9-g14fa2c7
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
@ -7,7 +7,7 @@
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
GIT_DIR=$(git rev-parse --git-dir)
|
||||
cd "$GIT_DIR/.." || exit 1
|
||||
cd "${GIT_DIR}/.." || exit 1
|
||||
|
||||
export HOOKDIR="dev/hooks"
|
||||
LASTPUSH='.git/.lastcommit'
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.21-0-gc85af77
|
||||
#### $$VERSION$$ v1.25-dev-9-g14fa2c7
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
@ -7,7 +7,7 @@
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
GIT_DIR=$(git rev-parse --git-dir)
|
||||
cd "$GIT_DIR/.." || exit 1
|
||||
cd "${GIT_DIR}/.." || exit 1
|
||||
|
||||
export HOOKDIR="dev/hooks"
|
||||
LASTPUSH='.git/.lastpush'
|
||||
@ -32,9 +32,9 @@ set +f
|
||||
FILES="$(find ./* -name '*.sh' | grep -v -e 'DIST\/' -e 'STANDALONE\/' -e 'JSON.sh')"
|
||||
set -f
|
||||
FILES="${FILES} $(sed '/^#/d' <"dev/shellcheck.files")"
|
||||
if [ "$FILES" != "" ]; then
|
||||
if [ "${FILES}" != "" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
shellcheck -x ${FILES} || exit 1
|
||||
shellcheck -o all -e SC2249,SC2154 -x ${FILES} || exit 1
|
||||
printf " OK\n............................\n"
|
||||
else
|
||||
# something went wrong
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.21-0-gc85af77
|
||||
#### $$VERSION$$ v1.25-dev-9-g14fa2c7
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
@ -7,7 +7,7 @@
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
GIT_DIR=$(git rev-parse --git-dir)
|
||||
cd "$GIT_DIR/.." || exit 1
|
||||
cd "${GIT_DIR}/.." || exit 1
|
||||
|
||||
export HOOKDIR="dev/hooks"
|
||||
LASTPUSH='.git/.lastpush'
|
||||
|
@ -4,7 +4,7 @@
|
||||
# files: mycommands.sh.clean
|
||||
# copy to mycommands.sh and add all your commands and functions here ...
|
||||
#
|
||||
#### $$VERSION$$ v1.25-dev-0-gd310805
|
||||
#### $$VERSION$$ v1.25-dev-9-g14fa2c7
|
||||
#
|
||||
|
||||
##########
|
||||
@ -108,7 +108,7 @@ else
|
||||
##################
|
||||
# example command, replace them by your own
|
||||
'/echo'*) # example echo command
|
||||
send_normal_message "${CHAT[ID]}" "$MESSAGE"
|
||||
send_normal_message "${CHAT[ID]}" "${MESSAGE}"
|
||||
;;
|
||||
|
||||
##########
|
||||
@ -152,10 +152,10 @@ else
|
||||
local image result sep="" count="1"
|
||||
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://images.search.yahoo.com/search/images?p=$1" | sed 's/</\n</g' | grep "<img src=")"
|
||||
while read -r image; do
|
||||
[ "$count" -gt "20" ] && break
|
||||
[ "${count}" -gt "20" ] && break
|
||||
image="${image#* src=\'}"; image="${image%%&pid=*}"
|
||||
[[ "${image}" = *"src="* ]] && continue
|
||||
printf "%s\n" "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
||||
printf "%s\n" "${sep}"; inline_query_compose "${RANDOM}" "photo" "${image}"; sep=","
|
||||
count=$(( count + 1 ))
|
||||
done <<<"${result}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user