diff --git a/install.sh b/install.sh index 4e0fdc4..aa071bb 100755 --- a/install.sh +++ b/install.sh @@ -45,6 +45,8 @@ chmod +x $0 #Os/Distro Check os_check=$(lsb_release -is) +[ -z $os_check ] && os_lsb_release_installer +lsb_release -is && os_check=$(lsb_release -is) real_os=$os_check check_major_release=$(lsb_release -rs | cut -d. -f1) check_codename=$(lsb_release -cs) @@ -56,6 +58,23 @@ os_unsupported () { exit 2; } +os_lsb_release_installer () { + if [ -s /etc/centos-release ] || [ -s /etc/fedora-release] || [ -s /etc/redhat-release ] ; then + yum -y install redhat-lsb-core + os_check='CentOS' + elif [ -s /etc/os-release ] && [ .`awk -F'=' '/^ID_LIKE=/ {print $2}' /etc/os-release` = .'debian' ] ; then + apt-get -y install lsb-base lsb-release + os_check='Debian' + fi + + #try to find and use package manager + which yum && { yum -y install redhat-lsb-core ; } + which apt-get && { apt-get -y install lsb-base lsb-release ; } + + #print location and file type + which lsb_release && file $(which lsb_release) +} + os_debian_common () { verbose "Removing the CD image from /etc/apt/sources.list" sed -i '/cdrom:/d' /etc/apt/sources.list @@ -64,6 +83,14 @@ os_debian_common () { verbose "Installing Git" apt-get install -y git } + +os_centos_common () { + verbose "Updating system before starting." + yum -y update + verbose "Installing Git" + yum install -y git +} + os_fetch_installer () { if [ ! -d /usr/src ]; then mkdir -vp /usr/src @@ -86,6 +113,14 @@ if [ .$os_check = .'Ubuntu' ]; then echo "${yellow}Detected Ubuntu, using Debian for compatibility${normal}" os_check="Debian" fi +if [ .$os_check = .'Fedora' ]; then + echo "${yellow}Detected Fedora, using CentOS for compatibility${normal}" + os_check="CentOS" +fi +if [ .$os_check = .'RedHatEnterpriseServer' ]; then + echo "${yellow}Detected RedHatEnterpriseServer, using CentOS for compatibility${normal}" + os_check="CentOS" +fi if [ .$os_check = .'Debian' ]; then if [ .$real_os = .'Debian' ]; then echo "${yellow}Detected Debian${normal}" @@ -112,6 +147,42 @@ if [ .$os_check = .'Debian' ]; then cd /usr/src/fusionpbx-install.sh/debian ./install.sh $@ fi +elif [ .$os_check = .'CentOS' ]; then + if [ .$real_os = .'CentOS' ]; then + echo "${yellow}Detected CentOS${normal}" + if [ $check_major_release -ge 7 ]; then + os_centos_continue='true' + else + os_centos_continue='false' + error "Although you are running $real_os we require version >= 7" + os_unsupported + fi + fi + if [ .$real_os = .'Fedora' ]; then + echo "${yellow}Detected Fedora${normal}" + if [ $check_major_release -ge 19 ]; then + os_centos_continue='true' + else + os_centos_continue='false' + error "Although you are running $real_os we require version >= 19" + os_unsupported + fi + fi + if [ .$real_os = .'RedHatEnterpriseServer' ]; then + if [ $check_major_release -ge 7 ]; then + os_centos_continue='true' + else + os_centos_continue='false' + error "Although you are running $real_os we require version >= 7" + os_unsupported + fi + fi + if [ .$os_centos_continue = .'true' ]; then + os_centos_common + os_fetch_installer + cd /usr/src/fusionpbx-install.sh/centos + ./install.sh $@ + fi else os_unsupported fi