Code:軟體安裝程式模板

sgy618發表於2011-10-12

#!/bin/bash
# install lighttd
# author chunsheng1@staff.sina.com.cn
# last update 2011-09-21

YASM_NAME="yasm-1.0.1"
YASM_SUFFIX=".tar.gz"

JPEG_NAME="jpegsrc.v8c"
JPEG_SUFFIX=".tar.gz"

FFMPEG_NAME="ffmpeg-0.8.1"
FFMPEG_SUFFIX=".tar.gz"

PCRE_NAME="pcre-7.4"
PCRE_SUFFIX=".tar.gz"

LIGHTTPD_NAME="lighttpd-1.4.18_sina-5.0"
LIGHTTPD_SUFFIX=".tgz"

TRANSFER_RSYNC_MODULE=$1"::download/video/"

LIGHTTPD_INSTALL_DIR="/data1/lighttpd"
DOC_ROOT="$LIGHTTPD_INSTALL_DIR/htdocs/"
LOG_DIR="$LIGHTTPD_INSTALL_DIR/logs/"
CONF_DIR="$LIGHTTPD_INSTALL_DIR/etc"
BIN_DIR="$LIGHTTPD_INSTALL_DIR/bin"
SBIN_DIR="$LIGHTTPD_INSTALL_DIR/sbin"
msg(){
date +"%Y-%m-%d %H-%M-%S "$1""
}

exe(){
msg "$1"
perl -e "system("$1")";
}

installtgz(){
name=$1;
subfix=$2;
store=$3;
para=$4;

tgz=$1$2

exe "rsync -avz $store/$tgz ./"

exe "tar zxvf $tgz"
if test -d $name
then
cd $name

exe "./configure $para"
exe "make"
exe "make install"
exe "cd .."
fi
}
iflag=0
a=`pcre-config --version | sed -e "s/([0-9])..*/1/"`
if [ -z $a ]; then
echo "PCRE is not installed yet"
iflag=1
elif [ $a -lt 7 ]; then
echo "PCRE version is older than 7, replace it with $PCRE_NAME"
echo "rm" `which pcre-config`
rm `which pcre-config`
iflag=1
fi

if [ $iflag -eq 1 ]
then
installtgz $PCRE_NAME $PCRE_SUFFIX $TRANSFER_RSYNC_MODULE ""
fi

flag=1
echo "install lighty? y/n :"
read input
case $input in
y|Y|Yes|YES) flag=1
;;
n|N|No|NO) flag=0
;;
esac

if [ $flag -eq 1 ]
then
installtgz $YASM_NAME $YASM_SUFFIX $TRANSFER_RSYNC_MODULE "--prefix=/usr"
installtgz $JPEG_NAME $JPEG_SUFFIX $TRANSFER_RSYNC_MODULE "--prefix=/usr --enable-shared"
installtgz $FFMPEG_NAME $FFMPEG_SUFFIX $TRANSFER_RSYNC_MODULE "--prefix=/usr --enable-shared --enable-zlib"
ldconfig /usr/lib

for so in /usr/lib/libyasm.a /usr/lib/libjpeg.so /usr/lib/libavcodec.so
do
if test ! -f "$so"
then
echo "***** $so not exists! *****"
exit 1
fi
done

exe "/data1/lighttpd/bin/stop.sh"
installtgz $LIGHTTPD_NAME $LIGHTTPD_SUFFIX $TRANSFER_RSYNC_MODULE "--prefix=$LIGHTTPD_INSTALL_DIR"

echo "Press any key to continue"
read

exe "mkdir -p $CONF_DIR"
exe "mkdir -p $DOC_ROOT"
exe "mkdir -p $LOG_DIR"
exe "mkdir -p $CONF_DIR"
msg "set password for user sinavideo"
echo "sinavideo:rM7oW32iAOfyU" > $CONF_DIR/.lighttpd.htpasswd
echo "sinavideo" > $CONF_DIR/lighttpd.user

fi

exe "cp $TEST_GIF $BAD_REQUEST_PAGE $INDEX_FILE $APACHE_DOC_ROOT/jiankong.html $DOC_ROOT/"
exe "cp -f lighttpd.conf.sample $CONF_DIR/lighttpd.conf"

exe "echo ulimit -c unlimited > $BIN_DIR/start.sh"
exe "echo $SBIN_DIR/lighttpd -f $CONF_DIR/lighttpd.conf >> $BIN_DIR/start.sh"
exe "echo killall lighttpd > $BIN_DIR/stop.sh "
exe "chmod +x $BIN_DIR/start.sh $BIN_DIR/stop.sh"
exe "/data1/lighttpd/bin/start.sh"

exit 0;

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23168012/viewspace-1055615/,如需轉載,請註明出處,否則將追究法律責任。

相關文章