<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>d|b</title>
	
	<link>http://disstress.net</link>
	<description>Sysadmins do it from the command line</description>
	<lastBuildDate>Fri, 14 Jan 2011 01:24:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/disstress/lDPK" /><feedburner:info uri="disstress/ldpk" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Install Shorewall and Fail2Ban on a cPanel server</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/KKc0rAps7J0/install-shorewall-and-fail2ban-on-a-cpanel-server</link>
		<comments>http://disstress.net/gen/install-shorewall-and-fail2ban-on-a-cpanel-server#comments</comments>
		<pubDate>Mon, 13 Dec 2010 23:13:58 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=104</guid>
		<description><![CDATA[For new admins that want to be able to access your cPanel server via SSH from multiple locations, you need to have a firewall solution in place. It is also a really good idea to have a solution in place that will block malicious SSH connection attempts. Shorewall with Fail2Ban are two really good programs [...]]]></description>
			<content:encoded><![CDATA[<p>For new admins that want to be able to access your cPanel server via SSH from multiple locations, you need to have a firewall solution in place. It is also a really good idea to have a solution in place that will block malicious SSH connection attempts.</p>
<p>Shorewall with Fail2Ban are two really good programs to use for these needs. Thankfully, the Fedora Project has set up an extra&#8217;s repository that houses these two programs in easy to install RPMs. From the <a href="http://fedoraproject.org/wiki/EPEL/FAQ" target="_blank">Fedora Project Wiki</a>:</p>
<blockquote><p>What is EPEL?</p>
<p>EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs, such as CentOS and Scientific Linux.</p>
<p>As part of the Fedora packaging community, EPEL packages are 100% free/libre open source software (FLOSS).</p></blockquote>
<p>To install these programs, you will first need to obtain the RPMs from the EPEL repository. You can either add the repo to your repo list or wget the RPMs directly.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>shorewall-common-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>shorewall-shell-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>shorewall-perl-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>shorewall-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>fail2ban-0.8.4-<span style="color: #000000;">23</span>.el5.noarch.rpm</div></div>
<p>Now you will want to satisfy a simple requirement using yum:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">yum install</span> gamin-python</div></div>
<p>With that out of the way, you can install the RPMs that you have downloaded:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rpm <span style="color: #660033;">-Uvh</span> shorewall-common-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
rpm <span style="color: #660033;">-Uvh</span> shorewall-shell-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
rpm <span style="color: #660033;">-Uvh</span> shorewall-perl-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
rpm <span style="color: #660033;">-Uvh</span> shorewall-4.0.15-<span style="color: #000000;">1</span>.el5.noarch.rpm<br />
rpm <span style="color: #660033;">-Uvh</span> fail2ban-0.8.4-<span style="color: #000000;">23</span>.el5.noarch.rpm</div></div>
<p>Now that they are both installed you will want to set Fail2Ban to start up with the system:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chkconfig <span style="color: #660033;">--add</span> fail2ban<br />
chkconfig fail2ban on<br />
service fail2ban start</div></div>
<p>Congratulations! You now have Shorewall and Fail2Ban installed on your Centos server. Now you may want to configure Fail2Ban if you want to to change the way that it logs or if you need to white-list an IP.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>fail2ban<span style="color: #000000; font-weight: bold;">/</span>jail.conf</div></div>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/KKc0rAps7J0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/gen/install-shorewall-and-fail2ban-on-a-cpanel-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://disstress.net/gen/install-shorewall-and-fail2ban-on-a-cpanel-server</feedburner:origLink></item>
		<item>
		<title>Add Database Users From API</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/X9_PGSE5Rk0/add-database-users-from-api</link>
		<comments>http://disstress.net/mysql/add-database-users-from-api#comments</comments>
		<pubDate>Sat, 27 Nov 2010 20:43:59 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[Accounts]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=92</guid>
		<description><![CDATA[The new update to cPanel 11.28.X has removed the admin&#8217;s ability to directly interact with certain functionality from the command line using standard bash commands. The idea is that cPanel wants admins to interact with the API or do everything through the WHM GUI. I am not about to load up WHM to perform simple [...]]]></description>
			<content:encoded><![CDATA[<p>The new update to cPanel 11.28.X has removed the admin&#8217;s ability to directly interact with certain functionality from the command line using standard bash commands. The idea is that cPanel wants admins to interact with the API or do everything through the WHM GUI. <img class="alignright" title="MySQL Tips" src="http://disstress.net/wp-content/uploads/2010/09/mysql-150x150.png" alt="cPanel tips by disstress" width="150" height="150" /><br />
I am not about to load up WHM to perform simple task, so I have written scripts for the most common CLI tasks to interact with the cPanel XML API. The first one is an update to my dbuser script.</p>
<p>This script will create the following:<br />
MySQL database<br />
MySQL database user<br />
The important part is this: The script will map the database and database user to a cPanel account.<br />
Even more important?: The script will map the database user to the database. This is the only way to perform this final step outside of the cPanel GUI.</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span><br />
<span style="color: #666666; font-style: italic;">#Written By Brendan Clemmer</span><br />
<span style="color: #666666; font-style: italic;">#only way to properly create and assign a MySQL db+user since the cPanel 11.28 debacle</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">UserAgent</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">BEGIN</span> <span style="color: #009900;">&#123;</span><a href="http://perldoc.perl.org/functions/push.html"><span style="color: #000066;">push</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@INC</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;/usr/local/cpanel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$whm</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> Cpanel<span style="color: #339933;">::</span><span style="color: #006600;">Accounting</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">new</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/root/.accesshash'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/open.html"><span style="color: #000066;">open</span></a><span style="color: #009900;">&#40;</span>FILE<span style="color: #339933;">,</span> <span style="color: #0000ff;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@lines</span> <span style="color: #339933;">=</span> <span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/close.html"><span style="color: #000066;">close</span></a><span style="color: #009900;">&#40;</span>FILE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Cpanel<span style="color: #339933;">::</span><span style="color: #006600;">Accounting</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Term<span style="color: #339933;">::</span><span style="color: #006600;">ANSIColor</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Cwd<span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dir</span> <span style="color: #339933;">=</span> getcwd<span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$UN</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`echo $dir|cut -d/ -f3`</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$UN</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s//g</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;@lines&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$hash</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s//g</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$auth</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;WHM root:&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$hash</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>host<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;localhost&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>user<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>accesshash<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$hash</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$#ARGV</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'green'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;usage: perl &amp;lt;(GET yourscriptdomain.com/dbuser) dbname mysqluser password<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$UN</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># cPanel username</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBNAME</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># database name</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBUSER</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># database username</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBPASS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># database password</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$module</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'Mysql'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBUHmodule</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'adduser'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBAUHmodule</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'adduserdb'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBAUHperms</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'alter temporary routine create delete drop select insert update references index lock all'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBHmodule</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'adddb'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DBUHmodule</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'adduser'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$checkpath</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/var/cpanel/users/'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$UN</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>e <span style="color: #0000ff;">$checkpath</span> <span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span> <span style="color: #339933;">-</span>f <span style="color: #0000ff;">$checkpath</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'red'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;You need to run this from the user's home. Try Again.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$DBNAME</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/\_/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'red'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Don't append the cPanel username to the database name. Try again.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$DBUSER</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/\_/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'red'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Don't append the cPanel username to the MySQL username. Try again.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$length</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'7'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$checklength</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/length.html"><span style="color: #000066;">length</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$DBUSER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$checklength</span> <span style="color: #339933;">&amp;</span><span style="color: #b1b100;">lt</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'red'</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Your MySQL username is too long. There are limits. Try again.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>showversion<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>error<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;There was an error while processing your request: Cpanel::Accounting returned [$whm-&amp;gt;{error}]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;cPanel version: $version&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbhack</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>api1<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$user</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$module</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBHmodule</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBNAME</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>error<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;There was an error while processing your request: Cpanel::Accounting returned [$whm-&amp;gt;{error}]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbuserhack</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>api1<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$user</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$module</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBUHmodule</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBUSER</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBPASS</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>error<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;There was an error while processing your request: Cpanel::Accounting returned [$whm-&amp;gt;{error}]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbadduserhack</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span>api1<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$user</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$module</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBAUHmodule</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBNAME</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBUSER</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$DBAUHperms</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$whm</span><span style="color: #339933;">-&amp;</span><span style="color: #b1b100;">gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#123;</span>error<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;There was an error while processing your request: Cpanel::Accounting returned [$whm-&amp;gt;{error}]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'green'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;SUCCESS::We created the user $user<span style="color: #000099; font-weight: bold;">\_</span>$DBUSER on $user<span style="color: #000099; font-weight: bold;">\_</span>$DBNAME using the password $DBPASS&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> color <span style="color: #ff0000;">'reset'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span></div></div>
<p><span style="color: #ff0000;"><strong>EDIT:</strong> </span>cPanel has made another change. They have decided to remove the functionality of the cPanel Accounting perl module in 11.28.64 making this script not work properly. I do have an update, but will not be posting it here. If you are interested maybe we can work something out $$, contact me.</p>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/X9_PGSE5Rk0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/mysql/add-database-users-from-api/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://disstress.net/mysql/add-database-users-from-api</feedburner:origLink></item>
		<item>
		<title>Fixing a Broken Perl Installation In cPanel</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/C1MaJPUoLRQ/fixing-broken-perl</link>
		<comments>http://disstress.net/perl-5/fixing-broken-perl#comments</comments>
		<pubDate>Sat, 27 Nov 2010 19:43:49 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=82</guid>
		<description><![CDATA[Got broken perl? If you see messages like this you do: Can't locate *.pm in @INC (@INC contains: /scripts /usr/local/cpanel /usr/lib/perl5/5.8.1/i686-linux /usr/lib/perl5/5.8.1 /usr/lib/perl5/site_perl/5.8.1/i686-linux /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at /scripts/cPScript/*.pm line 10. BEGIN failed--compilation aborted at /scripts/*somescript* I see this happen frequently due to botched installations or incomplete upgrades. You will see this when trying to [...]]]></description>
			<content:encoded><![CDATA[<p>Got broken perl? If you see messages like this you do:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Can't locate *.pm in @INC (@INC contains: /scripts /usr/local/cpanel /usr/lib/perl5/5.8.1/i686-linux /usr/lib/perl5/5.8.1 /usr/lib/perl5/site_perl/5.8.1/i686-linux /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at /scripts/cPScript/*.pm line 10.<br />
BEGIN failed--compilation aborted at /scripts/*somescript*</div></div>
<p>I see this happen frequently due to botched installations or incomplete upgrades. You will see this when trying to run anything out of /scripts/, likely you won&#8217;t even be able to run /scripts/upcp due to borked perl modules. </p>
<p>The fix is pretty simple, but can take awhile.<br />
The first thing you want to do is cd to a directory to work with the installation (I use /usr/src). You then want to grab the latest perl installer from this link:  <a href="http://httpupdate.cpanel.net/">http://httpupdate.cpanel.net/</a><br />
Next you untar the package, cd into the installation directory and install.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src &nbsp; <br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>httpupdate.cpanel.net<span style="color: #000000; font-weight: bold;">/</span>perl588installer.tar.gz<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz perl588installer.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> &nbsp;perl588installer.tar.gz<br />
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span><br />
<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>upcp <span style="color: #660033;">--force</span></div></div>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/C1MaJPUoLRQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/perl-5/fixing-broken-perl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://disstress.net/perl-5/fixing-broken-perl</feedburner:origLink></item>
		<item>
		<title>Install lwp-request aliases</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/Qm6Pzgiku1U/perl-get-alias-lwp-module</link>
		<comments>http://disstress.net/perl-5/perl-get-alias-lwp-module#comments</comments>
		<pubDate>Fri, 05 Nov 2010 02:09:59 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[GET alias]]></category>
		<category><![CDATA[libwww]]></category>
		<category><![CDATA[LWP]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=76</guid>
		<description><![CDATA[I ran into an issue with a new cPanel install not allowing me to install the lwp-request aliases: GET, POST, HEAD. There are some suggestions out there that seem to imply that the following code will work: /scripts/realperlinstaller --force lwp Well, in most cases this will NOT work. If you want a fool-proof way to [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an issue with a new cPanel install not allowing me to install the lwp-request aliases: GET, POST, HEAD.<br />
There are some suggestions out there that seem to imply that the following code will work:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>realperlinstaller <span style="color: #660033;">--force</span> lwp</div></div>
<p>Well, in most cases this will NOT work. If you want a fool-proof way to install the perl lwp-request aliases then follow these steps:<br />
First you will need to download the latest libwww from cpan.org</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>search.cpan.org<span style="color: #000000; font-weight: bold;">/</span>CPAN<span style="color: #000000; font-weight: bold;">/</span>authors<span style="color: #000000; font-weight: bold;">/</span>id<span style="color: #000000; font-weight: bold;">/</span>G<span style="color: #000000; font-weight: bold;">/</span>GA<span style="color: #000000; font-weight: bold;">/</span>GAAS<span style="color: #000000; font-weight: bold;">/</span>libwww-perl-<span style="color: #000000;">5.837</span>.tar.gz</div></div>
<p>You will need to untar and gunzip this file  and cd into that directory like so:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz libwww-perl-<span style="color: #000000;">5.837</span>.tar.gz ; <span style="color: #7a0874; font-weight: bold;">cd</span> libwww-perl-<span style="color: #000000;">5.837</span></div></div>
<p>Once inside of that directory you will need to tell libwww to set up the aliases and install the module:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">perl</span> Makefile.PL <span style="color: #660033;">--aliases</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Now you have the libwww (LWP) aliases installed on your system. You can use the GET, POST, and HEAD aliaes to the lwp-request command. </p>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/Qm6Pzgiku1U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/perl-5/perl-get-alias-lwp-module/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://disstress.net/perl-5/perl-get-alias-lwp-module</feedburner:origLink></item>
		<item>
		<title>MD5 and SHA1 Hash Generator</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/bB0MBtkZSxQ/md5-and-sha1-hash-generator</link>
		<comments>http://disstress.net/gen/md5-and-sha1-hash-generator#comments</comments>
		<pubDate>Thu, 04 Nov 2010 00:47:15 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sha1]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=68</guid>
		<description><![CDATA[There comes a time in everyone&#8217;s life where they need to generate a MD5 or SHA1 hash of a string. Well, maybe not everyone, but definitely sysadmins and webmasters. I have set up a website for just this! It is a free to use service for generating a MD5 and SHA1 hash from a string. [...]]]></description>
			<content:encoded><![CDATA[<p>There comes a time in everyone&#8217;s life where they need to generate a MD5 or SHA1 hash of a string. Well, maybe not everyone, but definitely sysadmins and webmasters.  I have set up a website for just this! It is a free to use service for generating a MD5 and SHA1 hash from a string. </p>
<p>This is a handy tool for changing your WordPress Admin password from the database in case you are unable to access the dashboard from a browser due to hacking or data loss. </p>
<p>You can visit the site here: <a href="http://md5.me">md5.me</a></p>
<p>Of course if you have access to a terminal you can just run the following:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;apple&quot;</span><span style="color: #000000; font-weight: bold;">|</span>md5sum<br />
1f3870be274f6c49b3e31a0c6728957f &nbsp;-</div></div>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/bB0MBtkZSxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/gen/md5-and-sha1-hash-generator/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://disstress.net/gen/md5-and-sha1-hash-generator</feedburner:origLink></item>
		<item>
		<title>Add Database Users From CLI</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/7-UkXv77tG0/add-mysql-database-users-from-the-command-line</link>
		<comments>http://disstress.net/mysql/add-mysql-database-users-from-the-command-line#comments</comments>
		<pubDate>Sat, 11 Sep 2010 04:02:51 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=43</guid>
		<description><![CDATA[Ever try to add a database user from the command line and it doesn&#8217;t show up in a user&#8217;s cPanel account? The following bit of code can be used to create a database, database user, and assign the same privileges that would have been assigned if the user were created in the cPanel GUI. Once [...]]]></description>
			<content:encoded><![CDATA[<p>Ever try to add a database user from the command line and it doesn&#8217;t show up in a user&#8217;s cPanel account?</p>
<p>The following bit of code can be used to create a database, database user, and assign the same privileges that would have been assigned if the user were created in the cPanel GUI. Once the script has been run the output will let you know the name of the database, database user, and the password assigned. <img class="alignright" title="MySQL Tips" src="http://disstress.net/wp-content/uploads/2010/09/mysql-150x150.png" alt="cPanel tips by disstress" width="150" height="150" /></p>
<p>If you run the script without any command line arguments then the usage instructions will be printed on screen.<br />
The basic instructions are to run the script from inside the users account ( /home/username/* ) and  supply the database name, database username, and password. Do not add the cPanel username or the script will error out.</p>
<p><span style="color: #ff0000;">EDIT:: This is now outdated with the 11.28 Patch. </span><a href="http://disstress.net/mysql/add-database-users-from-api">Please see this new post for an updated script.</a></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">#dbuser.sh</span><br />
<span style="color: #666666; font-style: italic;"># Database and database user creation script</span><br />
<span style="color: #666666; font-style: italic;"># by Brendan Clemmer</span><br />
<span style="color: #666666; font-style: italic;"># This script will create a database if it does not exist, create a user, and assign that user to the database.</span></div></div>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">UN</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span> -f3<span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #007800;">EXPECTED_ARGS</span>=<span style="color: #000000;">3</span><br />
<span style="color: #007800;">E_BADARGS</span>=<span style="color: #000000;">65</span><br />
<span style="color: #007800;">SQLBASE</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">SQLUSER</span>=<span style="color: #007800;">$2</span><br />
<span style="color: #007800;">SQLPASS</span>=<span style="color: #007800;">$3</span><br />
<br />
user_check<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cpanel<span style="color: #000000; font-weight: bold;">/</span>users<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$UN</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\E[0;31mScript dying, you need to run this from the user's home&quot;</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
create_database<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SQLBASE</span> == <span style="color: #ff0000;">&quot;<span style="color: #007800;">$UN</span>&quot;</span>_<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\E[0;31mOnly enter the database name, not the cPanel username prefix, try again. &quot;</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
mysql <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;create database if not exists <span style="color: #007800;">${UN}</span>_<span style="color: #007800;">${SQLBASE}</span>&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
create_user<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SQLUSER</span> == <span style="color: #ff0000;">&quot;<span style="color: #007800;">$UN</span>&quot;</span>_<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\E[0;31mOnly enter the database username, not the cPanel username prefix, try again. &quot;</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
mysql <span style="color: #660033;">-Be</span> <span style="color: #ff0000;">&quot;GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE ON \<span style="color: #780078;">`&quot;$UN&quot;\\_&quot;$SQLBASE&quot;\`</span>.* TO '&quot;</span><span style="color: #007800;">$UN</span><span style="color: #ff0000;">&quot;_&quot;</span><span style="color: #007800;">$SQLUSER</span><span style="color: #ff0000;">&quot;'@'localhost' IDENTIFIED BY '<span style="color: #007800;">$SQLPASS</span>';FLUSH PRIVILEGES&quot;</span><br />
<span style="color: #007800;">status</span>=<span style="color: #007800;">$?</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
quit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #007800;">$status</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;\E[0;32mSUCCESS::We created the user <span style="color: #007800;">${UN}</span>_<span style="color: #007800;">${SQLUSER}</span> on <span style="color: #007800;">${UN}</span>_<span style="color: #007800;">${SQLBASE}</span> with the password <span style="color: #007800;">$SQLPASS</span>.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\E[0;31mHoly CARP! you messed up! MySQL error listed above.&quot;</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #007800;">$EXPECTED_ARGS</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\E[0;31mUsage: &nbsp;./dbuser.sh database user dbpass'</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\E[0;32mRun this script from the users home directory.'</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\E[0;32mThe script will place the username and underscore prefix'</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\E[0;32min the appropriate place for the db name and user name.'</span>;tput sgr0<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$E_BADARGS</span><br />
<span style="color: #000000; font-weight: bold;">fi</span></div></div>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">user_check<br />
create_database<br />
create_user<br />
quit</div></div>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/7-UkXv77tG0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/mysql/add-mysql-database-users-from-the-command-line/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://disstress.net/mysql/add-mysql-database-users-from-the-command-line</feedburner:origLink></item>
		<item>
		<title>cPanel tricks</title>
		<link>http://feedproxy.google.com/~r/disstress/lDPK/~3/Jrr1nJ9GrTg/cpanel-tricks</link>
		<comments>http://disstress.net/gen/cpanel-tricks#comments</comments>
		<pubDate>Wed, 05 Aug 2009 17:09:50 +0000</pubDate>
		<dc:creator>Disstress</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://disstress.net/?p=1</guid>
		<description><![CDATA[I have spent countless hours scouring the internets looking for tips and tricks on doing the needful in cPanel.  Everything I find tends to be, well wrong. I&#8217;ll back up and talk about what.. I&#8217;m talking.. about. Do it from the command line! WHM/cPanel are great in that they allow you to perform most of [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent countless hours scouring the internets looking for tips and tricks on doing the needful in cPanel.  Everything I find tends to be, well wrong. I&#8217;ll back up and talk about what.. I&#8217;m talking.. about. Do it from the command line! WHM/cPanel are great in that they allow you to perform most of the server management tasks from a GUI. This makes Linux server administration(?) more assessable to people that wouldn&#8217;t normally get involved in it.</p>
<p>Fact of the matter is, it is faster to do anything from the command line. If you want to package an account for a backup you have to type `/scripts/pkgacct username` and it&#8217;s done. From inside the GUI you have to, well do more. I don&#8217;t feel like typing out an instructional document on clicking your way through cPanel to get a backup made.</p>
<p>I am going to provide a bunch of tutorials that get the job done from beginning to end. I will also provide some nifty one liners so you can surf /b/ and not worry. </p>
<img src="http://feeds.feedburner.com/~r/disstress/lDPK/~4/Jrr1nJ9GrTg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://disstress.net/gen/cpanel-tricks/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://disstress.net/gen/cpanel-tricks</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.497 seconds. --><!-- Cached page generated by WP-Super-Cache on 2011-11-01 14:41:54 -->

