#!/bin/sh
if ! [ "root" = "$(id -u -n)" ]; then
echo "ERROR: ${0} must be run as root!"; exit 1
fi
if ! [ "-y" = "${1}" ]; then
printf "Did you stop your node(s) first? (y/n) [n]: "; read -r CONFIRM
if ! [ "${CONFIRM}" = "y" ] && ! [ "${CONFIRM}" = "Y" ]; then
exit 1
fi
fi
if [ -f /etc/fedora-release ]; then
systemctl stop httpd
systemctl stop php-fpm
dnf -y --refresh update
systemctl start php-fpm
systemctl start httpd
elif [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
systemctl stop httpd
systemctl stop php-fpm
yum clean expire-cache
yum -y update
systemctl start php-fpm
systemctl start httpd
elif [ -f /etc/debian_version ]; then
PHP_VERSION=$(/usr/sbin/phpquery -V)
systemctl stop apache2
systemctl stop "php${PHP_VERSION}-fpm"
apt update
apt -y dist-upgrade
systemctl start "php${PHP_VERSION}-fpm"
systemctl start apache2
else
echo "ERROR: OS not supported!"
exit 1
fi