<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bash on the bin</title><link>https://thebin.net/tags/bash/</link><description>Recent content in Bash on the bin</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Wed, 16 Sep 2015 00:00:00 +0000</lastBuildDate><atom:link href="https://thebin.net/tags/bash/index.xml" rel="self" type="application/rss+xml"/><item><title>Bash: Dynamic Volume Group Mounter</title><link>https://thebin.net/2015/09/bash-dynamic-volume-group-mounter/</link><pubDate>Wed, 16 Sep 2015 00:00:00 +0000</pubDate><guid>https://thebin.net/2015/09/bash-dynamic-volume-group-mounter/</guid><description>&lt;p&gt;This is similar, but an enhanced version of my custom_mount.sh previously published here: &lt;a href="http://blog.allanglesit.com/2012/08/bash-automatically-mount-file-systems-on-volume-group-if-present/"&gt;Bash: Automatically Mount File Systems on Volume Group if Present&lt;/a&gt;. This previous version was just a simple init script.  This updated version is designed for newer Linux distributions that use Systemd instead of Init.&lt;/p&gt;&#10;&lt;h2 id="the-code"&gt;The Code&lt;/h2&gt;&#10;&lt;p&gt;The majority of the work is done by dvgmounter.sh.  It will check if the Volume Group is present, if it is it will parse the /etc/fstab file looking for entries that are marked noauto, then it will test if that file system is already mounted, if it is not it will mount it.&lt;/p&gt;</description></item><item><title>Bash: Automatically Mount File Systems on Volume Group if Present</title><link>https://thebin.net/2012/08/bash-automatically-mount-file-systems-on-volume-group-if-present/</link><pubDate>Thu, 02 Aug 2012 00:00:00 +0000</pubDate><guid>https://thebin.net/2012/08/bash-automatically-mount-file-systems-on-volume-group-if-present/</guid><description>&lt;p&gt;Update 09/16/2015 – I have published an updated article for this here: &lt;a href="http://blog.allanglesit.com/2012/08/bash-automatically-mount-file-systems-on-volume-group-if-present/"&gt;http://blog.allanglesit.com/2012/08/bash-automatically-mount-file-systems-on-volume-group-if-present/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In my laptop I have a solid state disk, and frankly I am way past addicted to solid state disks, but what you get in performance you lose in capacity.  As such I have had to be creative with how I can have the capacity and the performance that I need.  Lately the solution has been to have a spinning disk in the slot that would normally be occupied by my CD/DVD drive.  However the problem with this, revealed itself to be that my Fedora install would actually fail to boot when it tried and failed to mount the file systems if this device was not present.  So my first “solution” was to set noauto in the /etc/fstab for these secondary file systems.  Which presented a new problem…  I would forget to manually mount these devices before launching Virtualbox to start my VMs.  So I decided that I would need to have an auto-mount script which would check for the volume group to be present and then if it was mount the file systems contained within the /etc/fstab which live on the volume group.&lt;/p&gt;</description></item><item><title>Bash: A Better Way to Sed</title><link>https://thebin.net/2012/05/bash-a-better-way-to-sed/</link><pubDate>Tue, 01 May 2012 00:00:00 +0000</pubDate><guid>https://thebin.net/2012/05/bash-a-better-way-to-sed/</guid><description>&lt;p&gt;So I frequently find myself in a situation where I need to modify files on a fairly programmatic basis, so sed has become a friend of mine for a lot of these situations.  So lets start with some basic sed…&lt;/p&gt;&#10;&lt;p&gt;If I have a file..&lt;/p&gt;&#10;&lt;div class="codeblock" data-lang="bash"&gt;&#10; &lt;div class="codeblock__bar"&gt;&#10; &lt;span class="codeblock__lang"&gt;bash&lt;/span&gt;&#10; &lt;button type="button" class="codeblock__copy" aria-label="Copy code"&gt;&#10; &lt;span class="codeblock__copy-label"&gt;Copy&lt;/span&gt;&#10; &lt;/button&gt;&#10; &lt;/div&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/file.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;teststring&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;And I want to replace “teststring” with “productionvalue” then I could use sed.&lt;/p&gt;&#10;&lt;div class="codeblock" data-lang="bash"&gt;&#10; &lt;div class="codeblock__bar"&gt;&#10; &lt;span class="codeblock__lang"&gt;bash&lt;/span&gt;&#10; &lt;button type="button" class="codeblock__copy" aria-label="Copy code"&gt;&#10; &lt;span class="codeblock__copy-label"&gt;Copy&lt;/span&gt;&#10; &lt;/button&gt;&#10; &lt;/div&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sed -i &lt;span class="s1"&gt;&amp;#39;s/teststring/productionvalue/g&amp;#39;&lt;/span&gt; /etc/file.txt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="codeblock" data-lang="bash"&gt;&#10; &lt;div class="codeblock__bar"&gt;&#10; &lt;span class="codeblock__lang"&gt;bash&lt;/span&gt;&#10; &lt;button type="button" class="codeblock__copy" aria-label="Copy code"&gt;&#10; &lt;span class="codeblock__copy-label"&gt;Copy&lt;/span&gt;&#10; &lt;/button&gt;&#10; &lt;/div&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/file.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;productionvalue&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blah&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;This is all well and good, but recently I found a better way…&lt;/p&gt;</description></item><item><title>Bash: Duplicate Logical Volume Configuration for a Volume Group</title><link>https://thebin.net/2012/04/bash-duplicate-logical-volume-configuration-for-a-volume-group/</link><pubDate>Mon, 30 Apr 2012 00:00:00 +0000</pubDate><guid>https://thebin.net/2012/04/bash-duplicate-logical-volume-configuration-for-a-volume-group/</guid><description>&lt;p&gt;I recently ran into a situation where I needed to create a large number of Logical Volumes for a server replacement situation.  I could have done some manual data input, but why not take the opportunity to quickly write a script to do the hard work for me?&lt;/p&gt;&#10;&lt;p&gt;For my situation this was a server that pulls data from other servers in order to optimize getting that data to tape.  So we had 2 VGs, one for the system and one for the data we wanted to move.  We planned on simply performing a rsync to move the data itself, but the volumes had to be pre-staged.&lt;/p&gt;</description></item><item><title>Securing SSH with Publicly Accessible Servers</title><link>https://thebin.net/2012/02/securing-ssh-with-publicly-accessible-servers/</link><pubDate>Thu, 16 Feb 2012 00:00:00 +0000</pubDate><guid>https://thebin.net/2012/02/securing-ssh-with-publicly-accessible-servers/</guid><description>&lt;p&gt;Just about every IT environment has some sort of remotely managed environment which requires that they have SSH open to the Internet.  Perhaps this is a VPS, dedicated server, or colocation.  Regardless of your reason, the fact is that there is just some times where you need to have SSH open to the internet.&lt;/p&gt;&#10;&lt;p&gt;However regardless of if it is necessary doesn’t mean that you should just do it…  One look at your auth.log will reveal that.&lt;/p&gt;</description></item><item><title>Bash: Using Temporary SSH Keys Within A Script</title><link>https://thebin.net/2011/08/bash-using-temporary-ssh-keys-within-a-script/</link><pubDate>Wed, 10 Aug 2011 00:00:00 +0000</pubDate><guid>https://thebin.net/2011/08/bash-using-temporary-ssh-keys-within-a-script/</guid><description>&lt;p&gt;Every once and a while you will have the need to make multiple ssh calls to remote systems within a bash script.  Normally you would simply have the user enter their password multiple times, or have a requirement for SSH keys to be configured prior to running the keys.  This is widely accepted as the way to do it, however if that were the best way to do it, then I would not be writing this article.  Now the better way to do it would be to create ssh keys, and upload them as authorized keys to the remote host(s) then upon completion of the work we can then clean up the changes that we made.&lt;/p&gt;</description></item><item><title>Bash: Using pv to Display Progress of dd</title><link>https://thebin.net/2011/08/bash-using-pv-to-display-progress-of-dd/</link><pubDate>Tue, 09 Aug 2011 00:00:00 +0000</pubDate><guid>https://thebin.net/2011/08/bash-using-pv-to-display-progress-of-dd/</guid><description>&lt;p&gt;One of the biggest weaknesses of dd is that it has no way to display progress on its actions.  You can send a signal to the process which will pause, display statistics, and resume the process however this takes up alot of your terminal screen if you are doing any sort of long running copy.  Enter pv.  Pv allows us to monitor the progress of data through a pipe.&lt;/p&gt;&#10;&lt;h2 id="create-a-1gb-test-file"&gt;Create A 1GB Test File&lt;/h2&gt;&#10;&lt;p&gt;This is the file that we will use to peform the following tests.&lt;/p&gt;</description></item><item><title>Linux-KVM Management: Offline Migration</title><link>https://thebin.net/2011/08/linux-kvm-management-offline-migration/</link><pubDate>Mon, 08 Aug 2011 00:00:00 +0000</pubDate><guid>https://thebin.net/2011/08/linux-kvm-management-offline-migration/</guid><description>&lt;p&gt;When you compare Linux-KVM to Hyper-V or VMWare your initial results will indicate that Linux-KVM is lacking when it comes to management tools, and basic functionality.  You would be correct, however you would also be incorrect.  You see with Linux-KVM we can leverage the underlying power of the Linux userland, and with this frankly all things are possible.  Here is one of the basic bits of management functionality which can be attained with a little bit of bash scripting knowledge.  I started by writing a VM backup script, then a VM export script, and of course a VM import script.  Eventually I ended up with a full-blown end-to-end VM migration script.&lt;/p&gt;</description></item></channel></rss>