Friday, March 13, 2009

Creating a local fedora repo

Things you should know ahead of time:
-- You'll need a lot of HDD space so create a separate 40GB partition




# install some requirements:
yum install createrepo


# create directories:
mkdir -p /var/www/html/yum/base/10/i386
mkdir -p /var/www/html/yum/updates/10/i386


# sync the fedora 10 mirror with the repo directories
# NOTES:
# -- more mirror sites
# -- prepend the rsync command with the next line to deal with a proxy server
# RSYNC_PROXY="server.domain.com:3128"
#
# The base RPMs
rsync -avrt rsync://mirrors.tummy.com/fedora/linux/releases/10/Everything/i386/os/Packages/ /var/www/html/yum/base/10/i386/

# The update RPMs
rsync -avrt rsync://mirrors.tummy.com/fedora/linux/updates/10/i386/ --exclude=debug/ /var/www/html/yum/updates/10/i386/


# Create local repo data
# This will create a repodata directory along side your RPMs
createrepo /var/www/html/yum/base/10/i386
createrepo /var/www/html/yum/updates/10/i386


# automate it by resyncing the updates directory via cron job
23 4 */2 * * /usr/bin/rsync -avrt ........(resync updates)


# update yum configuration
# edit /etc/yum.conf Append file with this:
#---------------------------------------------------
# added by frankg
# used 127.0.0.1 because we have a dynamic IP
# you should use your static IP of possible
[base-local]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://127.0.0.1/yum/base/$releasever/$basearch
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
enabled=1
gpgcheck=0

[updates-local]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
baseurl=http://127.0.0.1/yum/updates/$releasever/$basearch/
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
enabled=1
gpgcheck=0




Reference Article

Friday, January 2, 2009

Viewing perl source in the browser

Nothing like getting sidetracked while in the middle of a project. I've done this a million times but of course forget every time I do it. So time to blog about it so I have a reference.

The issue:
I'm trying to view perl source code in the browser because I find it more flexible than VIM for browsing. Using the default configuration for the server and browser, when I click on a .pl file it opens a dialog box.

The real issue:
Well, the real issue that I was having was that I was using a URL like "file:///...". This type of URL is handled by the browser and never sent to the web server. So all the server config options in the world will not solve the problem. The trick is to serve the file with your web server so that you can use a URL like "http://servername/path/to/file".

The solution:
1. serve the files you want to view
I added a symbolic link to my root directory "/var/www/html/opt --> /opt
Make sure you have permissions set to allow your web user or group access.

2. create a conf file for handling .pl files
# filename: /etc/httpd/conf.d/perl.conf
# I like to view .pl files in my browser
AddType text/plain .pl

3. restart web server

4. clear cache in the browser

5. view the .pl file in your browser.

okay, back to work!!!

Monday, November 19, 2007

perl installers

This is the story about the evolution of perl installers

First there was ExtUtil::MakeMaker
The original joe.
This module comes with perl.
The godfather of perl install.

Then there was Module::Build
The next generation joe
This module does not come with perl.
The goal of this module is to duplicate the functionality of ExtUtil::MakeMaker without the need for 'make'.

And now finally there Module::Install
The better joe
Module::Install comes packaged with the module you're installing, so the end user never has to install it. You can also bundle other modules with your distribution/module. You can also add custom install code to your module.

Get all the details here.

Sunday, July 22, 2007

3 steps to passwordless ssh remote login

1) GENERATE KEYS ON LOCAL_BOX
=============================================================
# NOTE: don't enter passwords
local_box> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
4c:fd:65:ff:a8:50:50:5c:2d:a0:88:ab:d1:d5:3c:08 user@remote_box.domain.com


2) PLACE PUBLIC KEY ON REMOTE_BOX
=============================================================
# copy public key to remote_box
local_box> scp ~/.ssh/id_dsa.pub user@remote_box:~/
# Login to remote_box and append public key to authorized_key file
remote_box> cd ~/.ssh
remote_box> cat ~/id_dsa.pub >> authorized_keys


3) REQUIRED CLEANUP
=============================================================
# Set permission as follows
remote_box> chmod 700 ~/.ssh
remote_box> chmod 600 ~/.ssh/authorized_keys
# remove original key from home dir
remote_box> rm -f ~/id_dsa.pub


TEST IT
=============================================================
local_box> ssh user@remote_box
Last login: Sun Jul 22 03:46:03 2007 from box.domain.com
remote_box>

NOTES
=============================================================
There are security issues with having keys with no pass-phrase
I don't get into it here.


KEYS FROM WINDOWS ( see -> Kutzooi blog )
=============================================================
Using a public key created by 'PuTTYgen'

Unfortunately the layout of the key that PuTTYgen creates differs from the layout that SSH (on Linux) excepts, this means that we need to edit the public key to make it usuable under Linux. Fortunately enough its not too hard.

Open the public key that you created, it will look something like this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "user@host"
AAAAB3NzaC1kc3MAAACBANmj5ago5F/QP50X2nxD9FkSIDFoSVv1KavQNjlONStv
PuJvF1AQLcDYjGrtFnK8Wn7sEzz1VZcOYTDq6pxy0xDyoQLjYTWVpVM3vVLETfJc
XVNejswt6SGshEW4R1Ys9xKaTPwRejEHe8FLqEkapTCj56dp47J5JOHs4b8SkAPl
AAAAFQD89oWHllh2NDH0lIiEwqts0RArzwAAAIBAflemdNoJwPn6ayVyYNM2bO0p
szzguxKstAvEyojWuIo4srYqUj8c6x6QqLxIvjwi94J8BEDvo7+rmG2PLSwM5Ovm
jyfHUpPD+c6iPLvioGfwQB+B0M/E1frkwteophR9P1Jf1seRDemKL3pY37jdYpq7
NCsJhiMy/NGntcgoagAAAIEAmyxLKQpBDQ8nUT1Fv+YhdBgCWIDQixgwcGZJjJ3d
AiHyDlJ5jXp6ba4ccS5FW2F068yoLY3uQNh1Jt+aUrFyZoc33rrrk34czLK4FKNp
M9V2+KTI8EL/1JeM3/jjl9IhZTLRzSaQinKA5SAXhYnXxfFPlhPislY968Kzag0J
Dag=
---- END SSH2 PUBLIC KEY ----

You should edit the file to make it look like this:

ssh-dss AAAAB3NzaC1kc3MAAACBANmj5ago5F/QP50X2nxD9FkSIDFoSVv1KavQNjlONSt
vPuJvF1AQLcDYjGrtFnK8Wn7sEzz1VZcOYTDq6pxy0xDyoQLjYTWVpVM3vVLETfJcXVNejs
wt6SGshEW4R1Ys9xKaTPwRejEHe8FLqEkapTCj56dp47J5JOHs4b8SkAPlAAAAFQD89oWHl
lh2NDH0lIiEwqts0RArzwAAAIBAflemdNoJwPn6ayVyYNM2bO0pszzguxKstAvEyojWuIo4
srYqUj8c6x6QqLxIvjwi94J8BEDvo7+rmG2PLSwM5OvmjyfHUpPD+c6iPLvioGfwQB+B0M/
E1frkwteophR9P1Jf1seRDemKL3pY37jdYpq7NCsJhiMy/NGntcgoagAAAIEAmyxLKQpBDQ
8nUT1Fv+YhdBgCWIDQixgwcGZJjJ3dAiHyDlJ5jXp6ba4ccS5FW2F068yoLY3uQNh1Jt+aU
rFyZoc33rrrk34czLK4FKNpM9V2+KTI8EL/1JeM3/jjl9IhZTLRzSaQinKA5SAXhYnXxfFP
lhPislY968Kzag0JDag= user@host

NOTICE
This is all on one line. 'ssh-dss' at the beginning and 'user@host' (replace user,host) at the end.

Wednesday, July 11, 2007

more vim magic

Vim is a popular editor on the UNIX platform. It became popular partially because of its ubiquity but also for its power. In this blog entry I would like to show a few of the ways I use Vim to program with Perl.

Warning tabs in this document
Vim can be configured to highlight tab characters, so that you will know that the code is jacked! Many programmers get really pushed out of shape if the code has tabs in it. It is generally considered bad practice to include tabs in the code. Here I'll show how to configure Vim to highlight tabs to warn you of impending danger.
" highlight tabs with set color
highlight MyGroup ctermbg=yellow guibg=yellow
match MyGroup /\t/

We found the tabs now what?
A quick command will convert all tabs to spaces
:retab


Abbreviations
If you find yourself typing the same sequence repeatedly they use abbreviations.
The vim command to paste into your rc file 
iab #p #! /usr/bin/perl -w

# the syntax explanation:
iab # insert mode abbrevaition
#p # the abbrevaition to type
... # the rest is what gets pasted in instead

Now to try it out go into insert mode and type "#p " without the quotes. You should see the "#p" replaced with "#! /usr/bin/perl -w".

Boiler Plates
When creating complex documents like modules, contracts, anything with many sections, it can be difficult to remember important sections because there are just too many to remember them all. Boiler plates are skeleton documents that allow you to remember every section and avoid having to type them all in.

# create the boiler plate doc at ~/.code_templates/perl_application
# type this into your rc file
iab papp :r ~/.code_templates/perl_application

To try this out just type "papp ".

Setting things up at the root level should go a long ways towards making your more productive. Ciao :)

sharpening the saw

As I started working I realized that my home directory was a mess, so I decided to sharpen the saw.

The first step was to get a bit more organized by cleaning my home folder, so I moved everything into a projects folder. Ahhh much better, a clean home directory is the result.

Next, on to Vim. I have a couple of issues that I needed to work out. 1) local setting were different for a number of users. 2) global settings were not quite getting the job done, partially because I was not 100% sure what was being set.

I proceeded to wipe out the local settings for each user.
# once for each user
# WARNING: Make sure there is nothing important in there (backup if not sure)
rm -rf ~/.vim/*


next I opened up the /etc/vimrc file and cleaned it up:
"////////////////////////////////////////////////////////////////////////////
" Perl Best Practices
"////////////////////////////////////////////////////////////////////////////

set autoindent
"Preserve current indent on new lines

set textwidth=78
"Wrap at this column

set backspace=indent,eol,start
"Make backspaces delete sensibly

set tabstop=4
"Indentation levels every four columns

set expandtab
"Convert all tabs typed to spaces

set shiftwidth=4
"Indent/outdent by four columns

set shiftround
"Indent/outdent to nearest tabstop

set matchpairs+=[:]
"Allow % to bounce between angles too


"Inserting these abbreviations inserts the corresponding Perl statement...

iab #p #! /usr/bin/perl -w

iab papp [Esc]:r ~/.code_templates/perl_application.pl[CR]



That's about it for tonight.