- echo -e " --forcedb: reinstall vim_db DB, deleting previous database if exists and creating a new one"
- echo -e " --no-install-packages: <deprecate> use this option to skip updating and installing the requires packages. This avoid wasting time if you are sure requires packages are present e.g. because of a previous installation"
- echo -e " --unistall: Delete DB, by default vim_db"
+ echo -e " --forcedb: if database exists, it is dropped and a new one is created"
+ echo -e " --updatedb: if database exists, it preserves the content and it is updated to the needed version"
+ echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This avoid wasting time if you are sure requires packages are present e.g. because of a previous installation"
+ echo -e " --unistall: delete database"
+}
+
+function install_packages(){
+ [ -x /usr/bin/apt-get ] && apt-get install -y $*
+ [ -x /usr/bin/yum ] && yum install -y $*
+
+ #check properly installed
+ for PACKAGE in $*
+ do
+ PACKAGE_INSTALLED="no"
+ [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
+ [ -x /usr/bin/yum ] && yum list installed $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
+ if [ "$PACKAGE_INSTALLED" = "no" ]
+ then
+ echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
+ exit 1
+ fi
+ done
+}
+
+function _install_mysql_package(){
+ echo '
+ #################################################################
+ ##### INSTALL REQUIRED PACKAGES #####
+ #################################################################'
+ [ "$_DISTRO" == "Ubuntu" ] && ! install_packages "mysql-server" && exit 1
+ [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && ! install_packages "mariadb mariadb-server" && exit 1