Skip to content

Commit

Permalink
update MOTD routines in 123.09beta01
Browse files Browse the repository at this point in the history
- On first SSH login a MOTD banner is shown with Centmin Mod info and checks for latest nginx version and whether centmin mod code updates are available. Part of these checks is logging to a file named cmm-login-git-checks* in /root/centminlogs of this login routine with recorded time duration of how long the checks took. This is for troubleshooting if needed.
- However, this SSH login routine is triggered for both interactive and non-interactive logins. So when you SSH login = interactive. But when you have scripts remotely connecting to your server, they're non-interactive but the MOTD banner and /root/centminlogs/cmm-login-git-checks* generated logs are still triggered.
- This update changes it so that only interactive SSH logins trigger MOTD banner and /root/centminlogs/cmm-login-git-checks* generated logs. If you have scripts or processes which remotely log into the Centmin Mod server via SSH and they are non-interactive, then MOTD banner and /root/centminlogs/cmm-login-git-checks* generated logs are now skipped.
- To update existing Centmin Mod 123.09beta01 servers, run cmupdate command and then run centmin.sh menu once and exit.
  • Loading branch information
centminmod committed Sep 26, 2019
1 parent 356c6b3 commit 64177b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion centmin.sh
Expand Up @@ -27,7 +27,7 @@ DT=$(date +"%d%m%y-%H%M%S")
branchname='123.09beta01'
SCRIPT_MAJORVER='1.2.3'
SCRIPT_MINORVER='09'
SCRIPT_INCREMENTVER='282'
SCRIPT_INCREMENTVER='283'
SCRIPT_VERSIONSHORT="${branchname}"
SCRIPT_VERSION="${SCRIPT_VERSIONSHORT}.b${SCRIPT_INCREMENTVER}"
SCRIPT_DATE='31/10/2019'
Expand Down
10 changes: 7 additions & 3 deletions inc/cpcheck.inc
Expand Up @@ -1721,10 +1721,14 @@ cmupdatecheck() {
}

dmotdcheck() {
# correct /etc/profile.d/dmotd.sh setup bug
if [[ -f /etc/profile.d/dmotd.sh && "$(grep '"0"' /etc/profile.d/dmotd.sh)" ]]; then
# correct /etc/profile.d/dmotd.sh to only run motd and logging on interactive ssh sessions
# skip for non-interactive sessions like remote ssh logs that are scripted
if [[ -f /etc/profile.d/dmotd.sh && -z "$(grep 'tty' /etc/profile.d/dmotd.sh)" ]]; then
echo '#!/bin/bash' > /etc/profile.d/dmotd.sh
echo "if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi" >> /etc/profile.d/dmotd.sh
# echo "if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi" >> /etc/profile.d/dmotd.sh
echo "if tty -s; then type='interactive'; if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi; else type='non-interactive'; fi;" >> /etc/profile.d/dmotd.sh
echo "if echo \$0 | grep -e ^\\- 2>&1>/dev/null; then login='login'; else login='non-login'; fi;" >> /etc/profile.d/dmotd.sh
# echo "$type/$login"
fi
}

Expand Down
8 changes: 7 additions & 1 deletion inc/motd.inc
Expand Up @@ -12,7 +12,13 @@ checkmotd() {
fi
if [ ! -f /etc/profile.d/dmotd.sh ]; then
echo '#!/bin/bash' > /etc/profile.d/dmotd.sh
echo "if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi" >> /etc/profile.d/dmotd.sh
# echo "if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi" >> /etc/profile.d/dmotd.sh

# correct /etc/profile.d/dmotd.sh to only run motd and logging on interactive ssh sessions
# skip for non-interactive sessions like remote ssh logs that are scripted
echo "if tty -s; then type='interactive'; if [[ \"\$(id -u)\" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi; else type='non-interactive'; fi;" >> /etc/profile.d/dmotd.sh
echo "if echo \$0 | grep -e ^\\- 2>&1>/dev/null; then login='login'; else login='non-login'; fi;" >> /etc/profile.d/dmotd.sh
# echo "$type/$login"
\cp -f /etc/motd /etc/motd-backup2
echo > /etc/motd
fi
Expand Down

0 comments on commit 64177b8

Please sign in to comment.