每次安裝linux下的包的時候都要一個個config make make install安裝,煩,抽了個空,查了些資料,寫了個bash安裝指令碼,分別安裝了openldapujs、freeradiusujs及checkuserujs包,安裝時只需./install.sh即可,這三個包放在與install同一個目錄下的work目錄夾裡。安裝的配置在jsradius.ebuild中。install.sh #!/usr/bin/env bash CONF="jsradius.ebuild"
if [ ! -e $CONF ]
then
echo "Can't find ujsradius.ebuild."
exit 1
fi if [ $# -ne 1 ]
then
echo "Only one Parameter is permitted."
exit 1
fi source $CONF export ORIGDIR=`pwd`
export WORKDIR=${ORIGDIR}/work
export SRCDIR1=${WORKDIR}/${P1}
export SRCDIR2=${WORKDIR}/${P2}
export SRCDIR2=${WORKDIR}/${P3} ebuild_unpack() {
#make sure we're in the right directory
cd ${ORIGDIR} if [ -d ${WORKDIR} ]
then
rm -rf ${WORKDIR}
fi mkdir ${WORKDIR}
cd ${WORKDIR}
if [ ! -e ${ORIGDIR}/${A1} ]
then
echo "${ORIGDIR}/${A1} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A1}
echo "Unpacked ${ORIGDIR}/${A1}."
if [ ! -e ${ORIGDIR}/${A2} ]
then
echo "${ORIGDIR}/${A2} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A2}
echo "Unpacked ${ORIGDIR}/${A2}."
if [ ! -e ${ORIGDIR}/${A3} ]
then
echo "${ORIGDIR}/${A3} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A3}
echo "Unpacked ${ORIGDIR}/${A2}." #source is now correctly unpacked
} ebuild_compile() {
if [ ! -d "${SRCDIR1}" ]
then
echo "${SRCDIR1} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR1}
user_compile_ldap
if [ ! -d "${SRCDIR2}" ]
then
echo "${SRCDIR2} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR2}
user_compile_radius
if [ ! -d "${SRCDIR3}" ]
then
echo "${SRCDIR3} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR3}
user_compile_checkuser
} case "${1}" in
unpack)
ebuild_unpack
;;
compile)
ebuild_compile
;;
install)
ebuild_install
;;
all)
ebuild_unpack
ebuild_compile
ebuild_install
;;
*)
echo "Please specify unpack, compile, install or all as the parameter"
exit 1
;;
esacjsradius.ebuild#jsradius ebuild conf write by cz_hyfMAKEOPTS="-j2"
P1=openldapujs-2.0.25
P2=freeradiusujs-0.8.1
P3=checkuserujs-1.0
A1=${P1}.tar.gz
A2=${P2}.tar.gz
A3=${P3}.tar.gz user_compile_ldap() { if [ -e configure ]
then
./configure
./make depend
fi
make $MAKEOPTS MAKE="make $MAKEOPTS"
} user_compile_radius() { if [ -e configure ]
then
./configure
fi
make $MAKEOPTS MAKE="make $MAKEOPTS"
} user_compile_checkuser() { if [ -e configure ]
then
./configure
fi
make $MAKEOPTS MAKE="make $MAKEOPTS" }install #!/usr/bin/env bash CONF="ujsradius.ebuild"
if [ ! -e $CONF ]
then
echo "Can't find ujsradius.ebuild."
exit 1
fi if [ $# -ne 1 ]
then
echo "Only one Parameter is permitted."
exit 1
fi source $CONF export ORIGDIR=`pwd`
export WORKDIR=${ORIGDIR}/work
export SRCDIR1=${WORKDIR}/${P1}
export SRCDIR2=${WORKDIR}/${P2}
export SRCDIR2=${WORKDIR}/${P3} ebuild_unpack() {
#make sure we're in the right directory
cd ${ORIGDIR} if [ -d ${WORKDIR} ]
then
rm -rf ${WORKDIR}
fi mkdir ${WORKDIR}
cd ${WORKDIR}
if [ ! -e ${ORIGDIR}/${A1} ]
then
echo "${ORIGDIR}/${A1} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A1}
echo "Unpacked ${ORIGDIR}/${A1}."
if [ ! -e ${ORIGDIR}/${A2} ]
then
echo "${ORIGDIR}/${A2} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A2}
echo "Unpacked ${ORIGDIR}/${A2}."
if [ ! -e ${ORIGDIR}/${A3} ]
then
echo "${ORIGDIR}/${A3} does not exist. Please download first."
exit 1
fi
tar xzf ${ORIGDIR}/${A3}
echo "Unpacked ${ORIGDIR}/${A2}." #source is now correctly unpacked
} ebuild_compile() {
if [ ! -d "${SRCDIR1}" ]
then
echo "${SRCDIR1} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR1}
user_compile_ldap
if [ ! -d "${SRCDIR2}" ]
then
echo "${SRCDIR2} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR2}
user_compile_radius
if [ ! -d "${SRCDIR3}" ]
then
echo "${SRCDIR3} does not exist -- please unpack first."
exit 1
fi
#make sure we're in the right directory
cd ${SRCDIR3}
user_compile_checkuser
} case "${1}" in
unpack)
ebuild_unpack
;;
compile)
ebuild_compile
;;
install)
ebuild_install
;;
all)
ebuild_unpack
ebuild_compile
ebuild_install
;;
*)
echo "Please specify unpack, compile, install or all as the parameter"
exit 1
;;
esac參考資料:http://www-128.ibm.com/developerworks/cn/linux/shell/bash/bash-1/index.html