All posts by dropdeaddick

cPanel AppConfig for Fantastico

A simple script to populate the configuration file and register Fantastico with the cPanel AppConfig system.

#!/bin/sh

cat > /var/cpanel/apps/addon_fantastico.conf <<EOF
name=addon_fantastico
service=whostmgr
url=/cgi/addon_fantastico.cgi
url2=/cgi/fantastico/index.php
url3=/cgi/fantastico/fantastico.php
user=root
acls=any
displayname=addon_fantastico
EOF

/usr/local/cpanel/bin/register_appconfig /var/cpanel/apps/addon_fantastico.conf

WordPress Mass Update Script

I recently came across an excellent bash to mass update WordPress installs, which was written by Liz Quilty. This script works well, but unfortunately it did require manually setting paths if you are not using /var/www for your installs. Due to the large and varying number of servers I needed this for, I decided to make some changes so the script is slightly more automated and eliminate the need for the end user to edit the script.

These changes include:
– Added –path option to allow script to be ran on a specific path only.
e.g wordpress wpupgrade.sh –path /home/user
– Added a function to check for the existence of /var/www and /home, also validates –path option to insure custom path exists.
– Added a function to check the latest WordPress version via wordpress.org api.
– Script is now broke down into into the following functions.
usercheck
path
version
main
help

Here is my modified version.

wget http://dropdeaddick.com/files/wordpress-upgradeDD.sh
bash wordpress-upgradeDD.sh

Here is the original.

wget http://b.ri.mu/files/wordpress-upgrade.sh
bash wordpress-upgrade.sh

Update Timthumb for All cPanel Users

A simple script to check all cPanel user accounts for timthumb.php(WordPress) and update them to the latest version if needed. Also checks for timthumb being used as thumb.php. Uses check to insure thumb.php is not affected for scripts like joomla, which does not use timthumb.

#! /bin/bash
# Detects and updates timthumb.php to latest version for all cPanel users.
# dropdeaddick.com

latest=`lynx -source http://timthumb.googlecode.com/svn/trunk/timthumb.php |grep "define ('VERSION'" $file |cut -f4 -d"'"`
if [ -z "$latest" ]; then
echo "could not get latest timthumb release, aborting!"
exit 1
fi
for user in `awk -F':' '{ if ($3 > 499) print $0 }' /etc/passwd | grep home | cut -d':' -f1`; do
for file in `find /home*/$user/public_html/ -type f \( -name 'thumb.php' -o -name 'timthumb.php' \) 2>/dev/null | tr ' ' '%'`; do
file=`echo $file | tr '%' ' '`
check=`grep -c "code.google.com/p/timthumb" "$file"`
if [ -z "$check" ]; then
break
fi
if [ "$check" -gt "0" ]; then
version=`grep "define ('VERSION'" "$file" |cut -f4 -d"'"`
if [ "$version" != "$latest" ]; then
echo -e "\e[1;31mWARNING version $version\e[0m updating $file!"
# rm -f $file #delete current file before replacing.
wget -nv -t3 -T3 http://timthumb.googlecode.com/svn/trunk/timthumb.php -O "$file"
chown $user: "$file"
else
echo -e "\e[1;32mOK version $version\e[0m skipping $file"
fi
fi
done
done

Phillips 50″ Plasma – No Power

Last night my TV decided to punish me right in the middle of watching Family Guy, by shutting itself off and refusing to come back on. After replacing the power cord, resetting the surge protector, and a lot of foul language, I finally gave up for the night. 

After working for a few hours today, I then decided to yank the back off and dig into the issue or at the least blow something up. With my trusty multimeter in hand I was able to quickly trace it down to a blown fuse. Specifically, an 8 amp 250V slow blow ceramic fuse, which I was unable to find around town and had to order from amazon.com. 

All I can do now is wait and hope that the fuse is the only issue, however, I doubt I am that lucky, after all there is no telling what caused the fuse to blow. I also came across a few articles that this model line has issues with blowing caps and I can only assume that I will have to break out the soldering iron and tackle that too.

Until then, here is nice view of what I have to look at this weekend.

image
Philips 50 plasma back panel removed

Robot Rover

I recently picked up the basic DFRobot Rover kit from robotshop.com, which finally arrived today after what seemed like an eternity on back order. I also picked up a Bluetooth kit and a couple of sensors to play with. I’m still waiting for their new wheel encoders for this kit and a couple of 6V motors, but I can get started without them. Oh well, it just gives me a reason to disassemble it all later to add the new parts.

I started out trying to gather parts to build something similar, but decided to go with their kit and save some time(something I don’t always have a lot of). Maybe later, when I feel more comfortable with arduino, then I will move onto building something from scratch.

parts

The only thing I am missing at the moment is a mini USB cable for the main board. To be truthful, I am not really missing the cable, so much as I need to untangle it from the magical ball of USB cables that I have stuffed in a drawer.

 

 

 

Update on February 22, 2012
I have run into a couple of small issues that well are more an annoyance than anything else. The first is that I purchased an inexpensive bluetooth dongle that was DOA. Then the dagu mini pan and tilt I purchased, is not going to fit to the rover’s mount due to the front idler axle being in its way. This was simply an oversight on my part for not giving it a once over. I will most likely create a mount for this if I use it, or look at modifying how the idler is mounted.

I also dug up some older code from cellbots for this rover, but it is outdated and will need to be updated to work with the newer IDE.

Update on February 24, 2012
I’m Still waiting on my replacement bluetooth dongle but was able to connect to the rover via terminal using the SENA BTerm app on DroidX. This worked well and allowed me to control it with WASD keys from the phone using the sample code provided by robotshop. Please note that if you want to do something silly like I did – painting the tamiya wheels – then make sure you assemble them with the end caps first. Since I didn’t add the end caps first, I had to clean up the paint around the caps that was causing the idler wheels to stick and roll as a solid axle.

Kayako API: How to Post a Ticket

A basic PHP example of how to post a new ticket via the Kayako v4 Rest API

<?php 

$apiUrl = "https://support.domain.com/api/index.php?e=/Tickets/Ticket";
$apiKey = "78db96b0-1t7c-aea4-bd51-7xf39d50cdd6";
$salt = mt_rand();
$secretKey = "ZjBiZS0N2MtMzM3MTkyNTkxMjdiZWZkMGIjE3YmJiMGUtNmY0MC0yNWU0LWY5x6DktN1NzE0LWMxMGYyZDIzOThmYjY5YT7m";
$signature = base64_encode(hash_hmac('sha256',$salt,$secretKey,true));

$subject = "Test Ticket";
$fullname = "DropDeadDick";
$email = "test@domain.com";
$contents = "Test test test test";
$departmentid = "1";
$ticketstatusid = "1";
$ticketpriorityid = "1";
$tickettypeid = "1";
$staffid = "1";

$post_data = array('subject' => $subject,
 'fullname' => $fullname,
 'email' => $email,
 'contents' => $contents,
 'departmentid' => $departmentid,
 'ticketstatusid' => $ticketstatusid,
 'ticketpriorityid' => $ticketpriorityid,
 'tickettypeid' => $tickettypeid,
 'staffid' => $staffid, 
 'apikey' => $apiKey, 
 'salt' => $salt, 
 'signature' => $signature);

$post_data = http_build_query($post_data, '', '&');

$curl = curl_init($apiUrl); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, $apiUrl);
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);

$response = curl_exec($curl);  
curl_close($curl);

$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
echo "<pre>".print_r($xml, true)."</pre>";
 ?>

cPanel – Fix Ownership of /home/user

I recently had an issue with incorrect ownership of all files under /home/user/ due to mismatched UIDs after a cPanel server restore. The following script took care of this in no time.

echo -e "Checking ownership of /home/user \n"
for i in `ls /var/cpanel/users/`
do
if [ "$i" != "root" ]; then
chown -R $i:$i /home/$i
chown $i:nobody /home/$i/public_html /home/$i/.htpasswds
chown $i:mail /home/$i/etc /home/$i/etc/*/shadow /home/$i/etc/*/passwd
echo $i
fi
done

cPanel Webmail Direct Login Script

A simple and configurable script for direct login to the cPanel webmail applications(Horde, SquirrelMail, RoundCube).

<?php
// Modified version of the standard cPanel login page to allow direct login to a specific webmail application.
// Must set $host , $login_path , and $mail_app, defaults to cPanel proxy subdomains and SquirrelMail
$host = 'example.com';
// Uncomment one of the following to set login URL type

View full script