mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-09-28 08:19:02 +00:00
init: bashbot.rc: adjust botname
This commit is contained in:
parent
c6c30a4b9d
commit
d521d35815
18
bashbot.sh
18
bashbot.sh
@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
|
|||||||
# 8 - curl/wget missing
|
# 8 - curl/wget missing
|
||||||
# 10 - not bash!
|
# 10 - not bash!
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.25-dev-54-gbd664da
|
#### $$VERSION$$ v1.25-dev-55-gc6c30a4
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# emmbeded system may claim bash but it is not
|
# emmbeded system may claim bash but it is not
|
||||||
@ -1105,7 +1105,7 @@ start_bot() {
|
|||||||
# initialize bot environment, user and permissions
|
# initialize bot environment, user and permissions
|
||||||
bot_init() {
|
bot_init() {
|
||||||
[ -n "${BASHBOT_HOME}" ] && cd "${BASHBOT_HOME}" || exit 1
|
[ -n "${BASHBOT_HOME}" ] && cd "${BASHBOT_HOME}" || exit 1
|
||||||
local runuser touser DEBUG="$1"
|
local runuser chown touser botname DEBUG="$1"
|
||||||
# upgrade from old version
|
# upgrade from old version
|
||||||
# currently no action
|
# currently no action
|
||||||
printf "Check for Update actions ...\n"
|
printf "Check for Update actions ...\n"
|
||||||
@ -1120,8 +1120,8 @@ bot_init() {
|
|||||||
# ask for bashbot user
|
# ask for bashbot user
|
||||||
runuser="${RUNUSER}"; [ "${UID}" = "0" ] && runuser="nobody"
|
runuser="${RUNUSER}"; [ "${UID}" = "0" ] && runuser="nobody"
|
||||||
printf "Enter User to run bashbot [${runuser}]: "
|
printf "Enter User to run bashbot [${runuser}]: "
|
||||||
read -r touser
|
read -r chown
|
||||||
[ -z "${touser}" ] && touser="${runuser}"
|
[ -z "${chown}" ] && chown="${runuser}"; touser="${chown%:*}"
|
||||||
# check user ...
|
# check user ...
|
||||||
if ! id "${touser}" &>/dev/null; then
|
if ! id "${touser}" &>/dev/null; then
|
||||||
printf "${RED}User \"${touser}\" does not exist!${NN}"
|
printf "${RED}User \"${touser}\" does not exist!${NN}"
|
||||||
@ -1139,10 +1139,16 @@ bot_init() {
|
|||||||
chmod -R o-r,o-w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${BOTACL}" 2>/dev/null
|
chmod -R o-r,o-w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${BOTACL}" 2>/dev/null
|
||||||
# jsshDB must writeable by owner
|
# jsshDB must writeable by owner
|
||||||
find . -name '*.jssh*' -exec chmod u+w \{\} +
|
find . -name '*.jssh*' -exec chmod u+w \{\} +
|
||||||
chown -R "${touser}" . ./*
|
chown -Rf "${chown}" . ./*
|
||||||
printf "Done.\n"
|
printf "Done.\n"
|
||||||
# adjust values in bashbot.rc
|
# adjust values in bashbot.rc
|
||||||
[ -w "bashbot.rc" ] && sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'"${touser}"'"/' "bashbot.rc"
|
if [ -w "bashbot.rc" ]; then
|
||||||
|
printf "Adjust user and botname in bashbot.rc ...\n"
|
||||||
|
sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'"${touser}"'"/' "bashbot.rc"
|
||||||
|
botname="$(getConfigKey "botname")"
|
||||||
|
[ -n "${botname}" ] && sed -i '/^[# ]*name=/ s/name=.*$/name="'"${botname}"'"/' "bashbot.rc"
|
||||||
|
printf "Done.\n"
|
||||||
|
fi
|
||||||
# ask to check bottoken online
|
# ask to check bottoken online
|
||||||
if [ -z "$(getConfigKey "botid")" ]; then
|
if [ -z "$(getConfigKey "botid")" ]; then
|
||||||
printf "Seems to be your first init. Should I verify your bot token online? (y/N) N\b"
|
printf "Seems to be your first init. Should I verify your bot token online? (y/N) N\b"
|
||||||
|
Loading…
Reference in New Issue
Block a user