Qugstart Blog | Ruby, Rails, Nerdy, Life

This was done on Fedora 10 in my case, but should be similar for all distributions. This is set up on a shared ‘central’ repository, where changes are pushed to. That’s why it’s done using the post-receive hook (the repository receives changes).

Step 1: Copy (or symlink) the post-receive script, or download it here. The script must be in the ‘hooks’ directory like this:
$GIT_DIR/hooks/post-receive

I’ve read that on Debian systems, for example, the hook is stored in /usr/share/doc/git-core/contrib/hooks/post-receive-email but i had no luck finding it here on my system.

Make sure it is named “post-receive” so that Git recognizes it.

Step 2: Make sure that the script is executable:

chmod a+x $GIT_DIR/hooks/post-receive

Step 3: Edit the first line of $GIT_DIR/description to be your repository name. This will be in the subject of the email.

Step 4: Edit $GIT_DIR/config with some email settings such as recipient / sender email and subject-line prefix. Here’s some basic settings (read the script for all possible settings).

[hooks]
mailinglist = "receiver1@receivers.com, receiver2@receivers.com"
envelopesender = sender@senders.com
emailprefix = "[GIT] "

Note: you can also set these by using git-config:

git-config hooks.mailinglist "receiver1@receivers.com, receiver2@receivers.com"
git-config hooks.envelopesender sender@senders.com
git-config hooks.emailprefix "[GIT] "

That’s it ! Try doing a git-push to your shared repository, and see if you get email notifications. If not, try tailing your mail log to see what’s wrong (/var/log/maillog).

, , , , Hide

This guide shows you how to start an NFS service on one (host) machine, export the NFS drive, and then connect to that NFS drive from a client machine.

## On the NFS host machine:

#Start Portmap service if needed.
#NFS uses portmap and a bunch of ports (that you can set in /etc/sysconfig/nfs) if you want.
See this link for more details on NFS ports.

#Start portmap service

service portmap status
service portmap start (if needed)

#Start NFS

service nfs start

#Edit /etc/exports
#Reference: https://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-guide/s1-nfs-server-export.html

Format is (select the options you want):
[Directory to export] [Hosts to allow](options)

/home/just_testing 192.168.0.0/24(rw,async,wdelay,root_squash)

#Run exportfs to refresh NFS exports

exportfs -av

Be sure the proper ports are open on iptables
Reference: http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/

## Now on your NFS client machine:
Start portmap

service portmap start

Create a mount point and mount the NFS drive. Remember to use your own server’s IP address:

mkdir /mnt/nfs-usbdisk
mount 192.168.0.2:/home/just_testing /mnt/nfs-usbdisk

Voila ! Tail your logs if you have any problems !

, , , , Hide

#Note: If you are using CentOS 4, it’s the same general process. You might have more difficulty finding the packages to install fuse and dependencies.

This is a simple guide on how to mount your S3 bucket as a “virtual drive”. This is great for backing up your data to S3, or downloading a bunch of files from S3.

#First, make sure you have the fuse package installed.

#On CentOS, fuse is available from RPMforge

#http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

#Now install fuse

yum install fuse
modprobe fuse

#Download s3fs and make

cd /usr/local/src
wget http://s3fs.googlecode.com/files/s3fs-r191-source.tar.gz
cd s3fs
make

#Copy the binary to /usr/local/bin (or wherever you prefer)

cp s3fs /usr/local/bin

#Make a mount point

mkdir /mnt/s3drive

#Mount your bucket like this:

s3fs bucketname -o accessKeyId=XXXXXXXXXXXXXXXXXXXX -o secretAccessKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /mnt/s3drive

That’s it ! You can change directory to your virtual drive or start copying files !
Go ahead and use a visual client such as CyberDuck or S3Hub to verify with your own eyes that this actually worked. :)
Good luck!

, , , , , Hide

Working with Amazon Web Services (AWS) such as EC2, S3, and EBS takes some time to get familiar with all the tools, acronyms, and especially paradigm of thinking about servers. Once you get into it, you quickly find much old (outdated) documentation, and you can easily find yourself spending hours searching the web for blog posts to help in your quest!

After much research, I decided to create a Mysql database server on a ‘instance-store’ small ec2 server, with all the precious Mysql data stored on a EBS volume attached to my server. This way, I could easily create snapshot backups of my databases for FAST backups. Here’s the procedure I decided on. It involves symlinking Mysql config files and data directories onto the EBS volume.

Another trick I used because I needed to migrate about 20 GiB’s of data to get started, was that I initially set up an “X-tra large” instance, with 10 GiB’s RAM to handle the data import. After the data was migrated and imported to my database, I simply terminated my X-Large instance and spun up a small instance connected to the same EBS volume! All the databases were preserved nicely and I did not have to waste money paying for an X-Large instance anymore. This exemplifies the value of thinking in the “cloud” mindset – where you can spin up and down servers in a matter of seconds! Hope this article helps someone else out there!

Great Reference: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663

# Create small instance (I used the AMI for i.386 CentOS 5.4)

# Create EBS volume and attach it to the EC2 (as /dev/sdh in my example)

# Install mysql-server

yum install mysql-server

# Install xfsprogs so you can format EBS drive with XFS

yum install xfsprogs
modprobe xfs
mkfs.xfs /dev/sdh

# Add to your /etc/fstab so it mounts on boot

echo "/dev/sdh /vol xfs noatime 0 0" | sudo tee -a /etc/fstab
sudo mkdir -m 000 /vol
sudo mount /vol

# Create directories that will store persistant Mysql data

mkdir /vol/etc /vol/lib /vol/log

# Move the mysql config and data files to your newly mounted drive

mv /etc/my.cnf  /vol/etc/
mv /var/lib/mysql /vol/lib/
mv /var/log/mysqld.log /vol/log/

# Symlink the mysql directories so that mysql uses the mounted EBS drive

ln -s /vol/lib/mysql /var/lib/mysql
ln -s /vol/etc/my.cnf /etc/my.cnf
ln -s /vol/log/mysqld.log /var/log/mysqld.log

Now restart your Mysql server and check your logs if you have any errors!

service mysqld start

# If you have errors, watch the logs
tail -f /var/log/mysqld.log

Good luck !

, , , , , Hide

Just installed Redmine for our project management / code tracking with Git. I must say it’s pretty nice being able to setup multiple projects easily (unlike Trac). The system is designed fairly well with a very user-friendly interface. And plus, it’s Rails !!

Anyways… too much on Redmine! This post is to describe how to setup a Git repository for use with Redmine.

The important thing to note is that the Git repository MUST BE on the same server as your Redmine setup. So, you probably need to have access to that server!
This was not ideal for me because our Git server does not have Ruby/Rails, etc. installed on it. That’s okay! You just need to clone the repository as a BARE repository on the same machine that your Redmine app is running on. Let’s see how:

Pick a place on your Redmine app server to house all your bare Git repos.
I will choose “/var/local/git_copies” for my example.

Note: Make sure that your permissions allow for your web-user to access these Git repos. My web-user is ‘build’.

# Change to build user (see above)
$ su - build
# Create the directory
$ mkdir /var/local/git_copies

Now, create your git clone as a bare repository clone.
Note: a bare repository will not have your actual files. It will just contain the standard git folders

# Goto your git_copies directory
$ cd /var/local/git_copies
# Make a bare clone of the repo
$ git clone --bare ssh://git@reposerver/usr/local/git_root/foo-project.git

Change into your project and configure remote branch tracking for your local copy.

$ cd foo-project.git
$ git remote add origin ssh://git@reposerver/usr/local/git_root/foo-project.git

Now, normally you want to sync up the repo, but you cannot do a normal git fetch && git merge into a bare repo.
Instead, do a fetch and reset the HEAD to point to the remote branch commit. You need the ‘–soft’ flag or else you will see errors!

$ git fetch origin
$ git reset --soft refs/remotes/origin/master

Now, remember you need to manually sync your new Git repo to have the changes appear on Redmine. A better idea would be to create a cronjob that does this automatically. Especially with more than 1 repository, automating this process will save much time. Here’s the basic idea:

# Add the following to your crontab
*/30 * * * * cd /var/local/git_copies/foo-project.git && git fetch origin && git reset --soft refs/remotes/origin/master > /dev/null

Instead of doing many times in your crontab, maybe it would be easier to setup a bash script to run:

#!/bin/bash
# Not tested! Use at your own risk, and change your GIT_ROOT and "*.git" to fit your setup.
GIT_ROOT=/var/local/git_copies

cd $GIT_ROOT
ls *.git | while read repo; do
  cd $repo && git fetch origin && git reset --soft refs/remotes/origin/master > /dev/null && cd $GIT_ROOT
done

Then, just add this one script to your crontab and have it run every N minutes as you desire!

This site is helpful and worth checking out as well:
Reference on synchronizing 2 git repositories

That’s it, let me know how it goes!

, , Hide

« Previous Entries

Next Page »

Find it!

Theme Design by devolux.org
To top