Wednesday, May 20, 2009

Drupal module install scripts

The curl downloader -- for clients that lack wget

#!/bin/bash
## This script uses curl to save a web url from the net... It sets the file to the target filename.

function usage {
echo "usage: cget [opts] url
opts
-h: this help message
"
}

while getopts ":h" OPTION
do
case $OPTION in
h)
usage $OPTARG
exit 1
;;

?)
usage $OPTARG
exit
;;
esac
done

if [ -z $1 ]
then
usage
exit 1
fi

NAME=`echo $1 | tr "/" "\012"`

for X in $NAME
do
FNAME=$X

done

curl -o $FNAME $1

exit 0

The "installer"

#!/bin/bash
## This script uses downloads a zip file and moves it to the specified directory... from a package directory... This was intended to be used for drupal modules.

function usage {
echo "usage: modinst [opts] url
opts
-h: this help message
"
}

while getopts ":h" OPTION
do
case $OPTION in
h)
usage $OPTARG
exit 1
;;

?)
usage $OPTARG
exit
;;
esac
done

if [ -z $1 ]
then
usage
exit 1
fi

NAME=`echo $1 | tr "/" "\012"`

for X in $NAME
do
FNAME=$X

done

./cget $1

cd ../modules/
tar -xzf ../gzips/$FNAME

exit 0



No comments:

Post a Comment