summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2018-03-05 13:22:47 +0000
committerramon <ramongomez@us.es>2018-03-05 13:22:47 +0000
commita37e5fc4e8bf00123a5f738f2b32ba360bb45e81 (patch)
treeb4ffe72d2b68e2f3a0094290caad087681b4355e
parent0563f44728ba09569581804f29a0a56235f3644d (diff)
#804: Instalar y actualizar a PHP 7.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5638 a21b9725-9963-47de-94b9-378ad31fedc9
-rwxr-xr-xinstaller/opengnsys_installer.sh24
-rwxr-xr-xinstaller/opengnsys_update.sh97
2 files changed, 68 insertions, 53 deletions
diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh
index 96fd0737..4e1061f0 100755
--- a/installer/opengnsys_installer.sh
+++ b/installer/opengnsys_installer.sh
@@ -167,7 +167,7 @@ OSVERSION="${OSVERSION%%.*}"
# Configuración según la distribución GNU/Linux (usar minúsculas).
case "$OSDISTRIB" in
ubuntu|debian|linuxmint)
- DEPENDENCIES=( subversion apache2 php5 php5-ldap libapache2-mod-php5 mysql-server php5-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient15-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php5-curl gettext moreutils jq wakeonlan )
+ DEPENDENCIES=( subversion apache2 php php-ldap libapache2-mod-php mysql-server php-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient15-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan )
UPDATEPKGLIST="apt-get update"
INSTALLPKG="apt-get -y install --force-yes"
CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install"
@@ -277,7 +277,7 @@ selinuxenabled 2>/dev/null && setenforce 0 2>/dev/null
# dependiendo de la versión instalada.
function updatePackageList()
{
-local DHCPVERSION PHP5VERSION
+local DHCPVERSION PHP7VERSION
# Si es necesario, actualizar la lista de paquetes disponibles.
[ -n "$UPDATEPKGLIST" ] && eval $UPDATEPKGLIST
@@ -294,27 +294,25 @@ case "$OSDISTRIB" in
DHCPSERV=dhcp3-server
DHCPCFGDIR=/etc/dhcp3
fi
- # Configuración para PHP 5 en Ubuntu 16.x+.
- if [ -z "$(apt-cache pkgnames php5)" ]; then
+ # Configuración para PHP 7 en Ubuntu.
+ if [ -z "$(apt-cache pkgnames php7)" ]; then
eval $INSTALLPKG software-properties-common
add-apt-repository -y ppa:ondrej/php
eval $UPDATEPKGLIST
fi
- PHP5VERSION=$(apt-cache pkgnames php5 | sort | head -1)
- DEPENDENCIES=( ${DEPENDENCIES[@]//php5/$PHP5VERSION} )
+ PHP7VERSION=$(apt-cache pkgnames php7 | sort | head -1)
+ DEPENDENCIES=( ${DEPENDENCIES[@]//php/$PHP7VERSION} )
# Dependencias correctas para libmysqlclient.
[ -z "$(apt-cache pkgnames libmysqlclient15)" ] && DEPENDENCIES=( ${DEPENDENCIES[@]//libmysqlclient15/libmysqlclient} )
;;
centos) # Postconfiguación personalizada para CentOS.
- # Configuración para PHP 5.
- if ! yum list php5\*w &>/dev/null; then
- if [ $OSVERSION -ge 7 ]; then
- yum install -y https://mirror.webtatic.com/yum/el$OSVERSION/webtatic-release.rpm
- else
+ # Configuración para PHP 7.
+ if ! yum list php7 &>/dev/null; then
+ if [ $OSVERSION -lt 7 ]; then
yum install -y https://mirror.webtatic.com/yum/el$OSVERSION/latest.rpm
+ PHP7VERSION=$(yum list -q php7\*w | awk -F. '/^php/ {p=$1} END {print p}')
+ DEPENDENCIES=( ${DEPENDENCIES[@]//php/$PHP5VERSION} )
fi
- PHP5VERSION=$(yum list -q php5\*w | awk -F. '/^php/ {p=$1} END {print p}')
- DEPENDENCIES=( ${DEPENDENCIES[@]//php/$PHP5VERSION} )
fi
# Cambios a aplicar a partir de CentOS 7.
if [ $OSVERSION -ge 7 ]; then
diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh
index 556e06ef..6a2e7462 100755
--- a/installer/opengnsys_update.sh
+++ b/installer/opengnsys_update.sh
@@ -96,69 +96,75 @@ LOG_FILE=/tmp/$(basename $OGLOGFILE)
# - APACHECFGDIR, APACHESERV, DHCPSERV, INETDCFGDIR - configuración y servicios
function autoConfigure()
{
-local i
+ local service
-# Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
-if [ -f /etc/os-release ]; then
- source /etc/os-release
- OSDISTRIB="$ID"
- OSVERSION="$VERSION_ID"
-else
- OSDISTRIB=$(lsb_release -is 2>/dev/null)
- OSVERSION=$(lsb_release -rs 2>/dev/null)
-fi
-# Convertir distribución a minúsculas y obtener solo el 1er número de versión.
-OSDISTRIB="${OSDISTRIB,,}"
-OSVERSION="${OSVERSION%%.*}"
-
-# Configuración según la distribución de Linux.
-case "$OSDISTRIB" in
- ubuntu|debian|linuxmint)
- DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php5-curl gettext moreutils jq wakeonlan )
+ # Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
+ if [ -f /etc/os-release ]; then
+ source /etc/os-release
+ OSDISTRIB="$ID"
+ OSVERSION="$VERSION_ID"
+ else
+ OSDISTRIB=$(lsb_release -is 2>/dev/null)
+ OSVERSION=$(lsb_release -rs 2>/dev/null)
+ fi
+ # Convertir distribución a minúsculas y obtener solo el 1er número de versión.
+ OSDISTRIB="${OSDISTRIB,,}"
+ OSVERSION="${OSVERSION%%.*}"
+
+ # Configuración según la distribución de Linux.
+ if [ -f /etc/debian_version ]; then
+ # Distribución basada en paquetes Deb.
+ DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan )
UPDATEPKGLIST="add-apt-repository -y ppa:ondrej/php; apt-get update"
- INSTALLPKGS="apt-get -y install --force-yes"
+ INSTALLPKGS="apt-get -y install"
+ DELETEPKGS="apt-get -y purge"
CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\""
if which service &>/dev/null; then
STARTSERVICE="eval service \$service restart"
STOPSERVICE="eval service \$service stop"
+ SERVICESTATUS="eval service \$service status"
else
STARTSERVICE="eval /etc/init.d/\$service restart"
STOPSERVICE="eval /etc/init.d/\$service stop"
+ SERVICESTATUS="eval /etc/init.d/\$service status"
fi
ENABLESERVICE="eval update-rc.d \$service defaults"
APACHEUSER="www-data"
APACHEGROUP="www-data"
INETDCFGDIR=/etc/xinetd.d
- ;;
- fedora|centos)
- DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq wakeonlan )
+ elif [ -f /etc/redhat-release ]; then
+ # Distribución basada en paquetes rpm.
+ DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq net-tools )
# En CentOS 7 instalar arp-scan de CentOS 6.
[ "$OSDISTRIB$OSVERSION" == "centos7" ] && DEPENDENCIES=( ${DEPENDENCIES[*]/arp-scan/http://dag.wieers.com/redhat/el6/en/$(arch)/dag/RPMS/arp-scan-1.9-1.el6.rf.$(arch).rpm} )
INSTALLPKGS="yum install -y"
+ DELETEPKGS="yum remove -y"
CHECKPKG="rpm -q --quiet \$package"
if which systemctl &>/dev/null; then
- STARTSERVICE="eval systemctl start \$service.service"
+ STARTSERVICE="eval systemctl restart \$service.service"
STOPSERVICE="eval systemctl stop \$service.service"
ENABLESERVICE="eval systemctl enable \$service.service"
+ SERVICESTATUS="eval systemctl status \$service.service"
else
- STARTSERVICE="eval service \$service start"
+ STARTSERVICE="eval service \$service restart"
STOPSERVICE="eval service \$service stop"
ENABLESERVICE="eval chkconfig \$service on"
+ SERVICESTATUS="eval service \$service status"
fi
APACHEUSER="apache"
APACHEGROUP="apache"
INETDCFGDIR=/etc/xinetd.d
- ;;
- *) # Otras distribuciones.
- ;;
-esac
-for i in apache2 httpd; do
- [ -d /etc/$i ] && APACHECFGDIR="/etc/$i"
- [ -f /etc/init.d/$i ] && APACHESERV="/etc/init.d/$i"
-done
-for i in dhcpd dhcpd3-server isc-dhcp-server; do
- [ -f /etc/init.d/$i ] && DHCPSERV="/etc/init.d/$i"
-done
+ else
+ # Otras distribuciones.
+ :
+ fi
+ for service in apache2 httpd; do
+ [ -d /etc/$service ] && APACHECFGDIR="/etc/$service"
+ if $SERVICESTATUS &>/dev/null; then APACHESERV="$service"; fi
+ done
+ for service in dhcpd dhcpd3-server isc-dhcp-server; do
+ if $SERVICESTATUS &>/dev/null; then DHCPSERV="$service"; fi
+ done
}
@@ -355,17 +361,28 @@ function installDependencies()
{
local package
+ # Comprobar si hay que actualizar PHP 5 a PHP 7.
+ eval $UPDATEPKGLIST
+ if [ -f /etc/debian_version ]; then
+ # Basado en paquetes Deb.
+ PHP7VERSION=$(apt-cache pkgnames php7 2>/dev/null | sort | head -1)
+ PHP5PKGS=( $(dpkg -l |awk '$2~/^php5/ {print $2}') )
+ if [ -n "$PHP5PKGS" ]; then
+ $DELETEPKGS ${PHP5PKGS[@]}
+ PHP5PKGS[0]=$PHP7VERSION
+ INSTALLDEPS=${PHP5PKGS[@]//php5*-/${PHP7VERSION}-}
+ fi
+ fi
+
if [ $# = 0 ]; then
echoAndLog "${FUNCNAME}(): no dependencies are needed"
else
- PHP5VERSION=$(apt-cache pkgnames php5 2>/dev/null | sort | head -1)
while [ $# -gt 0 ]; do
- package="${1/php5/$PHP5VERSION}"
+ package="${1/php/$PHP7VERSION}"
eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $package"
shift
done
if [ -n "$INSTALLDEPS" ]; then
- $UPDATEPKGLIST
$INSTALLPKGS $INSTALLDEPS
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS"
@@ -526,7 +543,7 @@ function apacheConfiguration ()
done
# Reiniciar Apache.
- $APACHESERV restart
+ service=$APACHESERV; $STARTSERCICE
# Variables de ejecución de Apache.
# - APACHE_RUN_USER
@@ -822,7 +839,7 @@ function updateServerFiles()
if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then
echoAndLog "${FUNCNAME}(): updating DHCP files"
perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf
- $DHCPSERV restart
+ service=$DHCPSERV; $STARTSERVICE
NEWFILES="/etc/dhcp*/dhcpd*.conf"
fi
if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then