From c2f7c80c7ef5f6b4f9a51032af88b2fee43cce61 Mon Sep 17 00:00:00 2001 From: tianyu Date: Thu, 6 Nov 2014 14:34:45 +0800 Subject: [PATCH] Update install.sh --- opensips/install.sh | 63 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/opensips/install.sh b/opensips/install.sh index d192100..a7ab970 100644 --- a/opensips/install.sh +++ b/opensips/install.sh @@ -14,16 +14,58 @@ SBINS="opensipsctl opensipsunix osipsconfig opensips opensipsdbctl osipsconsole" BINNAME="opensips" RELEASEBIN="opensips.run" -echo "Install opensips..." - if [ $UID -ne 0 ]; then echo "Superuser privileges are required to run this script." echo "e.g. \"sudo ./$RELEASEBIN\"" exit 0 fi +if [ ! -z "$1" ];then + if [ $1 = "install" ];then + echo "Install opensips..." + elif [ $1 = "uninstall" ];then + echo "Uninstall opensips..." + for file in $SBINS;do + if [ -f "/$BINDIR/$file" ];then + echo "uninstall /$BINDIR/$file" + rm -f /$BINDIR/$file + fi + done + if [ -d "/$LIBDIR/$BINNAME" ];then + echo "removing /$LIBDIR/$BINNAME" + rm -rf /$LIBDIR/$BINNAME + fi + echo "Uninstall completed." + exit 0 + elif [ $1 = "purge" ];then + echo "Purge opensips..." + for file in $SBINS;do + if [ -f "/$BINDIR/$file" ];then + echo "purge /$BINDIR/$file" + rm -f /$BINDIR/$file + fi + done + if [ -d "/$LIBDIR/$BINNAME" ];then + echo "purge /$LIBDIR/$BINNAME" + rm -rf /$LIBDIR/$BINNAME + fi + if [ -d "/$ETCDIR/$BINNAME" ];then + echo "purge /$ETCDIR/$BINNAME" + rm -rf /$ETCDIR/$BINNAME + fi + echo "Purge completed." + exit 0 + else + echo "Unknow param, exit." + exit 0 + fi +else + echo "Install opensips..." +fi + echo -e "Checking for a supported OS... \c" +FAIL="true" if [ "$(echo -e $(cat /etc/issue |head -n1)|head -n1)" = "$(cat os)" ];then echo "OK" FAIL="false" @@ -34,15 +76,21 @@ else FAIL="false" fi fi - if [ ! $FAIL = "false" ];then + + # disable os check. + if [ ! "$FAIL" = "false" ];then + echo "OK" + FAIL="false" + fi + + + if [ ! "$FAIL" = "false" ];then echo "This file can only installed on $(cat os), abort." FAIL="true" fi fi -# Ignore OS check. -FAIL="false" -echo "OK" +if [ ! $FAIL = "true" ]; then echo -e "Checking for a 64-bit OS... \c" @@ -54,6 +102,8 @@ else FAIL="true" fi +fi + if [ $FAIL = "true" ];then echo "Aborting installation due to unsatisfied requirements." echo "Installation failed." @@ -82,4 +132,3 @@ fi cp -r $LIBDIR/$BINNAME /$LIBDIR/$BINNAME echo "Done. Please edit necessary configures to run opensips." -