mirror of
https://github.com/sartoopjj/thefeed.git
synced 2026-05-19 06:14:35 +03:00
fix: handle Telegram login service state during authentication
This commit is contained in:
+10
-1
@@ -534,6 +534,12 @@ telegram_login() {
|
|||||||
echo -e "${yellow}This will authenticate with Telegram and save the session.${plain}"
|
echo -e "${yellow}This will authenticate with Telegram and save the session.${plain}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
local was_active=0
|
||||||
|
if systemctl is-active --quiet thefeed-server 2>/dev/null; then
|
||||||
|
was_active=1
|
||||||
|
systemctl stop thefeed-server
|
||||||
|
fi
|
||||||
|
|
||||||
set -a
|
set -a
|
||||||
source "$DATA_DIR/thefeed.env"
|
source "$DATA_DIR/thefeed.env"
|
||||||
set +a
|
set +a
|
||||||
@@ -546,16 +552,19 @@ telegram_login() {
|
|||||||
--api-id "$TELEGRAM_API_ID" \
|
--api-id "$TELEGRAM_API_ID" \
|
||||||
--api-hash "$TELEGRAM_API_HASH" \
|
--api-hash "$TELEGRAM_API_HASH" \
|
||||||
--phone "$TELEGRAM_PHONE"
|
--phone "$TELEGRAM_PHONE"
|
||||||
|
local rc=$?
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $rc -ne 0 ]]; then
|
||||||
echo -e "${red}Telegram login failed${plain}"
|
echo -e "${red}Telegram login failed${plain}"
|
||||||
echo -e "${yellow}You can retry later with:${plain}"
|
echo -e "${yellow}You can retry later with:${plain}"
|
||||||
echo -e " sudo bash install.sh --login"
|
echo -e " sudo bash install.sh --login"
|
||||||
|
[[ $was_active -eq 1 ]] && systemctl start thefeed-server
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 600 "$DATA_DIR/session.json"
|
chmod 600 "$DATA_DIR/session.json"
|
||||||
echo -e "${green}Telegram login successful, session saved.${plain}"
|
echo -e "${green}Telegram login successful, session saved.${plain}"
|
||||||
|
[[ $was_active -eq 1 ]] && systemctl start thefeed-server
|
||||||
}
|
}
|
||||||
|
|
||||||
install_service() {
|
install_service() {
|
||||||
|
|||||||
Reference in New Issue
Block a user