Update install.sh

This commit is contained in:
tianyu 2014-11-06 14:34:45 +08:00
parent ff7280c632
commit c2f7c80c7e
1 changed files with 56 additions and 7 deletions

View File

@ -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."