add backup
This commit is contained in:
parent
aa3bc7d33e
commit
245ea6641b
|
@ -15,6 +15,8 @@ SBINS="opensipsctl opensipsunix osipsconfig opensips opensipsdbctl osipsconsole"
|
||||||
BINNAME="opensips"
|
BINNAME="opensips"
|
||||||
RELEASEBIN="opensips.run"
|
RELEASEBIN="opensips.run"
|
||||||
RUNSCRIPT="install.sh"
|
RUNSCRIPT="install.sh"
|
||||||
|
BACKUP="no"
|
||||||
|
RELEASEDIR="release"
|
||||||
|
|
||||||
if [ $UID -ne 0 ]; then
|
if [ $UID -ne 0 ]; then
|
||||||
echo "Superuser privileges are required to run this script."
|
echo "Superuser privileges are required to run this script."
|
||||||
|
@ -28,10 +30,25 @@ if [ ! -z $1 ]; then
|
||||||
if [ -d "archive" ]; then
|
if [ -d "archive" ]; then
|
||||||
rm -rf archive
|
rm -rf archive
|
||||||
fi
|
fi
|
||||||
if [ -d "release" ]; then
|
if [ -n "$2" ] && [ "$2" = "--backup" ]; then
|
||||||
rm -rf release
|
echo "cleaning backup..."
|
||||||
|
RELEASEDIR="backup"
|
||||||
|
fi
|
||||||
|
if [ -d "$RELEASEDIR" ]; then
|
||||||
|
rm -rf $RELEASEDIR
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [ "$1" = "--backup" ]; then
|
||||||
|
echo "create backup..."
|
||||||
|
RELEASEBIN="opensips-backup-"$(date +%F-%H-%M-%S)".run"
|
||||||
|
RELEASEDIR="backup"
|
||||||
|
BACKUP="yes"
|
||||||
|
if [ -d "archive" ]; then
|
||||||
|
rm -rf archive
|
||||||
|
fi
|
||||||
|
if [ -d "$RELEASEDIR" ]; then
|
||||||
|
rm -rf $RELEASEDIR
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "unknow param: $1"
|
echo "unknow param: $1"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -71,17 +88,31 @@ else
|
||||||
mkdir $ETCDIR/default
|
mkdir $ETCDIR/default
|
||||||
mkdir $ETCDIR/init.d
|
mkdir $ETCDIR/init.d
|
||||||
if [ -n "$(command -v apt-get)" ]; then
|
if [ -n "$(command -v apt-get)" ]; then
|
||||||
echo "copying ../packaging/debian/$BINNAME.default ..."
|
if [ "$BACKUP" = "no" ]; then
|
||||||
cp ../packaging/debian/$BINNAME.default $ETCDIR/default
|
echo "copying ../packaging/debian/$BINNAME.default ..."
|
||||||
echo "copying ../packaging/debian/$BINNAME.init..."
|
cp ../packaging/debian/$BINNAME.default $ETCDIR/default
|
||||||
cp ../packaging/debian/$BINNAME.init $ETCDIR/init.d
|
echo "copying ../packaging/debian/$BINNAME.init ..."
|
||||||
cp ../packaging/debian/$BINNAME.postinst $ETCDIR/
|
cp ../packaging/debian/$BINNAME.init $ETCDIR/init.d
|
||||||
|
cp ../packaging/debian/$BINNAME.postinst $ETCDIR/
|
||||||
|
else
|
||||||
|
echo "backup /etc/default/$BINNAME ..."
|
||||||
|
cp /etc/default/$BINNAME $ETCDIR/default/$BINNAME.default
|
||||||
|
echo "backup /etc/init.d/$BINNAME ..."
|
||||||
|
cp /etc/init.d/$BINNAME $ETCDIR/init.d/$BINNAME.init
|
||||||
|
fi
|
||||||
elif [ -n "$(command -v yum)" ]; then
|
elif [ -n "$(command -v yum)" ]; then
|
||||||
echo "copying ../packaging/debian/$BINNAME.default ..."
|
if [ "$BACKUP" = "no" ]; then
|
||||||
cp ../packaging/rpm/$BINNAME.default $ETCDIR/default
|
echo "copying ../packaging/debian/$BINNAME.default ..."
|
||||||
echo "copying ../packaging/debian/$BINNAME.init ..."
|
cp ../packaging/rpm/$BINNAME.default $ETCDIR/default
|
||||||
cp ../packaging/rpm/$BINNAME.init $ETCDIR/init.d
|
echo "copying ../packaging/debian/$BINNAME.init ..."
|
||||||
cp ../packaging/rpm/$BINNAME.postinst $ETCDIR/
|
cp ../packaging/rpm/$BINNAME.init $ETCDIR/init.d
|
||||||
|
cp ../packaging/rpm/$BINNAME.postinst $ETCDIR/
|
||||||
|
else
|
||||||
|
echo "backup /etc/default/$BINNAME ..."
|
||||||
|
cp /etc/default/$BINNAME $ETCDIR/default/$BINNAME.default
|
||||||
|
echo "backup /etc/init.d/$BINNAME ..."
|
||||||
|
cp /etc/init.d/$BINNAME $ETCDIR/init.d/$BINNAME.init
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -230,11 +261,15 @@ if [ -d "/$ETCDIR/$BINNAME" ];then
|
||||||
echo "install $BINNAME.init to /$ETCDIR/init.d/$BINNAME..."
|
echo "install $BINNAME.init to /$ETCDIR/init.d/$BINNAME..."
|
||||||
cp $ETCDIR/init.d/$BINNAME.init /$ETCDIR/init.d/$BINNAME
|
cp $ETCDIR/init.d/$BINNAME.init /$ETCDIR/init.d/$BINNAME
|
||||||
chmod +x /$ETCDIR/init.d/$BINNAME
|
chmod +x /$ETCDIR/init.d/$BINNAME
|
||||||
if [ -n $(command -v apt-get) ]; then
|
if [ -n "$(command -v apt-get)" ]; then
|
||||||
bash $ETCDIR/$BINNAME.postinst configure
|
if [ -f "$ETCDIR/$BINNAME.postinst" ]; then
|
||||||
elif [ -n $(command -v yum) ]; then
|
bash $ETCDIR/$BINNAME.postinst configure
|
||||||
bash $ETCDIR/$BINNAME.postinst configure
|
fi
|
||||||
passwd -l opensips
|
elif [ -n "$(command -v yum)" ]; then
|
||||||
|
if [ -f "$ETCDIR/$BINNAME.postinst" ]; then
|
||||||
|
bash $ETCDIR/$BINNAME.postinst configure
|
||||||
|
passwd -l opensips
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cp -r $ETCDIR/$BINNAME /$ETCDIR
|
cp -r $ETCDIR/$BINNAME /$ETCDIR
|
||||||
|
@ -253,12 +288,12 @@ chmod +x archive/$RUNSCRIPT
|
||||||
rm -rf archive
|
rm -rf archive
|
||||||
|
|
||||||
if [ -f "$RELEASEBIN" ]; then
|
if [ -f "$RELEASEBIN" ]; then
|
||||||
if [ -d "release" ]; then
|
if [ -d "$RELEASEDIR" ]; then
|
||||||
rm -rf release
|
rm -rf $RELEASEDIR
|
||||||
fi
|
fi
|
||||||
mkdir release
|
mkdir $RELEASEDIR
|
||||||
mv $RELEASEBIN release
|
mv $RELEASEBIN $RELEASEDIR
|
||||||
echo "Done. Please check file release/$RELEASEBIN"
|
echo "Done. Please check file \"$RELEASEDIR/$RELEASEBIN\""
|
||||||
else
|
else
|
||||||
echo "Error detected."
|
echo "Error detected."
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue