tag:blogger.com,1999:blog-19952573526696628022024-03-12T18:37:18.148-04:00Chad DevOpsIT StuffChadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-1995257352669662802.post-56951093624703347242023-04-21T23:15:00.002-04:002023-04-21T23:15:31.068-04:00Bambu Labs X1C Python Monitor and Pushover Notifier. <p>A python script that will monitor the Bambu X1C 3D printer and send pushover notifications on gcode_state changes.</p><p><a href="https://github.com/ChadDevOps/bambu-lab-pushover-notify">https://github.com/ChadDevOps/bambu-lab-pushover-notify</a></p>Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com0tag:blogger.com,1999:blog-1995257352669662802.post-3571729464175868852021-03-04T18:07:00.001-05:002021-03-04T18:07:29.148-05:00Marlin Ender 3 Max Config with BL-Touch<p>Marlin Firmware Config for the Ender 3 Max.</p><p><a href="https://github.com/ChadDevOps/Marlin-Ender-3-Max" target="_blank"> https://github.com/ChadDevOps/Marlin-Ender-3-Max</a></p>Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com1tag:blogger.com,1999:blog-1995257352669662802.post-82640666792817843442020-08-12T11:02:00.005-04:002020-08-12T11:14:21.894-04:00Extend XFS Linux partition<p><b>Summary</b></p><p></p><ul style="text-align: left;"><li>Running CentOS 8 on VMWare.</li></ul><p></p><p><b>Steps</b></p><p></p><ul style="text-align: left;"><li>Increase disk volume size in VMWare</li><li>Reboot or scan for disk changes</li><ul><li><span style="font-family: courier;">ls /sys/class/scsi_device/</span></li><li><span style="font-family: courier;">echo 1 > /sys/class/scsi_device/0\:0\:1\:0/device/rescan</span></li></ul><li>SSH to server</li><li>Run the following commands (note: server data disk located at /dev/sdb)</li></ul><p></p><pre style="background-color: #666666; border-radius: 3px; box-sizing: border-box; line-height: 1.45; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;"><span style="font-size: 13.6px;">yum install cloud-utils-growpart
growpart /dev/sdb 1
xfs_growfs -d /dev/sdb1</span></code></pre>Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com0tag:blogger.com,1999:blog-1995257352669662802.post-20370958924298543172020-02-13T22:25:00.000-05:002020-02-13T22:25:01.281-05:00Receive notifications on pfsense ipsec or openvpn connection/disconnectionA couple of scripts to receive notifications for ipsec or openvpn (dis)connections on your pfsense firewall. This was tested with a Netgate SG-5100 firewall with pfsense version 2.4.4-RELEASE-p3 (amd64).<br />
<br />
<a href="https://github.com/ChadDevOps/pfsense-vpn-notifications"><span style="color: black;">https://github.com/ChadDevOps/pfsense-vpn-notifications</span></a><br />
<span style="font-family: , "blinkmacsystemfont" , "segoe ui" , "helvetica" , "arial" , sans-serif , "apple color emoji" , "segoe ui emoji"; font-size: 1.25em;"><br />SSH</span><br />
<ul style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;">
<li style="box-sizing: border-box;">SSH to your pfsense firewall. Upload files to /root/</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">chmod 755</li>
</ul>
<pre style="background-color: #666666; border-radius: 3px; box-sizing: border-box; font-family: , "consolas" , "liberation mono" , "menlo" , monospace; font-size: 13.6px; line-height: 1.45; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;"> 4 -rwxr-xr-x 1 root wheel 1999 Jul 17 2019 ipsec.php
4 -rwxr-xr-x 1 root wheel 198 Jul 17 2019 notify.php
4 -rwxr-xr-x 1 root wheel 308 Jul 17 2019 openvpnconnect.sh
4 -rwxr-xr-x 1 root wheel 498 Jul 17 2019 openvpndisconnect.sh
</code></pre>
<h3 style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 1.25em; line-height: 1.25; margin-bottom: 16px; margin-top: 24px;">
<a aria-hidden="true" class="anchor" href="https://github.com/ChadDevOps/pfsense-vpn-notifications#open-vpn" id="user-content-open-vpn" style="background-color: initial; box-sizing: border-box; float: left; line-height: 1; margin-left: -20px; padding-right: 4px; text-decoration-line: none;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg><span style="color: black;"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" fill-rule="evenodd"></path></span></a>Open VPN</h3>
<div style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px;">
For open VPN:</div>
<ul style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;">
<li style="box-sizing: border-box;">Login to GUI</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">VPN</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Edit your OpenVPN Server</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Under Advanced Configuration, Custom options, add the following line:</li>
</ul>
<div style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px;">
<code style="background-color: #666666; border-radius: 3px; box-sizing: border-box; font-family: , "consolas" , "liberation mono" , "menlo" , monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em;">client-connect /root/openvpnconnect.sh;client-disconnect /root/openvpndisconnect.sh;</code></div>
<h3 style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 1.25em; line-height: 1.25; margin-bottom: 16px; margin-top: 24px;">
<a aria-hidden="true" class="anchor" href="https://github.com/ChadDevOps/pfsense-vpn-notifications#ipsec" id="user-content-ipsec" style="background-color: initial; box-sizing: border-box; float: left; line-height: 1; margin-left: -20px; padding-right: 4px; text-decoration-line: none;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg><span style="color: black;"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" fill-rule="evenodd"></path></span></a>ipsec</h3>
<div style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px;">
Create cron to run every minute or so. This will not give exact times for connect/disconnect but within a 60 second window.</div>
<ul style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;">
<li style="box-sizing: border-box;">Login to GUI</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Services</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Cron</li>
</ul>
<div style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px;">
<code style="background-color: #666666; border-radius: 3px; box-sizing: border-box; font-family: , "consolas" , "liberation mono" , "menlo" , monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em;">* * * * * root /usr/local/bin/php /root/ipsec.php > /dev/null 2>&1</code></div>
<h3 style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 1.25em; line-height: 1.25; margin-bottom: 16px; margin-top: 24px;">
<a aria-hidden="true" class="anchor" href="https://github.com/ChadDevOps/pfsense-vpn-notifications#notifications" id="user-content-notifications" style="background-color: initial; box-sizing: border-box; float: left; line-height: 1; margin-left: -20px; padding-right: 4px; text-decoration-line: none;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg><span style="color: black;"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" fill-rule="evenodd"></path></span></a>Notifications</h3>
<div style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px;">
Setup your SMTP server. The above files utilize pfsense's php functions to send via the send_smtp_message function</div>
<ul style="box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 0px !important; margin-top: 0px; padding-left: 2em;">
<li style="box-sizing: border-box;">Login to GUI</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">System</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Advanced</li>
<li style="box-sizing: border-box; margin-top: 0.25em;">Notifications Tab</li>
</ul>
<br />Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com2tag:blogger.com,1999:blog-1995257352669662802.post-67592435306959813592020-02-12T21:17:00.000-05:002020-02-12T21:17:00.287-05:00AWS Lambda script to delete old indices if ES server is low on space.A lamda script to delete old indices from AWS Elastic Search Service if it's low on space. Tested with AWS ElasticSearch Service 7.1.<br />
<br />
<a href="https://github.com/ChadDevOps/aws-elasticsearch-lambda-delete">https://github.com/ChadDevOps/aws-elasticsearch-lambda-delete</a><br />
<br />
<br />Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com2tag:blogger.com,1999:blog-1995257352669662802.post-76562707838370786412020-02-11T22:36:00.000-05:002020-02-12T12:27:41.806-05:00AWS Kibana Open Distro Alerting to MS TeamsMS Teams is a collaboration tool similar to Slack and it comes free with office365 business subscriptions. Below is a query to update the Kibana alerting trigger message (that comes with Open Distro) to use the MS Teams message card.<br />
<br />
Note, this will only update the first trigger. If anyone scripts this to update all triggers, please comment below.
<br />
<br />
Run the query from Kibana dev tools.<br />
<br />
<script src="https://gist.github.com/ChadDevOps/81dcf4a85698a35662318f0064bf5357.js?file=query"></script>Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com0tag:blogger.com,1999:blog-1995257352669662802.post-59261772361458143952020-02-07T23:32:00.002-05:002020-02-12T12:28:10.242-05:00Ubuntu 18.04 Installing ClamAV with clamonacc<span style="font-family: inherit;">A quick guide to installing ClamAV with clamonacc on Ubuntu 18.04.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Note: This was installed on a virtualmin server with clamav. Existing clamav was removed/purged via apt-get and reinstalled. clamd.conf reflects settings as part of virtualmin and clamonacc.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<b><span style="font-family: inherit;">Install clamav and mailx</span></b><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">sudo apt-get install -y bsd-mailx clamav clamav-base clamav-daemon clamav-docs clamav-freshclam</span><br />
<br />
<b>Create Quarantine Folder</b><br />
<br />
<div style="box-sizing: border-box;">
<span style="background-color: #666666;"><span style="font-family: "courier new" , "courier" , monospace;">mkdir /root/quarantine</span></span></div>
<br />
<br />
<b>Create the following files</b> (see gist files below at end of blog or <a href="https://gist.github.com/ChadDevOps/dc5428e8d816344f68b03c99359731f9" target="_blank">here</a>) <br />
<ul>
<li>/etc/systemd/system/clamonacc.service </li>
<li>/etc/clamav/clamd.conf </li>
<li>/etc/clamav/detected.sh</li>
</ul>
<ul>
</ul>
Modify them as needed (paths, email addresses, settings, etc)<br />
<br />
<b>Enable services</b><br />
<br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">systemctl enable clamav-daemon.service</span><br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">systemctl enable clamonacc.service</span><br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">systemctl enable clamav-freshclam.service</span><br />
<br />
<b>Add root to clamav group</b><br />
<br />
Clam, by default, will run under the clamav user and group. You can choose to keep/configure this or run as root. If you scan /root or folders owned by root you can encounter lstat() errors while running under the clamav user.<br />
<br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">usermod -a -G clamav root</span>
<br />
<br />
<b>Crons</b><br />
<b><br /></b>
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace; font-size: xx-small;">00 01,13 * * * /usr/bin/freshclam --quiet</span><br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace; font-size: xx-small;">0 19 * * 1-5 nice -n 16 systemd-cat --identifier="clamav-scan" clamdscan --quiet --fdpass /home /tmp >/dev/null 2>&1</span><br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace; font-size: xx-small;">0 6 * * 6 nice -n 18 systemd-cat --identifier="clamav-scan" clamdscan --quiet --fdpass / >/dev/null 2>&1</span><br />
<b><br /></b>
<b>Final Step</b><br />
<ul>
<li>Reboot</li>
</ul>
<b>Gist Files</b><br />
<br />
<script src="https://gist.github.com/ChadDevOps/dc5428e8d816344f68b03c99359731f9.js"></script>Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com1tag:blogger.com,1999:blog-1995257352669662802.post-10259479693281482592020-02-05T20:37:00.000-05:002020-04-15T15:29:11.861-04:00Virtualmin - Moving MySQL 5.7 to 8 - SUPER privilege(s) and DEFINER errorsWhile attempting to restore Virtualmin domains from Ububtu 16.04 with AWS MySQL RDS 5.7 to Ubuntu 18.04 with a remote AWS RDS MySQL 8.0 I ran into an issue where MySQL had <b>SUPER privilege(s) and DEFINER errors</b> when running the restore:<br />
<br />
<b>Example Error</b><br />
<br />
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation</span><br />
<br />
<b>Example Restore</b><br />
<br />
<span style="background-color: #666666; font-size: 13px;"><span style="font-family: "courier new" , "courier" , monospace;">virtualmin restore-domain --source /root/backups --all-domains --all-features</span></span><br />
<br />
<b>How to resolve</b><br />
<br />
Enable <span style="background-color: #666666; font-size: 13px;"><span style="font-family: "courier new" , "courier" , monospace;">log_bin_trust_function_creators = 1;</span></span> in your custom parameters for AWS RDS MySQL and reboot the instance.<br />
<br />
Get a export of your MySQL databases (I ended up using using webmin to grab a backup of all databases and SCPed those to the new server). Then proceed with the following replace commands to clean up the SQL dumps (after extracting the gzips)<br />
<br />
<div style="box-sizing: border-box;">
<pre><span style="background-color: #666666; font-size: 14px;">sed -i.bak 's#MyISAM#InnoDB#g' *
sed -i.bak 's#SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION\.SQL_LOG_BIN;##g' *
sed -i.bak 's#SET @@SESSION\.SQL_LOG_BIN= 0;##g' *
sed -i.bak "s#SET @@GLOBAL\.GTID_PURGED='.*';##g" *
sed -i.bak "s#SET @@SESSION\.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN##g" *
sed -i.bak 's#NO_AUTO_CREATE_USER##g' *</span></pre>
</div>
<br />
Note: The first replacement above is to convert your tables from MyISAM to InnoDB, ignore if you want to keep MyISAM. If you do not want a lot of .bak.bak.bak files, remove the '.bak' from the commands above.<br />
<br />
<b>Virtualmin</b><br />
<b><br /></b>
When running the restore Virtualmin will fail on importing the mysql database. However, the database and user information will be created. After it has been created import your SQL above. This can be done through Webmin or command line.<br />
<br />
If you are importing multiple domains, you can run the following command to continue importing your other domains. Repeat the steps above if you get another MySQL import error.<br />
<br />
<span style="background-color: #666666; font-size: 13px;"><span style="font-family: "courier new" , "courier" , monospace;">virtualmin restore-domain --source /root/backups --all-domains --all-features --only-missing</span></span><br />
<br />
<div>
<b>MySQL 8 Gotchas</b></div>
<b><br /></b>
With MySQL 8 you may run into an authentication issue after doing the above. Usually this shows up as a 500 error on your site or a 2054 from mysql. Run the following command to fix the authentication type for your user.<br />
<br />
<div style="box-sizing: border-box; font-size: 14px;">
<span style="background-color: #666666; font-family: "courier new" , "courier" , monospace;">ALTER USER 'YOUR_USERNAME'@'YOUR_HOSTNAME' IDENTIFIED WITH mysql_native_password BY 'YOUR_PASSWO</span><span style="background-color: #666666;"><span style="font-family: "courier new" , "courier" , monospace;">RD</span><span style="font-family: "courier new" , "courier" , monospace;">';</span></span></div>
<br />
Ref: <a href="https://aws.amazon.com/premiumsupport/knowledge-center/mysqldump-error-rds-mysql-mariadb/">https://aws.amazon.com/premiumsupport/knowledge-center/mysqldump-error-rds-mysql-mariadb/</a><br />
<div style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", Courier, monospace; font-size: 13px; white-space: pre;">
<pre></pre>
</div>
Chadhttp://www.blogger.com/profile/04940998038112908582noreply@blogger.com0