git insufficient permission for adding an object to repository database ./objects

strangely, I had been pushing to this repository for weeks no problems. Then one day I get the error message for the title above:


$git push
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 506 bytes, done.
Total 5 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit

I was a member of the group in question, checked via:

$ groups myusername

and verified that group had write permissions:

$ ls -la

Turned out a few files had shown up in the object directory with different permissions.

To fix:

ssh to server
cd your-repository.git

sudo chmod -R g+ws *
sudo chgrp -R yourgroup *

and maybe:

git repo-config core.sharedRepository true

and then try to push again

How To Move Your Drupal or WordPress Web Site to Amazon EC2 and Get Free Fast Hosting for a Year

Tired of slow shared hosting? Now you can move your Drupal or WordPress web site to Amazon’s EC2 cloud services, and you can even get free hosting for a year! That’s because Amazon has a deal going on to attract new users – they call it their free tier deal. Check it out, sign up.

Amazon’s EC2 service lets you create virtual servers of your own in their cloud. They have since added EBS (Elastic Block Store) and it is the addition of EBS that makes them very attractive for hosting your typical WordPress or Drupal web site, because it gives you persistent storage. The free deal is for running a single micro instance. A micro instance provides nominal computing power all of the time, with the ability to jump up to 2 EC2 Compute Units on demand, and 613 MB of memory. A normal small instance gives 1 EC2 Compute Unit all the time, along with 1.73 GB of memory. A small instance is not free, runs about $80 a month for most after it is all said and done. But the micro instance is great for most sites. I am running four low-traffic WordPress sites and 2 decent traffic Drupal sites on one micro instance, and I get fast page loads — I am very pleased. All told I only see about 1000 page views a day, but on shared hosting all I had was trouble and slow loading pages. And free for a year with low rates after that? Who can complain? Well, there is a downside. You have to configure and manage your server. It is not like with shared hosting where they have everything mostly set up for you.

But managing your own server is not that hard if you are interested in it at all. Setting up a mail server was the hardest part for me. And I detail all the steps below, for your reference, and as I future reference for myself. To save time, I refer you to other guides I used for parts of it.

So you signed up at http://aws.amazon.com/free/ – once you get your emails back from Amazon saying you are good to go, then it is time to log in to the AWS Management Console. Go here: http://aws.amazon.com/console/ and click on the button on the right side to sign in (choose the EC2 popdown next to the button).

First set up a security group. This is like a firewall setup. You’ll want to add SSH for port 20, for SSH access to the server. And you’ll want http access on port 80, and possible https access on port 443. Refer to the section “Setting up a security group” on this guide for more information.

Next, choose Key Pairs from the side bar menu and create a new key pair. This is used for authentication when SSH’ing into your server. More secure than password based authentication. For more info, see “Setting up your AWS account and tools” section in this guide. Save your key pem somewhere where you will not be likely to delete it on your computer.

Note, if setting up a micro instance, the guide I refer to above has information you should not follow about setting up persistent storage, because that article was written before EBS became available.

Now it is time to pick an AMI – Amazon Machine Image. This is like your virtual servers set up – what version or distribution of Linux you want to use, all ready to go. An Amazon Machine Image (AMI) is an encrypted machine image that contains all information necessary to boot instances of your operating system and software. For example, an AMI might contain all the software to act as a web server (e.g., Linux, Apache, and your web site). I went with Ubuntu Lucid LTS. Ubuntu is popular, well supported, and I like that they make long term support versions catering to web server use. From Amazon’s Help Guide:

To use Amazon EC2, you launch one or more instances of an AMI. An instance might be one web server within a web server cluster or one Hadoop node.

When launching AMIs, you can select an Amazon-provided AMI, a public AMI that another Amazon EC2 user provided, or an AMI that you create.

An Amazon EC2 instance can be launched from an AMI backed by either Amazon S3 or by Amazon EBS. Instances launched from AMIs backed by Amazon S3 use the local instance store as the root device (e.g., / or C:). An instance launched from an AMI backed by Amazon EBS uses an Amazon EBS volume as its root device.

I used ami-3e02f257. Make sure you pick an EBS (Elastic Block Store) version of an ami – micro instances require it.

More to come…

Put a project into git version control, with central svn style repository, + Drupal notes

Git is distributed and wonderful. Svn kinda sucks. But often you still want to sort of think of your git setup as having a one central bare repository, and git does that. Steps to set-up, for your reference and mine, follow:

Go to the base root directory of your project and type:

$ git init
$ git add .
$ git commit -m "initial commit"

now your project is under git’s purview.

$ git branch
*master

and you see you have one branch named master that was auto-created by the git init and commit process above.

Now go to wherever you want the bare (central) repository to be.

$ mkdir my_repository.git
$ cd my_repository.git
$ git --bare init
Initialized empty Git repository in /home/git/my_repository.git
$ exit
Bye!

your bare repository is set-up, simple as that, but now you need to push all the files into it:

First check and see if you have any remote repositories being tracked locally:

$ cd ~/Sites/myapp
$ git remote

None came up, good.

We already looked at local branches:

$ git branch
* master

Just one branch, the master branch that is auto-created by git when you did init/commit above.

Check .git/config:

$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true

Now, push from your project to the bare repository:

First, let your local know about the remote (bare):

$ git remote add origin ssh://myserver.com/home/git/my_repository.git

Check your config file again ($ cat .git/config) and you will see new lines for the remote named origin.

Finally:

$ git push origin master

All set. Now you can have others pull from the bare main repository, e.g.:

$ git clone ssh://username@myserver.com/home/git/my_repository.git

SOME DRUPAL NOTES

in Drupal, you probably do not want settings.php and .htaccess included in the repository. Depending, you might also want to include sites/default/files as an ignore directory. Really, should of done this much earlier, before we added files into git. also, note: To stop tracking a file that is currently tracked, use git rm --cached filepathname.

To ignore files, like svn propset ignore, go edit the exclude file to add in the file paths with wildcards that you wish git to ignore:

$ vim .git/info/exclude

eg.:

-bash-3.2$ cat .git/info/exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
sites/default/settings.php
.htaccess

Cliches

They say it is poor practice to use cliches in your writing. And they are correct. However, I am a big fan of cliches for informal communication. They say so much, so wisely, so well. Ok, so that’s over the top (-: I still like them though.

Some of my favorites:

Let sleeping dogs lie.
The squeaky wheel gets the grease.
You can catch more flies with honey.
Now we’re cooking with gas!
Don’t judge a book by it’s cover.
Absence makes the heart grow fonder.
What goes around comes around.
Youth is wasted on the young.
Penny wise, pound foolish.
Money can’t buy happiness.
If at first you don’t succeed, try try again.
No good deed goes unpunished.
There are two sides to every story.
When it rains, it pours.
Hitch your wagon to a star.
Every dog has his day.
Different strokes for different folks.
Hell hath no fury like a woman scorned.
Que sera, sera (Whatever will be, will be.)
The time is ripe.
Happy as a pig in mud.
The grass is always greener…

Drupal Classified Ads Modules Options / Choices / Comparisons

This post discusses the options / choices for having classified ads on Drupal websites. So it is a comparison of classified ad solutions for Drupal, if you will. Drupal is an open source content management system for building websites and it has lots of contributed modules that can often solve your needs without any custom programming on your own part. And luckily, there are at least two contributed modules for classified ads, plus the more jack of all trades modern solution of using the CCK and Views modules to roll it together.

I want the ability for users to add and edit classified ads. There is a Classified Ads drupal module available, that allows just this functionality. The only problem is that it requires the ads to expire at some point, and then removes them from your site. I do not like this because I would rather have items marked “Sold” or “No Longer For Sale” instead of being deleted. Why? Because I want the content to stay forever, for SEO reasons. Webmasters developing content websites work so hard to get content, why give any of it up?

I do like however that it integrates a “My Classified Ads” tab into the user profile “My Account” pages, and that it handles email notifications to remind customers when their ads are going to expire. Very nice features.

Another alternative is just to create a new content type for ads (using CCK), and then create views to handle display. This does not give you a tab on the user profiles page, although they can view their ads from their “My account” page by clicking on the “Track” tab if you have enabled the Tracker module.

Another alternative is the drupal module Zipsads. This was overkill for me, I did not want to link ads to zip codes, as I wanted all ads to be worldwide.

There is one other classified ads Drupal module, called classifiQ but there is no published release for it. So oh well there.

I think my solution will be to create the ads using the CCK / Views option, and down the line when I get time figure out how to code in a custom tab in the user profile.

Well, but I like the idea of getting rid of old ads. But what about if people link to them? I do not want to lose the link juice. Maybe what is needed is a redirect solution for 404 errors in general, or else specifically for expired (and thus unpublished) ads… so that it redirects to the main classified ad page. Any ideas?