Page MenuHomePhabricator
Paste P9323

dologmsg (for Cloud VPS)
ActivePublic

Authored by Lokal_Profil on Oct 14 2019, 8:55 AM.
Tags
None
Referenced Files
F30676078: raw.txt
Oct 14 2019, 8:55 AM
Subscribers
#!/bin/bash
# Send a !log message for the current project to #wikimedia-cloud.
# Usage:
# dologmsg webservice restart
# dologmsg 'deployed commit ab12de34 (T123456)'
labsproject=$(</etc/wmflabs-project)
su_user=$(logname)
message=$*
if [[ $message == "" ]]; then
printf >&2 '%s: no message\n' "$0"
exit 1
fi
if [[ $su_user ]]; then
message="<$su_user> $message"
fi
printf '#wikimedia-cloud !log %s %s\n' "$labsproject" "$message" > /dev/tcp/wm-bot2.wm-bot.eqiad.wmflabs/64834

Event Timeline

You can probably remove the if around L18 – logname should always return something, so it’s probably safer to inject it into the message unconditionally.

(But apart from that, I don’t see why this wouldn’t work.)

@LucasWerkmeister I'm still having an issue with wm-bot being credited as the sender of the message (see https://tools.wmflabs.org/sal/finding-glams?d=2019-10-14).

If I remove > /dev/tcp/wm-bot2.wm-bot.eqiad.wmflabs/64834 to test locally it correctly puts my username in so it must somehow be evaluating $su_user at a later stage when it has been passed to wm-bot