From 1b222cdf1697975a5fae27f7c891c96fb9cd1a2e Mon Sep 17 00:00:00 2001 From: tianyu Date: Thu, 6 Nov 2014 11:11:05 +0800 Subject: [PATCH] Update and rename build-release.sh to build.sh --- opensips/build-release.sh | 0 opensips/build.sh | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) delete mode 100644 opensips/build-release.sh create mode 100644 opensips/build.sh diff --git a/opensips/build-release.sh b/opensips/build-release.sh deleted file mode 100644 index e69de29..0000000 diff --git a/opensips/build.sh b/opensips/build.sh new file mode 100644 index 0000000..253b3ff --- /dev/null +++ b/opensips/build.sh @@ -0,0 +1,100 @@ +#!/bin/bash +#title :build.sh +#description :This script will build a release(opensips.run) file of opensips +#author :xdtianyu@gmail.com +#date :20141105 +#version :1.0 final +#usage :sudo ./build.sh to build the opensips.run, sudo ./build.sh -c to clean release. +#bash_version :4.3.11(1)-release +#============================================================================== + +BINDIR="archive/sbin" +ETCDIR="archive/etc" +LIBDIR="archive/lib64" +SBINS="opensipsctl opensipsunix osipsconfig opensips opensipsdbctl osipsconsole" +BINNAME="opensips" +RELEASEBIN="opensips.run" +RUNSCRIPT="install.sh" + +if [ $UID -ne 0 ]; then + echo "Superuser privileges are required to run this script." + echo "e.g. \"sudo $0\"" + exit 0 +fi + +if [ ! -z $1 ]; then + if [ $1 = "-c" ]; then + echo "cleaning build..." + if [ -d "archive" ]; then + rm -rf archive + fi + if [ -d "release" ]; then + rm -rf release + fi + exit 0 + else + echo "unknow param: $1" + exit 0 + fi +fi + +echo "Build opensips installer..." +if [ ! -d "archive" ]; +then + echo "create directory archive..." +else + echo "recreate directory archive..." + rm -rf archive +fi + +mkdir -p $BINDIR $ETCDIR $LIBDIR + +for bins in $SBINS; +do + if [ ! -f "/sbin/$bins" ]; + then + echo "/sbin/$bins not exist, stop now." + exit 0 + else + echo "copying /sbin/$bins..." + cp /sbin/$bins $BINDIR + fi +done + +if [ ! -d "/etc/$BINNAME" ];then + echo "/etc/$BINNAME not exist, stop now." + exit 0 +else + echo "copying /etc/$BINNAME..." + cp -r /etc/$BINNAME $ETCDIR +fi + +if [ ! -d "/lib64/$BINNAME" ];then + echo "/lib64/$BINNAME not exist, stop now." + exit 0 +else + echo "copying /lib64/$BINNAME..." + cp -r /lib64/$BINNAME $LIBDIR +fi + +echo -e $(cat /etc/issue |head -n1)|head -n1 >archive/os +if [ -f "/etc/redhat-release" ];then + echo -e $(cat /etc/redhat-release |head -n1)|head -n1 >archive/os +fi + +uname -i > archive/hardware + +cp $RUNSCRIPT archive +./makeself.sh archive/ $RELEASEBIN "$RELEASEBIN" ./$RUNSCRIPT +rm -rf archive + +if [ -f "$RELEASEBIN" ]; then + if [ -d "release" ]; then + rm -rf release + fi + mkdir release + mv $RELEASEBIN release + echo "Done. Please check file release/$RELEASEBIN" +else + echo "Error detected." +fi