From d078d40a7789d63cc593da4d6ebbe0c91b47fc4d Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Fri, 19 Jul 2024 11:51:53 -0500 Subject: [PATCH] Add hopeful method to list-packages as requested in #576 --- bin/installfog.sh | 11 ++- lib/common/functions.sh | 126 ++++++++++++++++++++++++++ packages/web/lib/fog/system.class.php | 2 +- 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/bin/installfog.sh b/bin/installfog.sh index d6a578fd60..d57fdcf497 100755 --- a/bin/installfog.sh +++ b/bin/installfog.sh @@ -78,11 +78,12 @@ usage() { echo -e "\t-T --no-tftpbuild\t\tDo not rebuild the tftpd config file" echo -e "\t-F --no-vhost\t\tDo not overwrite vhost file" echo -e "\t-A --arm-support\t\tInstall kernel and initrd for ARM platforms" + echo -e "\t-l --list-packages\t\tList of the basic packages FOG needs for install or is currently installed for FOG" exit 0 } -shortopts="h?odEUHSCKYyXxTPFAf:c:W:D:B:s:e:b:N:" -longopts="help,uninstall,ssl-path:,oldcopy,no-vhost,no-defaults,no-upgrade,no-htmldoc,force-https,recreate-keys,recreate-CA,recreate-Ca,recreate-cA,recreate-ca,autoaccept,file:,docroot:,webroot:,backuppath:,startrange:,endrange:,bootfile:,no-exportbuild,exitFail,no-tftpbuild,arm-support" +shortopts="h?odEUHSCKYyXxTPFAf:c:W:D:B:s:e:b:N:l" +longopts="help,uninstall,ssl-path:,oldcopy,no-vhost,no-defaults,no-upgrade,no-htmldoc,force-https,recreate-keys,recreate-CA,recreate-Ca,recreate-cA,recreate-ca,autoaccept,file:,docroot:,webroot:,backuppath:,startrange:,endrange:,bootfile:,no-exportbuild,exitFail,no-tftpbuild,arm-support,list-packages" optargs=$(getopt -o $shortopts -l $longopts -n "$0" -- "$@") [[ $? -ne 0 ]] && usage @@ -228,6 +229,10 @@ while :; do sarmsupport=1 shift ;; + -l | --list-packages) + listPackages=1 + shift + ;; --) shift break @@ -248,6 +253,7 @@ elif [[ -f /etc/debian_version ]]; then fi linuxReleaseName_lower=$(echo "$linuxReleaseName" | tr [:upper:] [:lower:]) +listPackages echo "Installing LSB_Release as needed" dots "Attempting to get release information" @@ -392,6 +398,7 @@ echo " * Interface: $interface" echo " * Server IP Address: $ipaddress" echo " * Server Subnet Mask: $submask" echo " * Hostname: $hostname" +echo case $installtype in N) echo " * Installation Type: Normal Server" diff --git a/lib/common/functions.sh b/lib/common/functions.sh index e30c4ee954..a02b200500 100755 --- a/lib/common/functions.sh +++ b/lib/common/functions.sh @@ -384,6 +384,129 @@ getAllNetworkInterfaces() { fi echo -n $interfaces } +listPackages() { + if [[ $listPackages != 1 ]]; then + return + fi + . ../lib/common/config.sh + [[ -z $fogpriorconfig ]] && fogpriorconfig="$fogprogramdir/.fogsettings" + if [[ -f $fogpriorconfig ]]; then + . "$fogpriorconfig" + case $osid in + 1) + osname="Redhat" + . ../lib/redhat/config.sh + ;; + 2) + osname="Debian" + . ../lib/ubuntu/config.sh + ;; + 3) + osname="Alpine" + . ../lib/alpine/config.sh + ;; + esac + else + case $linuxReleaseName_lower in + *fedora*|*red*hat*|*centos*|*mageia*|*alma*|*rocky*) + osid=1 + osname="Redhat" + . ../lib/redhat/config.sh + ;; + *ubuntu*|*bian*|*mint*) + osid=2 + osname="Debian" + . ../lib/ubuntu/config.sh + ;; + *alpine*) + osid=3 + osname="Alpine" + . ../lib/alpine/config.sh + ;; + *) + echo "Could not define OS" + exit 1 + ;; + esac + fi + if [[ $ignorehtmldoc -eq 1 ]]; then + [[ -z $newpackagelist ]] && newpackagelist="" + for z in $packages; do + [[ -$z != htmldoc ]] && newpackagelist="$newpackagelist $z" + done + packages=$(echo $newpackagelist) + fi + if [[ $bldhcp == 0 ]]; then + [[ -z $newpackagelist ]] && newpackagelist="" + for z in $packages; do + [[ -$z != $dhcpname ]] && newpackagelist="$newpackagelist $z" + done + packages=$(echo $newpackagelist) + fi + case $installtype in + [Ss]) + packages=$(echo $packages | sed -e 's/[-a-zA-Z]*dhcp[-a-zA-Z]*//g') + ;; + esac + packages="$packages jq unzip attr ${webserver}" + case $osid in + 1) + packages="$packages php-bcmath bc" + if [[ $installlang -eq 1 ]]; then + packages="$packages php-intl" + for i in fr de eu es pt zh en; do + packages="$packages glibc-langpack-${i}" + done + fi + packages="${packages// mod_fastcgi/}" + packages="${packages// mod_evasive/}" + packages="${packages// php-mcrypt/}" + case $linuxReleaseName_lower in + *fedora*) + packages="$packages php-json" + packages="${packages// mysql / mariadb }" + packages="${packages// mysql-server / mariadb-server }" + packages="${packages// dhcp / dhcp-server }" + esac + ;; + 2) + if [[ $webserver == "apache2" ]]; then + packages="${packages// libapache2-mod-fastcgi/}" + packages="${packages// libapache2-mod-evasive/}" + fi + packages="${packages// xinetd/}" + packages="${packages// php-gettext/}" + packages="${packages// php-php-gettext/}" + if [[ $installlang -eq 1 ]]; then + packages="$packages php-intl" + if [[ $installlang -eq 1 ]]; then + for i in fr de eu es pt zh-hans en; do + packages="$packages language-pack-${i}" + done + fi + fi + case $linuxReleaseName_lower in + *ubuntu*|*mint*) + if [[ $OSVersion -gt 17 ]]; then + packages="${packages// libcurl3 / libcurl4}" + fi + if [[ $OSVersion -gt 22 ]]; then + packages="${packages// libcurl4 / libcurl4t64}" + fi + esac + ;; + *bian*) + if [[ $OSVersion -ge 10 ]]; then + packages="${packages// libcurl3 / libcurl4}" + packages="${packages// mysql-client / mariadb-client}" + packages="${packages// mysql-server / mariadb-server}" + fi + ;; + esac + packages=$(echo ${packages[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ') + echo $packages; + exit 0; +} checkInternetConnection() { dots "Testing internet connection" DEBIAN_FRONTEND=noninteractive $packageinstaller curl >>$error_log 2>&1 @@ -743,6 +866,9 @@ installPackages() { if [[ $OSVersion -gt 17 ]]; then packages="${packages// libcurl3 / libcurl4 }">>$error_log 2>&1 fi + if [[ $OSVersion -gt 22 ]]; then + packages="${packages// libcurl4 / libcurl4t64 }">>$error_log 2>&1 + fi if [[ $linuxReleaseName_lower == +(*ubuntu*) && $OSVersion -ge 18 ]]; then # Fix missing universe section for Ubuntu 18.04 LIVE LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y universe >>$error_log 2>&1 diff --git a/packages/web/lib/fog/system.class.php b/packages/web/lib/fog/system.class.php index d7265ab378..6971cc9ddb 100644 --- a/packages/web/lib/fog/system.class.php +++ b/packages/web/lib/fog/system.class.php @@ -59,7 +59,7 @@ private static function _versionCompare() public function __construct() { self::_versionCompare(); - define('FOG_VERSION', '1.6.0-alpha.1371'); + define('FOG_VERSION', '1.6.0-alpha.1372'); define('FOG_CHANNEL', 'Alpha'); define('FOG_SCHEMA', 290); define('FOG_BCACHE_VER', 147);