Skip to content

Instantly share code, notes, and snippets.

@revmischa
Created March 15, 2012 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revmischa/2041767 to your computer and use it in GitHub Desktop.
Save revmischa/2041767 to your computer and use it in GitHub Desktop.
Set up everything needed for panoptic
#!/bin/bash
INSTALLDIR="$HOME/local/panoptic"
function step() {
NAME=$1
if [[ -z "$NAME" ]]; then
echo "Function name required"
exit 1
fi
STATEFILE=$NAME
if [[ ! -e $INSTALLDIR/.state/$STATEFILE ]]; then
echo "Executing $NAME..."
$NAME && touch $INSTALLDIR/.state/$STATEFILE
fi
}
function install_apt_deps () {
echo "Installing CPAN modules from APT..."
sudo aptitude install -y libcatalyst-perl libcatalyst-modules-extra-perl \
libcatalyst-modules-perl libcatalyst-view-tt-perl libdbd-pg-perl libdbd-sqlite3-perl
return $?
}
function install_perl_library () {
NAME=$1
REPO=$2
if [[ ! -e $INSTALLDIR/.state/built_module_$NAME ]]; then
echo "Checking out $NAME from $REPO..."
cd $INSTALLDIR
git clone $REPO $NAME
cd $NAME
echo "Installing depdencies for $NAME..."
cpanm --installdeps -v -n . || return 0
echo "Generating makefile for $NAME..."
perl Makefile.PL
echo "Building $NAME..."
# make && make install && touch $INSTALLDIR/.state/built_$NAME
make && touch $INSTALLDIR/.state/built_module_$NAME && echo "Built $NAME" && export PERL5LIB="$PERL5LIB:$INSTALLDIR/$NAME/lib" && return 1
return 0
fi
}
function build_video_server () {
cd $INSTALLDIR
echo "Checking out build_video_server..."
git clone git://gist.github.com/742831.git build_video_server
BASEDIR=$INSTALLDIR/build_video_server \
bash build_video_server/build-video-server.sh && return 1
return 0
}
function install_build_deps () {
cpanm -v ExtUtils::PkgConfig ExtUtils::MakeMaker local::lib
return $?
}
function build_panoptic () {
cd $INSTALLDIR
install_perl_library 'panoptic' 'git://github.com/int80/panoptic.git'
return $?
}
###################
mkdir -p $INSTALLDIR
cd $INSTALLDIR
mkdir -p .state
step "install_apt_deps"
step "install_build_deps"
step "build_video_server"
install_perl_library 'av-streamer' 'git://github.com/revmischa/av-streamer.git'
install_perl_library 'rapid' 'git://github.com/int80/rapid.git'
step "build_panoptic"
if [[ -e $INSTALLDIR/.state/build_panoptic && ! -e $INSTALLDIR/.state/configured_panoptic ]]; then
cd $INSTALLDIR/panoptic
echo "Configuring panoptic..."
# copy sample config
if [[ ! -e panoptic_local.yml ]]; then
cp sample/panoptic_local.yml ./
fi
# deploy schema
echo "Do you want to deploy panoptic schema? This will overwrite your panoptic configuration if it exists. Type YES to confirm: "
read DEPLOY
if [[ "$DEPLOY" -eq "YES" ]]; then
cpanm -v -n SQL::Translator
echo "Deploying schema..."
script/panoptic_deploy_schema.pl $DEPLOY && echo "Schema deployed"
fi
touch $INSTALLDIR/.state/configured_panoptic
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment