It has been too long since my website has been functional! On that note, I’ve decided to postpone my obsession with making things look “just right”.
“If ‘content is king’ then the designer is like the King’s tailor – there to make the King look fabulous without taking any of the limelight for themselves.”
There was a great article written by Colin James Firth called “Content is King”. In that article touches on the topic of having an “An Unhealthy Obsession With Aesthetics”; I myself having had this particular problem for quite some time now – have decided to do something about it!
So my goal is to take this digital nest egg of mine and make progress on the aesthetics gradually; then pump out as much content and brain dumps as I can. So stay tuned! I should be updating very frequently! Until next time! Please contact me if you have any comments or questions. My information is at the top of the page.
Bird bird bird, the bird is the word!
Posted by: Sterling Hamilton on:
I have updated my Twitter profile! Feel free to check it out.
Basically I created a background and tweeked the design colors. It’s nothing special.
Check back soon for more updates!
Using Color Text in Bash Scripts
Posted by: Sterling Hamilton on:
!/bin/bash
# Example usage:
# echo ${RedF}This text will be red!${Reset}
# echo ${BlueF}{$BoldOn}This will be blue and bold!${BoldOff}
# and this is just blue!${Reset}
# echo ${RedB}${BlackF}This has a red background
# and black font!${Reset}and everything after the reset
# is normal text!
Colors() {
Escape="\033";
BlackF="${Escape}[30m"; RedF="${Escape}[31m"; GreenF="${Escape}[32m";
YellowF="${Escape}[33m"; BlueF="${Escape}[34m"; Purplef="${Escape}[35m";
CyanF="${Escape}[36m"; WhiteF="${Escape}[37m";
BlackB="${Escape}[40m"; RedB="${Escape}[41m"; GreenB="${Escape}[42m";
YellowB="${Escape}[43m"; BlueB="${Escape}[44m"; PurpleB="${Escape}[45m";
CyanB="${Escape}[46m"; WhiteB="${Escape}[47m";
BoldOn="${Escape}[1m"; BoldOff="${Escape}[22m";
ItalicsOn="${Escape}[3m"; ItalicsOff="${Escape}[23m";
UnderlineOn="${Escape}[4m"; UnderlineOff="${Escape}[24m";
BlinkOn="${Escape}[5m"; BlinkOff="${Escape}[25m";
InvertOn="${Escape}[7m"; InvertOff="${Escape}[27m";
Reset="${Escape}[0m";
}
Plesk and the vhost.conf file!
Posted by: Sterling Hamilton on:
So…you’re running Plesk?
Good for you!
Plesk automatically updates httpd.include for each domain, making changes to this file only temporary. You don’t want to use this file if you need to make changes to Apache’s config on the fly, such as php’s open_basedir values per domain.
Instead you will want to use a vhost.conf file. This file will be placed inside your domain’s conf directory, usually found at “/var/www/vhosts/mysite.com/conf”.
Create a file called vhost.conf in whatever editor you prefer.
Note: If you have a site that has an SSL and you need to have access to directories outside the httpsdocs directory you will need to do the same thing but instead of “vhost.conf” it’s “vhost_ssl.conf”
You can now put in any Apache configuration options like you would into httpd.include.
Now if you’ve been using Plesk for a bit you know that sites are generally kept under the httpdocs directory.
But let’s say you’re installing some online software…like Sugar CRM, Joomla or ELGG.
These packages need access to directories outside of the httpdocs directory.
To solve this issue properly in Plesk – you’re supposed to create a vhost.conf file in the conf directory under your site.
Let’s say you did this:
cd /var/www/vhosts/mysite.com
mkdir data
chown myuser:psaserv data
In the site directory you could add the following:
After running that there is no need to restart Apache or any other service. Your changes should have taken effect already.
Bash Script to Post to Twitter
Posted by: Sterling Hamilton on:
Here is a quick/easy way to post to twitter from the command line interface.
#!/bin/bash
# Login information.
USERNAME="email address"
PASSWORD="password"
URL="http://twitter.com/statuses/update.xml"
# Check message length.
if [ ! -n "$1" ]; then
echo "Message not long enough"
exit
fi
# Check message length again.
message="$@"
maxlen=140;
len='echo $'
if [ $len -gt $maxlen ]; then
echo "Your message was longer than 140 characters...";
fi
# Post to Twitter.
result=`curl -u $USERNAME:$PASSWORD -d
status="$message" $URL`
Put the script in /usr/local/bin/
Then it is as easy as:
user@computername:~$ twitter Your Message Here
Pimp Slapping Your Domain Name
Posted by: Sterling Hamilton on:
Alright – so let’s bust out the baby powder and get ready to put our Domains in their place!
Anyone got a website? *raises hand*
Anyone have an alias for said website, such as mywebsite.com and mywebsite.net? *keeps hand raised*
Anyone feel like letting people stay at the non www versions of these domains or having them stay at .net? *puts hand down*
Alright then!
Let’s begin!
So basically here’s my situation.
I want to have my domain “sterlinghamilton.com” to be consistent.
So if someone goes to http://sterlinghamilton.com it should change to http://www.sterlinghamilton.com - and if they go to either variation of .net it should go to the .com version!
Basically…I want my domain rolling on dubs! *laughs to self*
So how would I do that?
Unfortunately backhanding is not the solution to everything. (Although it does solve a myriad of problems!)
I think for this issue I will use an .htaccess file!
Here’s what I am thinking (it’s short and sweet and later if I feel like making it more efficient I will):
The first line is allowing us to modify the URL.
The following sets are the rules I wanted to implement.
If it has a .com but it isn’t rolling on dubs (www) then put dubs on it!
If it has a .net but it isn’t rolling on dubs (www) then put dubs on it!
If it has a .net and it has dubs (www), then make it .com
Simple right?
That should do it. *quickly tests it so he doesn’t look stupid*
Yes – it works fine.
The down side to that method is it will only take the domain and set it to WWW - it won't change the TLD (.com or .net)
That is all!
Good day!
X-Cart Security Issue
Posted by: Sterling Hamilton on:
Ugh…I hate security holes.
Got notified of one for X-Cart…had to fix it:
During internal security audit a critical security issue has been detected in X-Cart. The issue makes the software vulnerable to attackers who wish to gain access to the server file system. The solution is to remove an affected file.
SEVERITY
Critical
IMPACT
A malicious user can execute his own shell commands and, as a result, gain access to the server file system.
AFFECTED VERSIONS
X-Cart versions from 4.1.0 to 4.1.11. All X-Cart customers who are using these versions are encouraged to apply the fix described below.
SOLUTION
Delete the ‘<xcart_dir>/payment/cc_basia.php’ file.
This file refers to an outdated integration of ‘Bank of Asia’ payment gateway, so its deletion will not cause any problems and will not affect your stores.
The ‘<xcart_dir>’ text means the server directory in which your X-Cart is installed.
You can delete this file using FTP, SSH or the hosting control panel file manager.
Now THAT’S a good time.
Here’s how I dealt with that:
Linux command:
locate "/payment/cc_basia.php" > BadFiles
Then I created a script:
#!/bin/sh
echo "enter file name"
read fname exec<$fname
while read line
do
echo "rm $";
rm $
done
Then ran the following commands:
sh DeleteFiles.sh
enter file name
BadFiles
Bad files are gone!
Woo – done in less than a minute. *blows smoke off fingers*
Finding All Domains In Ensim
Posted by: Sterling Hamilton on:
Nifty thing to know.
There is a file in Ensim that keeps track of all domains (aliases included).
It’s generally stored at:
/etc/virtualhosting/mappings/domainmap
That’s nifty if you need to keep track of what’s on the server…or check domain statuses, expiration dates…etc.
…
Oh I’m sorry…did I hear someone in the audience say they wanted more?
What’s that you say? You want to grab all the domains from that list? Just the domains? Not the site numbers or anything?
UGH. Fine.
You should be root when running this or you will run into issues.
Enjoy!
* Note: the code above may not be showing right… that's all supposed to be on one line.
Plesk Bash Script to turn off Mail Service!
Posted by: Sterling Hamilton on:
So we have our own mail service here at Exyst.
Due to that fact - we do not use Plesk’s mail service.
If that mail service is on when we create a site through Plesk, then mail sent by the server isn't handled properly.
This would include contact forms and anything that a Web Application would shoot out.
Is that a big issue? Yeah…it is.
So I wrote a script that finds all sites that have the service on - and then it turns it off.
Enjoy:
#!/bin/bash
SiteList=`egrep 'Server(Name)' /var/www/vhosts/*/conf/httpd.include|awk
'{print $3}'
|grep -v www.*|grep -v '^.*\..*\..*$'|sed 's/:80//'|sed 's/:443//'|
sort -u`;
for Site in $SiteList
do
Result=`/usr/local/psa/bin/domain -i $Site | grep 'Mail service' |
awk '{print $3}'`;
if [ $Result == On ]; then
Command=`/usr/local/psa/bin/domain -u $Site -mail_service
false`
echo "Turning Off Mail Service: $Site";
fi
done
Zimbra Mail Quota Bash Script
Posted by: Sterling Hamilton on:
In an effort to automate some of my daily tasks I decided to write this mail quota monitoring script.
It gets all quota information, processes it, then Twitters the information AND sends an e-mail.
The Twitter information is vague so security isn’t compromised, but the e-mail has the details.
This way I can get a heads up of impending doom on certain mail accounts!
Enjoy!
#!/bin/bash
# Get the e-mail ready.
Email="esupport@exyst.com";
Subject="Xync: Account(s) Exceeding Quota(s)."
Message="/tmp/message.txt"
# This starts the message fresh.
echo "Summary:" > $Message
# Generate data about all mail boxes.
MailBoxQuotaData=`/opt/zimbra/bin/zmprov gqu localhost`;
# Set counters.
Counter=0;
AccountCounter=0
# Sort through the data.
for Line in $MailBoxQuotaData
do
Counter=`expr $Counter + 1`;
case "$Counter" in
"1" )
Account=$Line
;;
"2" )
Limit=$Line
;;
"3" )
Used=$Line
# If the limit is 0 then it
# has no limit.
if [ "$Limit" -ne "0" ]; then
# This produces a whole number we can work
# with.
Percent=$(($Used*100/$Limit))
# Notify us if a limit is over 85%.
if [ "$Percent" -ge "85" ]; then
echo "Account: $Account" >>
$Message
echo "Quota Percentage: $Percent"
>> $Message
AccountCounter=`expr
$AccountCounter + 1`
fi
fi
Counter=0
;;
esac
done
# Send Twitter message.
nice -n 19 /exyst/Twitter.sh "Xync: ${AccountCounter} Accounts Over 85%!"
# Send e=mail.
nice -n 19 /bin/mail -s "$Subject" "$Email" < $Message