Linux CP command that creates new directories as needed

I am making note of this here as I had to tweak what I had found after a fairly long Google search.

This is a custom shell script function I added to my .bashrc to provide the copying of files with the ability to create new directories as needed.
I needed to merge several websites and copy image assets from one site into the other website.

function cpmkdir()
 {
 if [[ -z "$1" || -z "$2" ]]; then
 echo "Usage: cpmkdir SOURCE... DIRECTORY"
 return 1;
 fi
 mkdir -p $(dirname "$2")
 cp -ur "$1" "$2"
 }

This will try to create a directory based on the directory tree you are putting your file.
It will then copy that file in, not replacing it if it’s already there & newer.

Based on: http://www.linuxquestions.org/questions/linux-software-2/cp-create-any-directories-necessary-to-open-the-destination-path-920501/#post4568625.

Bugzilla Install on CentOS under Plesk

I managed to get bugzilla installed and to work, but it was an all-day affair. It appears other people had problems as well. So I am documenting what I needed to do to make it work in the hopes that it’s useful to other people and potentially myself in the future.

Environment:

  • Plesk 10.4.4
  • CentOS release 5.6 (Final)
  • Bugzilla 4.2.3
  • Site is a subdomain created in Plesk & given cgi-bin permissions

 

Issue 1

Raw code displayed on screen.

Creating a .htaccess file and adding the following to it resolved this issue.

AddHandler cgi-script .cgi
Options +ExecCGI
DirectoryIndex index.cgi

However, that created a new problem.

Issue 2

500 Internal Server Error

This problem is a bit more difficult to track down. For me, it turned out to be a suexec issue.

After much google-fu I found http://simon.hu.free.fr/?p=215 which allowed me to fix the problem.

Looking at /etc/httpd/logs/suexec.log I see stuff like:

[2012-10-24 17:25:29]: uid: (10023/domain) gid: (2452/2452) cmd: index.cgi
[2012-10-24 17:25:29]: target uid/gid (10023/2452 or 2451) mismatch with directory (10023/2452) or program (10023/2451)

I did the suggested:

cp -arf /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec

which may or may not have been necessary. I was still seeing ‘Premature end of script headers:‘ in the apache/php error log.

The following tidbit turned out to be the final fix.

The script itself must be owned by domain FTP user but group must be ‘psacln’:

Making the files have the right ownership & group got everything working correctly.

chown -R ftpusername:psacln ./*

A busy week

image

It’s been a busy week this week. My daughter was born on Tuesday. She’s healthy. More about her coming soon. I ought to be able to write a blog post about that experience soon.

Friends and family have been calling and visiting. A good buddy actually just left and my parents are here too – already in bed. I am the last one up.

My parent’s and I visited the house I am trying to buy. Short sales suck for how long they can take. It’s looking good for the end of the month to move forward. I may be moving come June.

You may have noticed a totally new look for this blog. The migration to wordpress is coming along. I may need to recatagorize some posts as WP has both categories and tags. I used an auto-tagging tool to tag all the previous 500+ blog posts with less the stellar results. So I will need to manually tag high traffic pages soon so the related posts plugin presents better related pages.

I have to work tommorrow. Migrating websites to a new server. Best done on a slow day traffic wise. Sucks to work on a day off, but it keeps me in a job.

I am writing this post on my android phone which is relatively painless. There is an app for WordPress. I miss the live spellcheck, which sucks as I have lousy spelling. I will need to make a point of coming back and editing for spelling tommorrow. I put in a mobile template for the blog that seems to work well. .

My desk at work.

When I started work, I asked about getting a drafting table to use as a desk. They ordered one up for me!

It’s not a real drafting table, but it’s actually better for what I am using it for.
 The only drawback is that it wasn’t tall enough that I could comfortabley use it standing up, as I had intended.

 Well Dad and I fiddle futzed around for a month or more on ideas on how to easily jack this desk up. I bought some metric bolts that fit the desk, intending on making some legs for it, but didn’t get a chance to make them. Wouldn’t you know, FreeCycle to the rescue! Somebody posted 8 inch bed legs, never been used. I picked them up, and SWEET, they are perfect. Well, almost, they are SAE threaded, but the right size. We happened to have the right size metric die at the office, so I re-threaded the bolts.

 I stuck them onto the bottom of the desk.

 Oh, it’s a wonderful thing! The white is a bit tacky, but I think I got a fix for that. I think I will cut out Mt. Dew cans and slide over the the legs, it will look like I am using cans to hold the desk up. Totally tacky, but still pretty cool! The height isn’t right for 3 cans, but 3 cans, 1 or two of them crushed a bit will work, and really help with the effect.

Posted by Picasa

.