<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bash &#8211; Everything is Broken</title>
	<atom:link href="https://play.datalude.com/blog/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>https://play.datalude.com/blog</link>
	<description>Efficiency vs. Inefficiency, in a no-holds barred fight.</description>
	<lastBuildDate>Mon, 12 Feb 2024 08:20:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Nice formatting for mysql show variables / show status</title>
		<link>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/</link>
					<comments>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 12 Feb 2024 08:20:22 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=727</guid>

					<description><![CDATA[Have you ever tried to get a variable out of mysql and your screen fills with dots and dashes from mysql's output? Turns out its pretty simple to get rid of with awk. That's all.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Have you ever tried to get a variable out of mysql and your screen fills with dots and dashes from mysql's output? Turns out its pretty simple to get rid of with awk. </p>



<pre class="wp-block-code"><code># Arrgh!<br>mysql -e "show variables" | grep innodb<br><br># Much better<br>mysql -e "show variables" | awk '{print $1 " = " $2}' | grep innodb</code></pre>



<p class="wp-block-paragraph">That's all. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Troubleshooting postfix using bcc to local user</title>
		<link>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/</link>
					<comments>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 17 Nov 2022 03:35:13 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[postfix]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=685</guid>

					<description><![CDATA[After routing mail through postfix to an external relay server (in this case gmail's smtp relay), all the mail from a server was routing correctly. Except after a couple of days I noticed a couple of strange bounces. Authentication at the gmail end was by IP address and domain, so any address xxxxx@domain.com could be ... <a title="Troubleshooting postfix using bcc to local user" class="read-more" href="https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/" aria-label="Read more about Troubleshooting postfix using bcc to local user">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">After routing mail through postfix to an external relay server (in this case gmail's smtp relay), all the mail from a  server was routing correctly. Except after a couple of days I noticed a couple of strange bounces. Authentication at the gmail end was by IP address and domain, so any address xxxxx@domain.com could be used to send email. But these were coming from yyyy@otherdomain.com so were being rejected with a helpful message by gmail. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"><code>The IP address you've 550-5.7.1 registered in your G Suite SMTP Relay service doesn't match domain of 550-5.7.1 the account this email is being sent from. If you are trying to relay 550-5.7.1 mail from a domain that isn't registered under your G Suite account 550-5.7.1 or has empty envelope-from, you must configure your mail server 550-5.7.1 either to use SMTP AUTH to identify the sending domain or to present 550-5.7.1 one of your domain names in the HELO or EHLO command. For more 550-5.7.1 information, please visit 550 5.7.1 <a rel="noreferrer noopener" href="https://support.google.com/a/answer/6140680#invalidcred" target="_blank">https://support.google.com/a/answer/6140680</a></code></p>
</blockquote>



<p class="wp-block-paragraph">Pretty helpful as messages go. Less helpful was the fact that there were several websites on the server and a couple of other apps, and I didn't have access to the admin panels of any of them. The mails, once bounced, were removed from postfix's queue, never to be seen again. Time for some detective work.  </p>



<span id="more-685"></span>



<p class="wp-block-paragraph">I found that the mails were heading for zzzz@domain.com so I figured if I could make those appear locally I'd be able to look at the source and see what had created them. This is not so hard to do in postfix. First of all you need a line in your main.cf </p>



<pre class="wp-block-code"><code># Added to troubleshoot rejection by gmail smtp           
# Need to add addresses to the file and run postmap on it 
recipient_bcc_maps = regexp:/etc/postfix/recipient_bcc_maps</code></pre>



<p class="wp-block-paragraph">Then  you need to add entries in your /etc/postfix/recipient_bcc_maps</p>



<pre class="wp-block-code"><code># run postmap recipient_bcc_maps after editing
/zzzz\@domain.com/  ubuntu
</code></pre>



<p class="wp-block-paragraph">After that run postmap recipient_bcc_maps and restart postfix for good measure. So now any mail headed to zzzz@domain.com will also be bcced to the local ubuntu user, were we can pick it up in /var/spool/mail/ubuntu </p>



<p class="wp-block-paragraph">All good. I waited. And waited. Then got bored of waiting and made a quick bash one liner to alert me when the ubuntu user's mail file changed. </p>



<pre class="wp-block-code"><code>while true; do if ls -hal "/var/spool/mail/ubuntu" | grep -q "Nov 15 07:14" ; then sleep 5 ; else mutt -s "changed" me@mydomain.com &lt;/dev/null ; break ; fi ; done
</code></pre>



<p class="wp-block-paragraph">So this is pretty crude but it works. Every 5 seconds it checks the date and time of the mail spool file (you'd need to change to the actual date of the file, of course), and if it changes it emails to me@mydomain.com. I ran that under 'screen' and two days later I got a notification, from which I was able to figure out which script on which domain had fired off the email. </p>



<p class="wp-block-paragraph">Maybe that one liner makes more sense as a script:</p>



<pre class="wp-block-code"><code>#!/bin/bash

FILE=/var/spool/mail/ubuntu
PATTERN="Oct 17 10:44"

while true;
do 
	if ls -hal "$FILE" | grep -q "$PATTERN" ; then 
		# Do nothing. 
		sleep 5
	else
		# echo "changed"
                # play fanfare.mp3
		mutt -s "changed" me@mydomain.com &lt;/dev/null
		break;
	fi 
done</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
