Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Saturday, December 1, 2007

Mirroring CentOS

I need a local mirror of CentOS again. But I only want CentOS 5. I've done this before, but I figure I should post the script so that I don't have to write it from scratch again next time.

#!/bin/bash

# change to limit
# bandwidth
BWLIMIT=256

# call the script with '1' or something
# to make it display progress
VERBOSE=$1

# these can all be lists of
# the sub trees you're looking for
VER="5"
ARCHLIST="i386 x86_64"
BASELIST="os updates"

# where is your local repo?
LOCAL=/tmp/centos

RSYNC=rsync

# mirrir list available at http://www.centos.org/modules/tinycontent/index.php?id=13
MIRROR="rsync.FIXME::centos"

rsync_cmd="$RSYNC -aHz --delete"

if [ "x$VERBOSE" = "x" ]; then
rsync_cmd="$rsync_cmd -q"
else
rsync_cmd="$rsync_cmd -v --progress"
fi

if [ "x$BWLIMIT" != "x" ]; then
rsync_cmd="$rsync_cmd --bwlimit=$BWLIMIT"
fi


for ver in $VER; do
for arch in $ARCHLIST; do
for base in $BASELIST; do
if [ ! -d $LOCAL/$ver/$base/$arch/ ]; then
mkdir -p $LOCAL/$ver/$base/$arch/
fi
$rsync_cmd $MIRROR/$ver/$base/$arch/ $LOCAL/$ver/$base/$arch/
done
done
done
This is based on the original I found on the CentOS Mirroring page by a somewhat anonymous jlar310.

My script is nice because you can run it silently as a cron, or pass -v (or anything, really) on the command line and watch it go.

Sunday, October 21, 2007

Perforce Init Script

I'm playing around with perforce. Their installation packages leave a bit to be desired. You download the binaries off of their website and drop them into your file system.

I wrote this init script to help start it up on Redhat/CentOS systems:


#!/bin/bash

# chkconfig: 345 90 50
# description: perforce (p4d) is a SCM system.
# processname: /usr/sbin/p4d
# config: /etc/sysconfig/p4d

P4D=/usr/sbin/p4d
P4=/usr/bin/p4

P4ROOT=/var/perforce
P4JOURNAL=/var/perforce/journal
P4LOG=/var/log/p4err
P4PORT=1666
P4USER=perforce
OPTIONS=""

prog="p4d"

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/p4d ]; then
. /etc/sysconfig/perforce
fi


case $1 in
start)
echo -n "Starting $prog: "
daemon --check $P4D --user $P4USER "$P4D -r $P4ROOT -J $P4JOURNAL -L $P4LOG -p $P4PORT -d $OPTIONS 2>&1 > /dev/null"
echo
stop)
echo -n "Stopping $prog: "
killproc $prog
echo
;;
*)
echo "Usage: $0 ( start | stop )"
esac

My script runs perforce as a non-root user. By default, it expects the p4d to be in /usr/sbin and that you have a perforce user. I call this script /etc/init.d/p4d.

I may write a spec file to allow creation of an RPM.

I also want to add a 'backup' option for easy maintenance.

*UPDATE*

I switched the init script to use daemon instead of su.

Friday, October 5, 2007

EC2, CentOS and PPTP

Continuing on my EC2 journey.. I wanted to allow my ec2 hosts to talk to a private network at the office. We use a Microsoft PPTP vpn -- it's the quickest way for me to set up the VPN.

I've been the Rightscale CentOS 5 AMI for my testing. In order to get my PPTP vpn connection up and running, I used pptpclient. To install it, I mostly followed their instructions.

  1. Install their yum repos with

    # this isn't documented on their site
    rpm -Uvh http://pptpclient.sourceforge.net/yum/stable/rhel5/\ pptp-release-current.noarch.rpm

  2. Install the required RPM's via yum
  3. Follow their Configure by Hand instructions
  4. The pon script wasn't in the path. To start my VPN, I had to run

    # of course, substitue $TUNNEL with whatever you
    # set in the Configure by Hand steps
    bash /usr/share/doc/ppp-2.4.4/scripts/pon $TUNNEL
  5. Set up any required routes

    route add -net 1.2.3.4/24 gw $PPTP_GATEWAY
That's it. The next step is to automate the processes further. I'm guessing there is a config file that could easily be added to /etc/sysconfig/network-scripts to make this happen.