#!/bin/bash echo Bitweaver SamplePackage package creator echo # Validate Input if [ "$1a" == "a" ] then echo "Please enter a package name to create" exit fi # Make the correct case copies of the package name lcase=`echo "$1" | perl -ne "print lc"` ucase=`echo "$1" | perl -ne "print uc"` ccase=`echo "$lcase" | perl -n -e "print ucfirst"` # Check that the package doesn't already exist if [ -d $lcase ] then echo "A package called $ccase already exists. Folder $lcase exists" exit fi # Has the sample package already be decompressed if [ ! -f sample ] then # has the sample package already been downloaded if [ ! -f bitweaver_sample_package.tar.gz ] then wget http://www.bitweaver.org/builds/packages/bitweaver_sample_package.tar.gz fi # if we have the compressed sample package, decompress it if [ -f bitweaver_sample_package.tar.gz ] then tar -zxvf bitweaver_sample_package.tar.gz fi fi # if we have the sample package if [ -d sample ] then # From http://www.bitweaver.org/wiki/SamplePackage echo renaming sample mv sample $lcase; cd $lcase echo Case sensitive Search and Replace all occureneces of 'sample' with your package name find . -name "*" -exec perl -i -wpe "s/sample/$lcase/g" {} \; ; find . -name "*" -exec perl -i -wpe "s/SAMPLE/$ucase/g" {} \; ; find . -name "*" -exec perl -i -wpe "s/Sample/$ccase/g" {} \; echo Rename all the files containing 'sample' with your package name find . -name "*sample*" -exec rename sample $lcase {} \; ; find . -name "*Sample*" -exec rename Sample $ccase {} \; cd .. echo echo A basic outline of your package $ccase has been created echo else echo directory sample not found echo please review any errors echo please download and decompress the sample package fi