"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/common/functions.sh" between
fogproject-1.5.5.tar.gz and fogproject-1.5.6.tar.gz

About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.

functions.sh  (fogproject-1.5.5):functions.sh  (fogproject-1.5.6)
skipping to change at line 63 skipping to change at line 63
if [[ -d $backupPath/fog_web_${version}.BACKUP ]]; then if [[ -d $backupPath/fog_web_${version}.BACKUP ]]; then
[[ ! -d $backupPath/fogDBbackups ]] && mkdir -p $backupPath/fogDBbackups >>$workingdir/error_logs/fog_error_${version}.log 2>&1 [[ ! -d $backupPath/fogDBbackups ]] && mkdir -p $backupPath/fogDBbackups >>$workingdir/error_logs/fog_error_${version}.log 2>&1
wget --no-check-certificate -O $backupPath/fogDBbackups/fog_sql_${versio n}_$(date +"%Y%m%d_%I%M%S").sql "${httpproto}://$ipaddress/$webroot/maintenance/ backup_db.php" --post-data="type=sql&fogajaxonly=1" >>$workingdir/error_logs/fog _error_${version}.log 2>&1 wget --no-check-certificate -O $backupPath/fogDBbackups/fog_sql_${versio n}_$(date +"%Y%m%d_%I%M%S").sql "${httpproto}://$ipaddress/$webroot/maintenance/ backup_db.php" --post-data="type=sql&fogajaxonly=1" >>$workingdir/error_logs/fog _error_${version}.log 2>&1
fi fi
errorStat $? errorStat $?
} }
updateDB() { updateDB() {
case $dbupdate in case $dbupdate in
[Yy]|[Yy][Ee][Ss]) [Yy]|[Yy][Ee][Ss])
dots "Updating Database" dots "Updating Database"
local replace='s/[]"\/$&*.^|[]/\\&/g'
local escstorageLocation=$(echo $storageLocation | sed -e $replace)
sed -i -e "s/'\/images\/'/'$escstorageLocation'/g" $webdirdest/commo
ns/schema.php
wget --no-check-certificate -qO - --post-data="confirm&fogverified" --no-proxy ${httpproto}://${ipaddress}/${webroot}management/index.php?node=schem a >>$workingdir/error_logs/fog_error_${version}.log 2>&1 wget --no-check-certificate -qO - --post-data="confirm&fogverified" --no-proxy ${httpproto}://${ipaddress}/${webroot}management/index.php?node=schem a >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
;; ;;
*) *)
echo echo
echo " * You still need to install/update your database schema." echo " * You still need to install/update your database schema."
echo " * This can be done by opening a web browser and going to:" echo " * This can be done by opening a web browser and going to:"
echo echo
echo " $httpproto://${ipaddress}/fog/management" echo " $httpproto://${ipaddress}/fog/management"
echo echo
skipping to change at line 299 skipping to change at line 302
fi fi
numRollOver=$((octet2 / maxOctetValue)) numRollOver=$((octet2 / maxOctetValue))
let octet2-=$((numRollOver * maxOctetValue)) let octet2-=$((numRollOver * maxOctetValue))
let octet1+=$numRollOver let octet1+=$numRollOver
if [[ $octet1 -lt $maxOctetValue && $octet1 -ge 0 ]]; then if [[ $octet1 -lt $maxOctetValue && $octet1 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4 printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4
return 0 return 0
fi fi
return 1 return 1
} }
getFirstGoodInterface() { getAllNetworkInterfaces() {
siteToCheckForInternet="www.google.com" #Must be domain name. gatewayif=$(ip -4 route show | grep "^default via" | awk '{print $5}')
ipToCheckForInternet="8.8.8.8" #Must be IP. interfaces="$gatewayif $(ip -4 link | grep -v LOOPBACK | grep UP | awk -F':
[[ -e $workingdir/tempInterfaces.txt ]] && rm -f $workingdir/tempInterfaces. ' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")"
txt >/dev/null 2>&1 echo -n $interfaces
foundinterfaces=$(ip -4 addr | awk -F'(global )' '/global / {print $2}') }
for interface in $foundinterfaces; do checkInternetConnection() {
ping -c 1 $ipToCheckForInternet -I $interface >/dev/null 2>&1 sites=( "k.root-servers.net" "m.root-servers.net" "f.root-servers.net" )
[[ ! $? -eq 0 ]] && continue ips=( "193.0.14.129" "202.12.27.33" "192.5.5.241" )
ping -c 1 $siteToCheckForInternet -I $interface >/dev/null 2>&1 dots "Testing internet connection"
if [[ ! $? -eq 0 ]]; then for i in $(seq 0 2); do
echo "Internet detected on $interface but there seems to be a DNS pr ping -c 1 ${ips[$i]} >/dev/null 2>&1
oblem." >>$workingdir/error_logs/fog_error_${version}.log [[ $? -ne 0 ]] && continue
echo "Check the contents of /etc/resolv." >>$workingdir/error_logs/f ping -c 1 ${sites[$i]} >/dev/null 2>&1
og_error_${version}.log if [[ $? -ne 0 ]]; then
echo "If this is CentOS, RHEL, or Fedora or an other RH variant," >> echo "Internet connection detected but there seems to be a DNS probl
$workingdir/error_logs/fog_error_${version}.log em." | tee -a $workingdir/error_logs/fog_error_${version}.log
echo "also check the DNS entries for /etc/sysconfig/network-scripts/ echo "Check the contents of /etc/resolv.conf" | tee -a $workingdir/e
ifcfg-$interface" >>$workingdir/error_logs/fog_error_${version}.log rror_logs/fog_error_${version}.log
continue echo "If this is CentOS, RHEL, or Fedora or an other RH variant," |
tee -a $workingdir/error_logs/fog_error_${version}.log
echo "also check the DNS entries in /etc/sysconfig/network-scripts/i
fcfg-*" | tee -a $workingdir/error_logs/fog_error_${version}.log
fi fi
echo $interface >> $workingdir/goodInterface.txt echo "Done"
break return
done done
[[ -e $workingdir/tempInterfaces.txt ]] && rm -f $workingdir/tempInterfaces. echo "There was no interface with an active internet connection found." | te
txt >/dev/null 2>&1 e -a $workingdir/error_logs/fog_error_${version}.log
if [[ -e $workingdir/goodInterface.txt ]]; then echo
goodInterface=$(cat $workingdir/goodInterface.txt | head -1)
rm -f $workingdir/goodInterface.txt >/dev/null 2>&1
fi
[[ -n $goodInterface ]] && echo $goodInterface
if [[ -z $goodInterface ]]; then
echo "There was no interface with an active internet connection found."
>>$workingdir/error_logs/fog_error_${version}.log
echo ""
fi
} }
join() { join() {
local IFS="$1" local IFS="$1"
shift shift
echo "$*" echo "$*"
} }
restoreReports() { restoreReports() {
dots "Restoring user reports" dots "Restoring user reports"
if [[ -d $webdirdest/management/reports ]]; then if [[ -d $webdirdest/management/reports ]]; then
if [[ -d ../rpttmp/ ]]; then if [[ -d ../rpttmp/ ]]; then
skipping to change at line 426 skipping to change at line 424
esac esac
;; ;;
esac esac
errorStat $? errorStat $?
} }
configureDefaultiPXEfile() { configureDefaultiPXEfile() {
[[ -z $webroot ]] && webroot='/' [[ -z $webroot ]] && webroot='/'
echo -e "#!ipxe\ncpuid --ext 29 && set arch x86_64 || set arch \${buildar ch}\nparams\nparam mac0 \${net0/mac}\nparam arch \${arch}\nparam platform \${pla tform}\nparam product \${product}\nparam manufacturer \${product}\nparam ipxever \${version}\nparam filename \${filename}\nparam sysuuid \${uuid}\nisset \${net1 /mac} && param mac1 \${net1/mac} || goto bootme\nisset \${net2/mac} && param mac 2 \${net2/mac} || goto bootme\n:bootme\nchain ${httpproto}://$ipaddress${webroot }service/ipxe/boot.php##params" > "$tftpdirdst/default.ipxe" echo -e "#!ipxe\ncpuid --ext 29 && set arch x86_64 || set arch \${buildar ch}\nparams\nparam mac0 \${net0/mac}\nparam arch \${arch}\nparam platform \${pla tform}\nparam product \${product}\nparam manufacturer \${product}\nparam ipxever \${version}\nparam filename \${filename}\nparam sysuuid \${uuid}\nisset \${net1 /mac} && param mac1 \${net1/mac} || goto bootme\nisset \${net2/mac} && param mac 2 \${net2/mac} || goto bootme\n:bootme\nchain ${httpproto}://$ipaddress${webroot }service/ipxe/boot.php##params" > "$tftpdirdst/default.ipxe"
} }
configureTFTPandPXE() { configureTFTPandPXE() {
dots "Setting up and starting TFTP and PXE Servers"
[[ -d ${tftpdirdst}.prev ]] && rm -rf ${tftpdirdst}.prev >>$workingdir/error _logs/fog_error_${version}.log 2>&1 [[ -d ${tftpdirdst}.prev ]] && rm -rf ${tftpdirdst}.prev >>$workingdir/error _logs/fog_error_${version}.log 2>&1
[[ ! -d ${tftpdirdst} ]] && mkdir -p $tftpdirdst >>$workingdir/error_logs/fo g_error_${version}.log 2>&1 [[ ! -d ${tftpdirdst} ]] && mkdir -p $tftpdirdst >>$workingdir/error_logs/fo g_error_${version}.log 2>&1
[[ -e ${tftpdirdst}.fogbackup ]] && rm -rf ${tftpdirdst}.fogbackup >>$workin gdir/error_logs/fog_error_${version}.log 2>&1 [[ -e ${tftpdirdst}.fogbackup ]] && rm -rf ${tftpdirdst}.fogbackup >>$workin gdir/error_logs/fog_error_${version}.log 2>&1
[[ -d $tftpdirdst && ! -d ${tftpdirdst}.prev ]] && mkdir -p ${tftpdirdst}.pr ev >>$workingdir/error_logs/fog_error_${version}.log 2>&1 [[ -d $tftpdirdst && ! -d ${tftpdirdst}.prev ]] && mkdir -p ${tftpdirdst}.pr ev >>$workingdir/error_logs/fog_error_${version}.log 2>&1
[[ -d ${tftpdirdst}.prev ]] && cp -Rf $tftpdirdst/* ${tftpdirdst}.prev/ >>$w orkingdir/error_logs/fog_error_${version}.log 2>&1 [[ -d ${tftpdirdst}.prev ]] && cp -Rf $tftpdirdst/* ${tftpdirdst}.prev/ >>$w orkingdir/error_logs/fog_error_${version}.log 2>&1
if [[ "x$httpproto" = "xhttps" ]]; then
dots "Compiling iPXE binaries that trust our SSL certificate"
cd $buildipxesrc
./buildipxe.sh $sslpath/CA/.fogCA.pem >>$workingdir/error_logs/fog_error
_${version}.log 2>&1
errorStat $?
cd $workingdir
fi
dots "Setting up and starting TFTP and PXE Servers"
cd $tftpdirsrc cd $tftpdirsrc
for tftpdir in $(ls -d */); do for tftpdir in $(ls -d */); do
[[ ! -d $tftpdirdst/$tftpdir ]] && mkdir -p $tftpdirdst/$tftpdir >>$work ingdir/error_logs/fog_error_${version}.log 2>&1 [[ ! -d $tftpdirdst/$tftpdir ]] && mkdir -p $tftpdirdst/$tftpdir >>$work ingdir/error_logs/fog_error_${version}.log 2>&1
done done
local findoptions="" local findoptions=""
[[ $notpxedefaultfile == true ]] && findoptions="! -name default" [[ $notpxedefaultfile == true ]] && findoptions="! -name default"
find -type f $findoptions -exec cp -Rfv {} $tftpdirdst/{} \; >>$workingdir/e rror_logs/fog_error_${version}.log 2>&1 find -type f $findoptions -exec cp -Rfv {} $tftpdirdst/{} \; >>$workingdir/e rror_logs/fog_error_${version}.log 2>&1
cd $workingdir cd $workingdir
chown -R $username $tftpdirdst >>$workingdir/error_logs/fog_error_${version} .log 2>&1 chown -R $username $tftpdirdst >>$workingdir/error_logs/fog_error_${version} .log 2>&1
chown -R $username $webdirdest/service/ipxe >>$workingdir/error_logs/fog_err or_${version}.log 2>&1 chown -R $username $webdirdest/service/ipxe >>$workingdir/error_logs/fog_err or_${version}.log 2>&1
skipping to change at line 534 skipping to change at line 539
echo " */" >> "$webdirdest/management/index.php" echo " */" >> "$webdirdest/management/index.php"
echo "require '../commons/base.inc.php';" >> "$webdirdest/management/index.p hp" echo "require '../commons/base.inc.php';" >> "$webdirdest/management/index.p hp"
echo "require '../commons/text.php';" >> "$webdirdest/management/index.php" echo "require '../commons/text.php';" >> "$webdirdest/management/index.php"
echo "ob_start();" >> "$webdirdest/management/index.php" echo "ob_start();" >> "$webdirdest/management/index.php"
echo "FOGCore::getClass('FOGPageManager')->render();" >> "$webdirdest/manage ment/index.php" echo "FOGCore::getClass('FOGPageManager')->render();" >> "$webdirdest/manage ment/index.php"
echo "ob_end_clean();" >> "$webdirdest/management/index.php" echo "ob_end_clean();" >> "$webdirdest/management/index.php"
echo "die(_('This is a storage node, please do not access the web ui here!') );" >> "$webdirdest/management/index.php" echo "die(_('This is a storage node, please do not access the web ui here!') );" >> "$webdirdest/management/index.php"
} }
addUbuntuRepo() { addUbuntuRepo() {
find /etc/apt/sources.list.d/ -name '*ondrej*' -exec rm -rf {} \; >>$working dir/error_logs/fog_error_${version}.log 2>&1 find /etc/apt/sources.list.d/ -name '*ondrej*' -exec rm -rf {} \; >>$working dir/error_logs/fog_error_${version}.log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller python-software-properties DEBIAN_FRONTEND=noninteractive $packageinstaller python-software-properties
software-properties-common ntpdate >>$workingdir/error_logs/fog_error_${version} >>$workingdir/error_logs/fog_error_${version}.log 2>&1
.log 2>&1 DEBIAN_FRONTEND=noninteractive $packageinstaller software-properties-common
>>$workingdir/error_logs/fog_error_${version}.log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller ntpdate >>$workingdir/error
_logs/fog_error_${version}.log 2>&1
ntpdate pool.ntp.org >>$workingdir/error_logs/fog_error_${version}.log 2>&1 ntpdate pool.ntp.org >>$workingdir/error_logs/fog_error_${version}.log 2>&1
locale-gen 'en_US.UTF-8' >>$workingdir/error_logs/fog_error_${version}.log 2 >&1 locale-gen 'en_US.UTF-8' >>$workingdir/error_logs/fog_error_${version}.log 2 >&1
if [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]*) && $OSVersion -ge 1 8 ]]; then if [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]*) && $OSVersion -ge 1 8 ]]; then
# Fix missing universe section for Ubuntu 18.04 LIVE # 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 > >$workingdir/error_logs/fog_error_${version}.log 2>&1 LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y universe > >$workingdir/error_logs/fog_error_${version}.log 2>&1
else else
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej /${repo} >>$workingdir/error_logs/fog_error_${version}.log 2>&1 LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej /${repo} >>$workingdir/error_logs/fog_error_${version}.log 2>&1
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej /apache2 >>$workingdir/error_logs/fog_error_${version}.log 2>&1 LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej /apache2 >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
return $? return $?
} }
installPackages() { installPackages() {
[[ $installlang -eq 1 ]] && packages="$packages gettext" [[ $installlang -eq 1 ]] && packages="$packages gettext"
packages="$packages unzip" packages="$packages unzip"
dots "Adding needed repository" dots "Adding repository if needed"
case $osid in case $osid in
1) 1)
pkginst=$(command -v dnf)
[[ -z $pkginst ]] && pkginst=$(command -v yum)
pkginst="$pkginst -y install"
packages="$packages php-bcmath bc" packages="$packages php-bcmath bc"
packages="${packages// mod_fastcgi/}" packages="${packages// mod_fastcgi/}"
packages="${packages// mod_evasive/}" packages="${packages// mod_evasive/}"
packages="${packages// php-mcrypt/}"
case $linuxReleaseName in case $linuxReleaseName in
*[Ff][Ee][Dd][Oo][Rr][Aa]*) *[Ff][Ee][Dd][Oo][Rr][Aa]*)
repo="fedora" packages="$packages php-json"
[[ -z $OSVersion ]] && echo "OS Version not detected" packages="${packages// mysql / mariadb }">>$workingdir/error
! [[ $OSVersion =~ ^[0-9]+$ ]] && echo "OS Version not detec _logs/fog_error_${version}.log 2>&1
ted properly." packages="${packages// mysql-server / mariadb-server }">>$wo
if [[ $OSVersion -ge 22 ]]; then rkingdir/error_logs/fog_error_${version}.log 2>&1
packages="${packages// mysql / mariadb }">>$workingdir/e packages="${packages// dhcp / dhcp-server }">>$workingdir/er
rror_logs/fog_error_${version}.log 2>&1 ror_logs/fog_error_${version}.log 2>&1
packages="${packages// mysql-server / mariadb-server }">
>$workingdir/error_logs/fog_error_${version}.log 2>&1
packages="${packages// dhcp / dhcp-server }">>$workingdi
r/error_logs/fog_error_${version}.log 2>&1
fi
;; ;;
*) *)
repo="enterprise"
x="epel-release" x="epel-release"
eval $packageQuery >>$workingdir/error_logs/fog_error_${vers ion}.log 2>&1 eval $packageQuery >>$workingdir/error_logs/fog_error_${vers ion}.log 2>&1
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
$pkginst epel-release >>$workingdir/error_logs/fog_error y="https://dl.fedoraproject.org/pub/epel/epel-release-la
_${version}.log 2>&1 test-${OSVersion}.noarch.rpm"
$packageinstaller $y >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
fi
y="http://rpms.remirepo.net/enterprise/remi-release-${OSVers
ion}.rpm"
x=$(basename $y | awk -F[.] '{print $1}')
eval $packageQuery >>$workingdir/error_logs/fog_error_${vers
ion}.log 2>&1
if [[ ! $? -eq 0 ]]; then
rpm -Uvh $y >>$workingdir/error_logs/fog_error_${version
}.log 2>&1
rpm --import "http://rpms.remirepo.net/RPM-GPG-KEY-remi"
>>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi
if [[ -n $repoenable ]]; then
$repoenable epel >>$workingdir/error_logs/fog_error_${ve
rsion}.log 2>&1 || true
$repoenable remi >>$workingdir/error_logs/fog_error_${ve
rsion}.log 2>&1 || true
$repoenable remi-php72 >>$workingdir/error_logs/fog_erro
r_${version}.log 2>&1 || true
fi fi
;; ;;
esac esac
y="http://rpms.remirepo.net/$repo/remi-release-${OSVersion}.rpm"
x=$(basename $y | awk -F[.] '{print $1}')
eval $packageQuery >>$workingdir/error_logs/fog_error_${version}.log
2>&1
if [[ ! $? -eq 0 ]]; then
rpm -Uvh $y >>$workingdir/error_logs/fog_error_${version}.log 2>
&1
rpm --import "http://rpms.remirepo.net/RPM-GPG-KEY-remi" >>$work
ingdir/error_logs/fog_error_${version}.log 2>&1
fi
if [[ -n $repoenable ]]; then
$repoenable remi >>$workingdir/error_logs/fog_error_${version}.l
og 2>&1 || true
$repoenable remi-php56 >>$workingdir/error_logs/fog_error_${vers
ion}.log 2>&1 || true
fi
;; ;;
2) 2)
packages="${packages// libapache2-mod-fastcgi/}" packages="${packages// libapache2-mod-fastcgi/}"
packages="${packages// libapache2-mod-evasive/}" packages="${packages// libapache2-mod-evasive/}"
packages="${packages// php${php_ver}-mcrypt/}"
packages="${packages} php${php_ver}-bcmath bc" packages="${packages} php${php_ver}-bcmath bc"
case $linuxReleaseName in case $linuxReleaseName in
*[Uu][Bb][Uu][Nn][Tt][Uu]*|*[Mm][Ii][Nn][Tt]*) *[Uu][Bb][Uu][Nn][Tt][Uu]*|*[Mm][Ii][Nn][Tt]*)
addUbuntuRepo addUbuntuRepo
;; ;;
esac esac
;; ;;
3)
echo $packages | grep -q -v " git" && packages="${packages} git"
packages="${packages// php-mcrypt/}"
;;
esac esac
errorStat $? errorStat $?
dots "Preparing Package Manager" dots "Preparing Package Manager"
$packmanUpdate >>$workingdir/error_logs/fog_error_${version}.log 2>&1 $packmanUpdate >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ $osid -eq 2 ]]; then if [[ $osid -eq 2 ]]; then
if [[ $? != 0 ]] && [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]* |*[Mm][Ii][Nn][Tt]*) ]]; then if [[ $? != 0 ]] && [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]* |*[Mm][Ii][Nn][Tt]*) ]]; then
cp /etc/apt/sources.list /etc/apt/sources.list.original_fog_$(date + %s) cp /etc/apt/sources.list /etc/apt/sources.list.original_fog_$(date + %s)
sed -i -e 's/\/\/*archive.ubuntu.com\|\/\/*security.ubuntu.com/\/\/o ld-releases.ubuntu.com/g' /etc/apt/sources.list sed -i -e 's/\/\/*archive.ubuntu.com\|\/\/*security.ubuntu.com/\/\/o ld-releases.ubuntu.com/g' /etc/apt/sources.list
$packmanUpdate >>$workingdir/error_logs/fog_error_${version}.log 2>& 1 $packmanUpdate >>$workingdir/error_logs/fog_error_${version}.log 2>& 1
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
skipping to change at line 703 skipping to change at line 710
errorStat $? errorStat $?
fi fi
} }
confirmPackageInstallation() { confirmPackageInstallation() {
for x in $packages; do for x in $packages; do
dots "Checking package: $x" dots "Checking package: $x"
eval $packageQuery >>$workingdir/error_logs/fog_error_${version}.log 2>& 1 eval $packageQuery >>$workingdir/error_logs/fog_error_${version}.log 2>& 1
errorStat $? errorStat $?
done done
} }
checkSELinux() {
command -v sestatus >>$workingdir/error_logs/fog_error_${version}.log 2>&1
exitcode=$?
[[ $exitcode -ne 0 ]] && return
currentmode=$(LANG=C sestatus | grep "^Current mode" | awk '{print $3}')
configmode=$(LANG=C sestatus | grep "^Mode from config file" | awk '{print $
5}')
[[ "$currentmode" != "enforcing" && "$configmode" != "enforcing" ]] && retur
n
echo " * SELinux is currently enabled on your system. This is often causing"
echo " * issues and we recommend to disable it on FOG servers as of now."
echo " * Should the installer disable SELinux for you now? (Y/n)"
sedisable=""
while [[ -z $sedisable ]]; do
if [[ -n $autoaccept ]]; then
sedisable="Y"
else
read -r sedisable
fi
case $sedisable in
[Yy]|[Yy][Ee][Ss]|"")
sedisable="Y"
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=permissive/' /etc/selinux/config
echo -e " * SELinux disabled - proceeding with installation...\n
"
;;
[Nn]|[Nn][Oo])
echo " * You sure know what you are doing, just keep in mind we
told you! :-)"
;;
*)
sedisable=""
echo " * Invalid input, please try again!"
;;
esac
done
}
checkFirewall() {
command -v iptables >>$workingdir/error_logs/fog_error_${version}.log 2>&1
exitcode=$?
[[ $exitcode -ne 0 ]] && return
rulesnum=$(iptables -L -n | wc -l)
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c)
[[ $rulesnum -eq 8 && $policy -eq 0 ]] && return
echo " * The local firewall seems to be currently enabled on your system. Th
is can cause"
echo " * issues on FOG servers if you are not well experienced and know what
you are doing."
echo " * Should the installer try to disable the local firewall for you now?
(y/N)"
fwdisable=""
while [[ -z $fwdisable ]]; do
if [[ -n $autoaccept ]]; then
fwdisable="N"
else
read -r fwdisable
fi
case $fwdisable in
[Yy]|[Yy][Ee][Ss])
ufw stop >/dev/null 2>&1
ufw disable >/dev/null 2>&1
systemctl stop ufw >/dev/null 2>&1
systemctl disable ufw >/dev/null 2>&1
systemctl stop firewalld >/dev/null 2>&1
systemctl disable firewalld >/dev/null 2>&1
systemctl stop iptables >/dev/null 2>&1
systemctl disable iptables >/dev/null 2>&1
rulesnum=$(iptables -L -n | wc -l)
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c)
if [[ $rulesnum -ne 8 || $policy -ne 0 ]]; then
echo " * We were unable to disable the firewall on your syst
em. Read up on how"
echo " * you can disable it manually. Proceeding with the in
stallation anyway..."
echo " * Hit ENTER so we know you've read this message."
read
else
echo -e " * Firewall disabled - proceeding with installation
...\n"
fi
;;
[Nn]|[Nn][Oo]|"")
fwdisable="N"
echo " * You sure know what you are doing, just keep in mind we
told you! :-)"
if [[ -z $autoaccept ]]; then
echo " * Hit ENTER so we know you've read this message."
read
fi
;;
*)
fwdisable=""
echo " * Invalid input, please try again!"
;;
esac
done
}
displayOSChoices() { displayOSChoices() {
blFirst=1 blFirst=1
while [[ -z $osid ]]; do while [[ -z $osid ]]; do
if [[ $fogupdateloaded -eq 1 && $blFirst -eq 1 ]]; then if [[ $fogupdateloaded -eq 1 && $blFirst -eq 1 ]]; then
blFirst=0 blFirst=0
else else
osid=$strSuggestedOS osid=$strSuggestedOS
if [[ -z $autoaccept && ! -z $osid ]]; then if [[ -z $autoaccept && ! -z $osid ]]; then
echo " What version of Linux would you like to run the installa tion for?" echo " What version of Linux would you like to run the installa tion for?"
echo echo
skipping to change at line 785 skipping to change at line 879
if [[ $status != 0 ]]; then if [[ $status != 0 ]]; then
echo "Failed!" echo "Failed!"
[[ -z $exitFail ]] && exit $status [[ -z $exitFail ]] && exit $status
fi fi
echo "OK" echo "OK"
} }
stopInitScript() { stopInitScript() {
for serviceItem in $serviceList; do for serviceItem in $serviceList; do
dots "Stopping $serviceItem Service" dots "Stopping $serviceItem Service"
if [ "$systemctl" == "yes" ]; then if [ "$systemctl" == "yes" ]; then
systemctl stop $serviceItem >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1 && sleep 2 systemctl is-active --quiet $serviceItem && systemctl stop $serviceI tem >>$workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2
else else
[[ -x $initdpath/$serviceItem ]] && $initdpath/$serviceItem stop >>$ [[ ! -x $initdpath/$serviceItem ]] && continue
workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2 $initdpath/$serviceItem status >/dev/null 2>&1 && $initdpath/$servic
eItem stop >>$workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2
fi fi
echo "OK" echo "OK"
done done
} }
startInitScript() { startInitScript() {
for serviceItem in $serviceList; do for serviceItem in $serviceList; do
dots "Starting $serviceItem Service" dots "Starting $serviceItem Service"
if [[ $systemctl == yes ]]; then if [[ $systemctl == yes ]]; then
systemctl start $serviceItem >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1 && sleep 2 systemctl is-active --quiet $serviceItem || systemctl start $service Item >>$workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2
else else
[[ -x $initdpath/$serviceItem ]] && $initdpath/$serviceItem start >> [[ ! -x $initdpath/$serviceItem ]] && continue
$workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2 $initdpath/$serviceItem status >/dev/null 2>&1 || $initdpath/$servic
eItem start >>$workingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2
fi fi
errorStat $? errorStat $?
done done
} }
enableInitScript() { enableInitScript() {
for serviceItem in $serviceList; do for serviceItem in $serviceList; do
case $systemctl in case $systemctl in
yes) yes)
dots "Setting permissions on $serviceItem script" dots "Setting permissions on $serviceItem script"
chmod 644 $initdpath/$serviceItem >>$workingdir/error_logs/fog_e rror_${version}.log 2>&1 chmod 644 $initdpath/$serviceItem >>$workingdir/error_logs/fog_e rror_${version}.log 2>&1
skipping to change at line 862 skipping to change at line 958
errorStat $? errorStat $?
echo echo
echo echo
echo " * Configuring FOG System Services" echo " * Configuring FOG System Services"
echo echo
echo echo
enableInitScript enableInitScript
} }
configureMySql() { configureMySql() {
stopInitScript stopInitScript
if [[ $installtype == +([Nn]) && ! $fogupdateloaded -eq 1 && -z $autoaccept
]]; then
dummy=""
while [[ -z $dummy ]]; do
echo -n " * Is the MySQL password blank? (Y/n) "
read -r dummy
case $dummy in
[Yy]|[Yy][Ee][Ss]|"")
dummy='Y'
;;
[Nn]|[Nn][Oo])
echo -n " * Enter the MySQL password: "
read -rs PASSWORD1
echo
echo -n " * Re-enter the MySQL password: "
read -rs PASSWORD2
echo
if [[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1" ]]; then
dbpass=$PASSWORD1
else
dbpass=""
while ! [[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1"
]]; do
echo "Password entries were blank or didn't match!"
echo -n " * Enter the MySQL password: "
read -rs PASSWORD1
echo
echo -n " * Re-enter the MySQL password: "
read -rs PASSWORD2
echo
[[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1" ]]
&& dbpass=$PASSWORD1
done
fi
[[ $snmysqlpass != "$dbpass" ]] && snmysqlpass=$dbpass
;;
*)
dummy=""
echo " * Invalid input, please try again!"
;;
esac
done
fi
dots "Setting up and starting MySQL" dots "Setting up and starting MySQL"
dbservice=$(systemctl list-units | grep -o -e "mariadb\.service" -e "mysqld\
.service" -e "mysql\.service" | tr -d '@')
[[ -z $dbservice ]] && dbservice=$(systemctl list-unit-files | grep -v bad |
grep -o -e "mariadb\.service" -e "mysqld\.service" -e "mysql\.service" | tr -d
'@')
for mysqlconf in $(grep -rl '.*skip-networking' /etc | grep -v init.d); do for mysqlconf in $(grep -rl '.*skip-networking' /etc | grep -v init.d); do
sed -i '/.*skip-networking/ s/^#*/#/' -i $mysqlconf >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 sed -i '/.*skip-networking/ s/^#*/#/' -i $mysqlconf >>$workingdir/error_ logs/fog_error_${version}.log 2>&1
done done
for mysqlconf in `grep -rl '.*bind-address.*=.*127.0.0.1' /etc | grep -v ini t.d`; do for mysqlconf in `grep -rl '.*bind-address.*=.*127.0.0.1' /etc | grep -v ini t.d`; do
sed -e '/.*bind-address.*=.*127.0.0.1/ s/^#*/#/' -i $mysqlconf >>$workin gdir/error_logs/fog_error_${version}.log 2>&1 sed -e '/.*bind-address.*=.*127.0.0.1/ s/^#*/#/' -i $mysqlconf >>$workin gdir/error_logs/fog_error_${version}.log 2>&1
done done
if [[ $systemctl == yes ]]; then if [[ $systemctl == yes ]]; then
if [[ $osid -eq 3 ]]; then if [[ $osid -eq 3 && ! -f /var/lib/mysql/ibdata1 ]]; then
[[ ! -d /var/lib/mysql ]] && mkdir /var/lib/mysql >>$workingdir/erro mkdir -p /var/lib/mysql >>$workingdir/error_logs/fog_error_${version
r_logs/fog_error_${version}.log 2>&1 }.log 2>&1
chown -R mysql:mysql /var/lib/mysql >>$workingdir/error_logs/fog_err or_${version}.log 2>&1 chown -R mysql:mysql /var/lib/mysql >>$workingdir/error_logs/fog_err or_${version}.log 2>&1
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysq l >>$workingdir/error_logs/fog_error_${version}.log 2>&1 mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysq l >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
systemctl enable mysql.service >>$workingdir/error_logs/fog_error_${vers systemctl is-enabled --quiet $dbservice || systemctl enable $dbservice >
ion}.log 2>&1 >$workingdir/error_logs/fog_error_${version}.log 2>&1
systemctl stop mysql.service >>$workingdir/error_logs/fog_error_${versio systemctl is-active --quiet $dbservice || systemctl start $dbservice >>$
n}.log 2>&1 workingdir/error_logs/fog_error_${version}.log 2>&1
sleep 2
systemctl start mysql.service >>$workingdir/error_logs/fog_error_${versi
on}.log 2>&1
sleep 2
systemctl status mysql.service >>$workingdir/error_logs/fog_error_${vers
ion}.log 2>&1
if [[ ! $? -eq 0 ]]; then
systemctl enable mysqld.service >>$workingdir/error_logs/fog_error_$
{version}.log 2>&1
systemctl stop mysqld.service >>$workingdir/error_logs/fog_error_${v
ersion}.log 2>&1
sleep 2
systemctl start mysqld.service >>$workingdir/error_logs/fog_error_${
version}.log 2>&1
sleep 2
systemctl status mysqld.service >>$workingdir/error_logs/fog_error_$
{version}.log 2>&1
fi
if [[ ! $? -eq 0 ]]; then
systemctl enable mariadb.service >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
systemctl stop mariadb.service >>$workingdir/error_logs/fog_error_${
version}.log 2>&1
sleep 2
systemctl start mariadb.service >>$workingdir/error_logs/fog_error_$
{version}.log 2>&1
sleep 2
systemctl status mariadb.service >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
fi
else else
case $osid in case $osid in
1) 1)
chkconfig mysqld on >>$workingdir/error_logs/fog_error_${version }.log 2>&1 chkconfig mysqld on >>$workingdir/error_logs/fog_error_${version }.log 2>&1
service mysqld stop >>$workingdir/error_logs/fog_error_${version
}.log 2>&1
sleep 2
service mysqld start >>$workingdir/error_logs/fog_error_${versio n}.log 2>&1 service mysqld start >>$workingdir/error_logs/fog_error_${versio n}.log 2>&1
sleep 2
service mysqld status >>$workingdir/error_logs/fog_error_${versi
on}.log 2>&1
;; ;;
2) 2)
sysv-rc-conf mysql on >>$workingdir/error_logs/fog_error_${versi on}.log 2>&1 sysv-rc-conf mysql on >>$workingdir/error_logs/fog_error_${versi on}.log 2>&1
service mysql stop >>$workingdir/error_logs/fog_error_${version}
.log 2>&1
sleep 2
service mysql start >>$workingdir/error_logs/fog_error_${version }.log 2>&1 service mysql start >>$workingdir/error_logs/fog_error_${version }.log 2>&1
sleep 2
;; ;;
esac esac
fi fi
errorStat $? options=("-s")
[[ -n $snmysqlhost ]] && options=( "${options[@]}" "--host=$snmysqlhost" )
[[ -n $snmysqluser ]] && options=( "${options[@]}" "--user=$snmysqluser" )
[[ -n $snmysqlpass ]] && options=( "${options[@]}" "--password=$snmysqlpass"
)
sqlescsnmysqlpass=$(echo "$snmysqlpass" | sed -e s/\'/\'\'/g) # Replace ev
ery ' with '' for full MySQL escaping
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE User='root';
"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_${version}.l
og 2>&1
mysqlver=$(mysql -V | sed -n 's/.*Distrib[ ]\(\([0-9]\([.]\|\)\)*\).*\([-]\
|\)[,].*/\1/p')
mariadb=$(mysql -V | sed -n 's/.*Distrib[ ].*[-]\(.*\)[,].*/\1/p')
vertocheck="5.7"
[[ -n $mariadb ]] && vertocheck="10.2"
if [[ $systemctl == yes ]]; then
systemctl restart $dbservice >>$workingdir/error_logs/fog_error_${versio
n}.log 2>&1
else
case $osid in
1)
service mysqld restart >>$workingdir/error_logs/fog_error_${vers
ion}.log 2>&1
;;
2)
service mysql restart >>$workingdir/error_logs/fog_error_${versi
on}.log 2>&1
;;
esac
fi
mysqlver=$(echo $mysqlver | awk -F'([.])' '{print $1"."$2}')
runTest=$(echo "$mysqlver < $vertocheck" | bc)
if [[ $runTest -eq 0 ]]; then
[[ -z $snmysqlhost ]] && snmysqlhost='localhost'
[[ -z $snmysqluser ]] && snmysqluser='root'
case $snmysqlhost in
127.0.0.1|[Ll][Oo][Cc][Aa][Ll][Hh][Oo][Ss][Tt])
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE
User='root';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'127.0.0.1' IDENTIFIED WITH mysql
_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'localhost' IDENTIFIED WITH mysql
_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
;;
*)
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE
User='root';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'$snmysqlhost' IDENTIFIED WITH my
sql_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
;;
esac
fi
echo "Done"
} }
configureFOGService() { configureFOGService() {
[[ ! -d $servicedst ]] && mkdir -p $servicedst >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 [[ ! -d $servicedst ]] && mkdir -p $servicedst >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
[[ ! -d $servicedst/etc ]] && mkdir -p $servicedst/etc >>$workingdir/error_l ogs/fog_error_${version}.log 2>&1 [[ ! -d $servicedst/etc ]] && mkdir -p $servicedst/etc >>$workingdir/error_l ogs/fog_error_${version}.log 2>&1
echo "<?php define('WEBROOT','${webdirdest}');" > $servicedst/etc/config.php echo "<?php define('WEBROOT','${webdirdest}');" > $servicedst/etc/config.php
startInitScript startInitScript
} }
configureNFS() { configureNFS() {
dots "Setting up exports file" dots "Setting up exports file"
if [[ $blexports != 1 ]]; then if [[ $blexports != 1 ]]; then
skipping to change at line 996 skipping to change at line 1152
dots "Setting up FOG Snapins" dots "Setting up FOG Snapins"
mkdir -p $snapindir >>$workingdir/error_logs/fog_error_${version}.log 2>&1 mkdir -p $snapindir >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ -d $snapindir ]]; then if [[ -d $snapindir ]]; then
chmod -R 777 $snapindir chmod -R 777 $snapindir
chown -R $username:$apacheuser $snapindir chown -R $username:$apacheuser $snapindir
fi fi
errorStat $? errorStat $?
} }
configureUsers() { configureUsers() {
userexists=0 userexists=0
[[ -z $username ]] && username='fog' [[ -z $username || "x$username" = "xfog" ]] && username='fogproject'
dots "Setting up $username user" dots "Setting up $username user"
getent passwd $username > /dev/null getent passwd $username > /dev/null
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo "Already setup" if [[ ! -f "$fogprogramdir/.fogsettings" ]]; then
userexists=1 echo "Already exists"
fi echo
if [[ $userexists -eq 0 ]]; then echo "The account \"$username\" already exists but this seems to be
a"
echo "fresh install. We highly recommend to NOT creating this accoun
t"
echo "beforehand as it is supposed to be a system account not meant"
echo "to be used to login and work on the machine!"
echo
echo "Please remove the account \"$username\" manually before runnin
g"
echo "the installer again. Run: userdel $username"
echo
exit 1
else
lastlog -u $username | tail -n -1 | grep "\*\*.*\*\*" > /dev/null 2>
&1
if [[ $? -eq 1 ]]; then
echo "Already exists"
echo
echo "The account \"$username\" already exists and has been used
to"
echo "logon and work on this machine. We highly recommend you NO
T"
echo "use this account for your work as it is supposed to be a"
echo "system account!"
echo
echo "Please remove the account \"$username\" manually before ru
nning"
echo "the installer again. Run: userdel $username"
echo
exit 1
fi
echo "Already setup"
fi
else
useradd -s "/bin/bash" -d "/home/${username}" -m ${username} >>$workingd ir/error_logs/fog_error_${version}.log 2>&1 useradd -s "/bin/bash" -d "/home/${username}" -m ${username} >>$workingd ir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
fi fi
if [[ ! -d /home/$username ]]; then if [[ ! -d /home/$username ]]; then
echo "# It has been noticed that your $username home folder is missing, #" echo "# It has been noticed that your $username home folder is missing, #"
echo "# has been deleted, or has been moved. #" echo "# has been deleted, or has been moved. #"
echo "# This may cause issues with capturing images and snapin uploads. #" echo "# This may cause issues with capturing images and snapin uploads. #"
echo "# If you this move/delete was unintentional you can run: #" echo "# If you this move/delete was unintentional you can run: #"
echo " userdel $username" echo " userdel $username"
echo " useradd -s \"/bin/bash\" -d \"/home/$username\" -m \"$username\"" echo " useradd -s \"/bin/bash\" -d \"/home/$username\" -m \"$username\""
#userdel $username #userdel $username
#useradd -s "/bin/bash" -d "/home/${username}" -m ${username} >>$working dir/error_logs/fog_error_${version}.log 2>&1 #useradd -s "/bin/bash" -d "/home/${username}" -m ${username} >>$working dir/error_logs/fog_error_${version}.log 2>&1
#errorStat $? #errorStat $?
fi fi
dots "Locking $username as a system account"
chsh -s /bin/bash $username >>$workingdir/error_logs/fog_error_${version}.lo
g 2>&1
textmessage="You seem to be using the '$username' system account to logon an
d work \non your FOG server system.\n\nIt's NOT recommended to use this account!
Please create a new \naccount for administrative tasks.\n\nIf you re-run the in
staller it would reset the 'fog' account \npassword and therefore lock you out o
f the system!\n\nTake care, \nyour FOGproject team"
grep "exit 1" /home/$username/.bashrc || cat >>/home/$username/.bashrc <<EOF
echo -e "$textmessage"
exit 1
EOF
mkdir -p /home/$username/.config/autostart/
cat >/home/$username/.config/autostart/warnfogaccount.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Warn users to not use the $username account
Exec=/home/$username/warnfogaccount.sh
Comment=Warn users who use the $username system account to logon
EOF
chown -R $username:$username /home/$username/.config/
cat >/home/$username/warnfogaccount.sh <<EOF
#!/bin/bash
title="FOG system account"
text="$textmessage"
z=\$(which zenity)
x=\$(which xmessage)
n=\$(which notify-send)
if [[ -x "\$z" ]]
then
\$z --error --width=480 --text="\$text" --title="\$title"
elif [[ -x "\$x" ]]
then
echo -e "\$text" | \$x -center -file -
else
\$n -u critical "\$title" "\$(echo \$text | sed -e 's/ \\n/ /g')"
fi
EOF
chmod 755 /home/$username/warnfogaccount.sh
errorStat $?
dots "Setting up $username password" dots "Setting up $username password"
if [[ -z $password ]]; then if [[ -z $password ]]; then
[[ -f $webdirdest/lib/fog/config.class.php ]] && password="$(awk -F'[(") [[ -f $webdirdest/lib/fog/config.class.php ]] && password=$(awk -F '"' -
]' '/TFTP_FTP_PASSWORD/ {print $3}' $webdirdest/lib/fog/config.class.php)" e '/TFTP_FTP_PASSWORD/,/);/{print $2}' $webdirdest/lib/fog/config.class.php | gr
[[ -z $password ]] && password=$(openssl rand -base64 32) ep -v "^$")
fi fi
echo -e "$password\n$password" | passwd $username >>$workingdir/error_logs/f passcheck=$(echo $password | tr -d '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[\\]^_{|}~'
og_error_${version}.log 2>&1 )
errorStat $? if [[ -n "$passcheck" ]]
then
echo "Failed"
echo "# The fog system account password includes characters we cannot pr
operly"
echo "# handle. Please remove the following character(s) from the passwo
rd in"
echo "# your .fogsettings file before re-running the installer: $passche
ck"
exit 1
fi
cnt=0
ret=999
while [[ $ret -ne 0 && $cnt -lt 10 ]]
do
[[ -z $password || $ret -ne 999 ]] && password=$(tr -cd '0-9a-zA-Z!#$%&(
)*+,-./:;<=>?@[\\]^_{|}~' < /dev/urandom | fold -w12 | head -n1)
echo -e "$password\n$password" | passwd $username >>$workingdir/error_lo
gs/fog_error_${version}.log 2>&1
ret=$?
let cnt+=1
done
errorStat $ret
unset cnt
unset ret
} }
linkOptFogDir() { linkOptFogDir() {
if [[ ! -h /var/log/fog ]]; then if [[ ! -h /var/log/fog ]]; then
dots "Linking FOG Logs to Linux Logs" dots "Linking FOG Logs to Linux Logs"
ln -s /opt/fog/log /var/log/fog >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1 ln -s /opt/fog/log /var/log/fog >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1
errorStat $? errorStat $?
fi fi
if [[ ! -h /etc/fog ]]; then if [[ ! -h /etc/fog ]]; then
dots "Linking FOG Service config /etc" dots "Linking FOG Service config /etc"
ln -s /opt/fog/service/etc /etc/fog >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1 ln -s /opt/fog/service/etc /etc/fog >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
skipping to change at line 1080 skipping to change at line 1316
fi fi
chmod -R 777 $storageLocation $storageLocationCapture >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 chmod -R 777 $storageLocation $storageLocationCapture >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1
chown -R $username $storageLocation $storageLocationCapture >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1 chown -R $username $storageLocation $storageLocationCapture >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
} }
clearScreen() { clearScreen() {
clear clear
} }
writeUpdateFile() { writeUpdateFile() {
tmpDte=$(date +%c) tmpDte=$(date +%c)
replace='s/[]"\/$*.^|[]/\\&/g'; replace='s/[]"\/$&*.^|[]/\\&/g';
escversion=$(echo $version | sed -e $replace) escversion=$(echo $version | sed -e $replace)
esctmpDte=$(echo $tmpDate | sed -e $replace) esctmpDte=$(echo $tmpDate | sed -e $replace)
escipaddress=$(echo $ipaddress | sed -e $replace) escipaddress=$(echo $ipaddress | sed -e $replace)
escinterface=$(echo $interface | sed -e $replace) escinterface=$(echo $interface | sed -e $replace)
escsubmask=$(echo $submask | sed -e $replace) escsubmask=$(echo $submask | sed -e $replace)
eschostname=$(echo $hostname | sed -e $replace)
escrouteraddress=$(echo $routeraddress | sed -e $replace) escrouteraddress=$(echo $routeraddress | sed -e $replace)
escplainrouter=$(echo $plainrouter | sed -e $replace) escplainrouter=$(echo $plainrouter | sed -e $replace)
escdnsaddress=$(echo $dnsaddress | sed -e $replace) escdnsaddress=$(echo $dnsaddress | sed -e $replace)
escpassword=$(echo $password | sed -e $replace -e "s/[']{1}/'''/g") escpassword=$(echo $password | sed -e $replace)
escosid=$(echo $osid | sed -e $replace) escosid=$(echo $osid | sed -e $replace)
escosname=$(echo $osname | sed -e $replace) escosname=$(echo $osname | sed -e $replace)
escdodhcp=$(echo $dodhcp | sed -e $replace) escdodhcp=$(echo $dodhcp | sed -e $replace)
escbldhcp=$(echo $bldhcp | sed -e $replace) escbldhcp=$(echo $bldhcp | sed -e $replace)
escdhcpd=$(echo $dhcpd | sed -e $replace) escdhcpd=$(echo $dhcpd | sed -e $replace)
escblexports=$(echo $blexports | sed -e $replace) escblexports=$(echo $blexports | sed -e $replace)
escinstalltype=$(echo $installtype | sed -e $replace) escinstalltype=$(echo $installtype | sed -e $replace)
escsnmysqluser=$(echo $snmysqluser | sed -e $replace) escsnmysqluser=$(echo $snmysqluser | sed -e $replace)
escsnmysqlpass=$(echo "$snmysqlpass" | sed -e s/\'/\'\"\'\"\'/g) # replace every ' with '"'"' for full bash escaping escsnmysqlpass=$(echo "$snmysqlpass" | sed -e s/\'/\'\"\'\"\'/g) # replace every ' with '"'"' for full bash escaping
sedescsnmysqlpass=$(echo "$escsnmysqlpass" | sed -e 's/[\&/]/\\&/g') # then prefix every \ & and / with \ for sed escaping sedescsnmysqlpass=$(echo "$escsnmysqlpass" | sed -e 's/[\&/]/\\&/g') # then prefix every \ & and / with \ for sed escaping
skipping to change at line 1139 skipping to change at line 1376
echo "ipaddress='$ipaddress'" >> $fogprogramdir/.fogsettings echo "ipaddress='$ipaddress'" >> $fogprogramdir/.fogsettings
grep -q "copybackold=" $fogprogramdir/.fogsettings && \ grep -q "copybackold=" $fogprogramdir/.fogsettings && \
sed -i "s/copybackold=.*/copybackold='$copybackold'/g" $fogprogr amdir/.fogsettings || \ sed -i "s/copybackold=.*/copybackold='$copybackold'/g" $fogprogr amdir/.fogsettings || \
echo "copybackold='$copybackold'" >> $fogprogramdir/.fogsettings echo "copybackold='$copybackold'" >> $fogprogramdir/.fogsettings
grep -q "interface=" $fogprogramdir/.fogsettings && \ grep -q "interface=" $fogprogramdir/.fogsettings && \
sed -i "s/interface=.*/interface='$escinterface'/g" $fogprogramd ir/.fogsettings || \ sed -i "s/interface=.*/interface='$escinterface'/g" $fogprogramd ir/.fogsettings || \
echo "interface='$interface'" >> $fogprogramdir/.fogsettings echo "interface='$interface'" >> $fogprogramdir/.fogsettings
grep -q "submask=" $fogprogramdir/.fogsettings && \ grep -q "submask=" $fogprogramdir/.fogsettings && \
sed -i "s/submask=.*/submask='$escsubmask'/g" $fogprogramdir/.fo gsettings || \ sed -i "s/submask=.*/submask='$escsubmask'/g" $fogprogramdir/.fo gsettings || \
echo "submask='$submask'" >> $fogprogramdir/.fogsettings echo "submask='$submask'" >> $fogprogramdir/.fogsettings
grep -q "hostname=" $fogprogramdir/.fogsettings && \
sed -i "s/hostname=.*/hostname='$eschostname'/g" $fogprogramdir/
.fogsettings || \
echo "hostname='$hostname'" >> $fogprogramdir/.fogsettings
grep -q "routeraddress=" $fogprogramdir/.fogsettings && \ grep -q "routeraddress=" $fogprogramdir/.fogsettings && \
sed -i "s/routeraddress=.*/routeraddress='$escrouteraddress'/g" $fogprogramdir/.fogsettings || \ sed -i "s/routeraddress=.*/routeraddress='$escrouteraddress'/g" $fogprogramdir/.fogsettings || \
echo "routeraddress='$routeraddress'" >> $fogprogramdir/.fogsett ings echo "routeraddress='$routeraddress'" >> $fogprogramdir/.fogsett ings
grep -q "plainrouter=" $fogprogramdir/.fogsettings && \ grep -q "plainrouter=" $fogprogramdir/.fogsettings && \
sed -i "s/plainrouter=.*/plainrouter='$escplainrouter'/g" $fogpr ogramdir/.fogsettings || \ sed -i "s/plainrouter=.*/plainrouter='$escplainrouter'/g" $fogpr ogramdir/.fogsettings || \
echo "plainrouter='$plainrouter'" >> $fogprogramdir/.fogsettings echo "plainrouter='$plainrouter'" >> $fogprogramdir/.fogsettings
grep -q "dnsaddress=" $fogprogramdir/.fogsettings && \ grep -q "dnsaddress=" $fogprogramdir/.fogsettings && \
sed -i "s/dnsaddress=.*/dnsaddress='$escdnsaddress'/g" $fogprogr amdir/.fogsettings || \ sed -i "s/dnsaddress=.*/dnsaddress='$escdnsaddress'/g" $fogprogr amdir/.fogsettings || \
echo "dnsaddress='$dnsaddress'" >> $fogprogramdir/.fogsettings echo "dnsaddress='$dnsaddress'" >> $fogprogramdir/.fogsettings
grep -q "password=" $fogprogramdir/.fogsettings && \ grep -q "password=" $fogprogramdir/.fogsettings && \
sed -i "s/password=.*/password=\"$escpassword\"/g" $fogprogramdi sed -i "s/password=.*/password='$escpassword'/g" $fogprogramdir/
r/.fogsettings || \ .fogsettings || \
echo "password=\"$escpassword\"" >> $fogprogramdir/.fogsettings echo "password='$password'" >> $fogprogramdir/.fogsettings
grep -q "osid=" $fogprogramdir/.fogsettings && \ grep -q "osid=" $fogprogramdir/.fogsettings && \
sed -i "s/osid=.*/osid='$osid'/g" $fogprogramdir/.fogsettings || \ sed -i "s/osid=.*/osid='$osid'/g" $fogprogramdir/.fogsettings || \
echo "osid='$osid'" >> $fogprogramdir/.fogsettings echo "osid='$osid'" >> $fogprogramdir/.fogsettings
grep -q "osname=" $fogprogramdir/.fogsettings && \ grep -q "osname=" $fogprogramdir/.fogsettings && \
sed -i "s/osname=.*/osname='$escosname'/g" $fogprogramdir/.fogse ttings || \ sed -i "s/osname=.*/osname='$escosname'/g" $fogprogramdir/.fogse ttings || \
echo "osname='$osname'" >> $fogprogramdir/.fogsettings echo "osname='$osname'" >> $fogprogramdir/.fogsettings
grep -q "dodhcp=" $fogprogramdir/.fogsettings && \ grep -q "dodhcp=" $fogprogramdir/.fogsettings && \
sed -i "s/dodhcp=.*/dodhcp='$escdodhcp'/g" $fogprogramdir/.fogse ttings || \ sed -i "s/dodhcp=.*/dodhcp='$escdodhcp'/g" $fogprogramdir/.fogse ttings || \
echo "dodhcp='$dodhcp'" >> $fogprogramdir/.fogsettings echo "dodhcp='$dodhcp'" >> $fogprogramdir/.fogsettings
grep -q "bldhcp=" $fogprogramdir/.fogsettings && \ grep -q "bldhcp=" $fogprogramdir/.fogsettings && \
skipping to change at line 1253 skipping to change at line 1493
echo "## Start of FOG Settings" > "$fogprogramdir/.fogsettings" echo "## Start of FOG Settings" > "$fogprogramdir/.fogsettings"
echo "## Created by the FOG Installer" >> "$fogprogramdir/.fogsettin gs" echo "## Created by the FOG Installer" >> "$fogprogramdir/.fogsettin gs"
echo "## Find more information about this file in the FOG Project wi ki:" >> "$fogprogramdir/.fogsettings" echo "## Find more information about this file in the FOG Project wi ki:" >> "$fogprogramdir/.fogsettings"
echo "## https://wiki.fogproject.org/wiki/index.php?title=.fogse ttings" >> "$fogprogramdir/.fogsettings" echo "## https://wiki.fogproject.org/wiki/index.php?title=.fogse ttings" >> "$fogprogramdir/.fogsettings"
echo "## Version: $version" >> "$fogprogramdir/.fogsettings" echo "## Version: $version" >> "$fogprogramdir/.fogsettings"
echo "## Install time: $tmpDte" >> "$fogprogramdir/.fogsettings" echo "## Install time: $tmpDte" >> "$fogprogramdir/.fogsettings"
echo "ipaddress='$ipaddress'" >> "$fogprogramdir/.fogsettings" echo "ipaddress='$ipaddress'" >> "$fogprogramdir/.fogsettings"
echo "copybackold='$copybackold'" >> "$fogprogramdir/.fogsettings" echo "copybackold='$copybackold'" >> "$fogprogramdir/.fogsettings"
echo "interface='$interface'" >> "$fogprogramdir/.fogsettings" echo "interface='$interface'" >> "$fogprogramdir/.fogsettings"
echo "submask='$submask'" >> "$fogprogramdir/.fogsettings" echo "submask='$submask'" >> "$fogprogramdir/.fogsettings"
echo "hostname='$hostname'" >> "$fogprogramdir/.fogsettings"
echo "routeraddress='$routeraddress'" >> "$fogprogramdir/.fogsetting s" echo "routeraddress='$routeraddress'" >> "$fogprogramdir/.fogsetting s"
echo "plainrouter='$plainrouter'" >> "$fogprogramdir/.fogsettings" echo "plainrouter='$plainrouter'" >> "$fogprogramdir/.fogsettings"
echo "dnsaddress='$dnsaddress'" >> "$fogprogramdir/.fogsettings" echo "dnsaddress='$dnsaddress'" >> "$fogprogramdir/.fogsettings"
echo "username='$username'" >> "$fogprogramdir/.fogsettings" echo "username='$username'" >> "$fogprogramdir/.fogsettings"
echo "password='$password'" >> "$fogprogramdir/.fogsettings" echo "password='$password'" >> "$fogprogramdir/.fogsettings"
echo "osid='$osid'" >> "$fogprogramdir/.fogsettings" echo "osid='$osid'" >> "$fogprogramdir/.fogsettings"
echo "osname='$osname'" >> "$fogprogramdir/.fogsettings" echo "osname='$osname'" >> "$fogprogramdir/.fogsettings"
echo "dodhcp='$dodhcp'" >> "$fogprogramdir/.fogsettings" echo "dodhcp='$dodhcp'" >> "$fogprogramdir/.fogsettings"
echo "bldhcp='$bldhcp'" >> "$fogprogramdir/.fogsettings" echo "bldhcp='$bldhcp'" >> "$fogprogramdir/.fogsettings"
echo "dhcpd='$dhcpd'" >> "$fogprogramdir/.fogsettings" echo "dhcpd='$dhcpd'" >> "$fogprogramdir/.fogsettings"
skipping to change at line 1299 skipping to change at line 1540
echo "## Start of FOG Settings" > "$fogprogramdir/.fogsettings" echo "## Start of FOG Settings" > "$fogprogramdir/.fogsettings"
echo "## Created by the FOG Installer" >> "$fogprogramdir/.fogsettings" echo "## Created by the FOG Installer" >> "$fogprogramdir/.fogsettings"
echo "## Find more information about this file in the FOG Project wiki:" >> "$fogprogramdir/.fogsettings" echo "## Find more information about this file in the FOG Project wiki:" >> "$fogprogramdir/.fogsettings"
echo "## https://wiki.fogproject.org/wiki/index.php?title=.fogsettin gs" >> "$fogprogramdir/.fogsettings" echo "## https://wiki.fogproject.org/wiki/index.php?title=.fogsettin gs" >> "$fogprogramdir/.fogsettings"
echo "## Version: $version" >> "$fogprogramdir/.fogsettings" echo "## Version: $version" >> "$fogprogramdir/.fogsettings"
echo "## Install time: $tmpDte" >> "$fogprogramdir/.fogsettings" echo "## Install time: $tmpDte" >> "$fogprogramdir/.fogsettings"
echo "ipaddress='$ipaddress'" >> "$fogprogramdir/.fogsettings" echo "ipaddress='$ipaddress'" >> "$fogprogramdir/.fogsettings"
echo "copybackold='$copybackold'" >> "$fogprogramdir/.fogsettings" echo "copybackold='$copybackold'" >> "$fogprogramdir/.fogsettings"
echo "interface='$interface'" >> "$fogprogramdir/.fogsettings" echo "interface='$interface'" >> "$fogprogramdir/.fogsettings"
echo "submask='$submask'" >> "$fogprogramdir/.fogsettings" echo "submask='$submask'" >> "$fogprogramdir/.fogsettings"
echo "hostname='$hostname'" >> "$fogprogramdir/.fogsettings"
echo "routeraddress='$routeraddress'" >> "$fogprogramdir/.fogsettings" echo "routeraddress='$routeraddress'" >> "$fogprogramdir/.fogsettings"
echo "plainrouter='$plainrouter'" >> "$fogprogramdir/.fogsettings" echo "plainrouter='$plainrouter'" >> "$fogprogramdir/.fogsettings"
echo "dnsaddress='$dnsaddress'" >> "$fogprogramdir/.fogsettings" echo "dnsaddress='$dnsaddress'" >> "$fogprogramdir/.fogsettings"
echo "username='$username'" >> "$fogprogramdir/.fogsettings" echo "username='$username'" >> "$fogprogramdir/.fogsettings"
echo "password='$password'" >> "$fogprogramdir/.fogsettings" echo "password='$password'" >> "$fogprogramdir/.fogsettings"
echo "osid='$osid'" >> "$fogprogramdir/.fogsettings" echo "osid='$osid'" >> "$fogprogramdir/.fogsettings"
echo "osname='$osname'" >> "$fogprogramdir/.fogsettings" echo "osname='$osname'" >> "$fogprogramdir/.fogsettings"
echo "dodhcp='$dodhcp'" >> "$fogprogramdir/.fogsettings" echo "dodhcp='$dodhcp'" >> "$fogprogramdir/.fogsettings"
echo "bldhcp='$bldhcp'" >> "$fogprogramdir/.fogsettings" echo "bldhcp='$bldhcp'" >> "$fogprogramdir/.fogsettings"
echo "dhcpd='$dhcpd'" >> "$fogprogramdir/.fogsettings" echo "dhcpd='$dhcpd'" >> "$fogprogramdir/.fogsettings"
skipping to change at line 1385 skipping to change at line 1627
FOG Server CA FOG Server CA
. .
EOF EOF
errorStat $? errorStat $?
fi fi
[[ -z $sslprivkey ]] && sslprivkey="$sslpath/.srvprivate.key" [[ -z $sslprivkey ]] && sslprivkey="$sslpath/.srvprivate.key"
if [[ $recreateKeys == yes || $recreateCA == yes || $caCreated != yes || ! - e $sslpath || ! -e $sslprivkey ]]; then if [[ $recreateKeys == yes || $recreateCA == yes || $caCreated != yes || ! - e $sslpath || ! -e $sslprivkey ]]; then
dots "Creating SSL Private Key" dots "Creating SSL Private Key"
mkdir -p $sslpath >>$workingdir/error_logs/fog_error_${version}.log 2>&1 mkdir -p $sslpath >>$workingdir/error_logs/fog_error_${version}.log 2>&1
openssl genrsa -out $sslprivkey 4096 >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 openssl genrsa -out $sslprivkey 4096 >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1
openssl req -new -sha512 -key $sslprivkey -out $sslpath/fog.csr >>$worki cat > $sslpath/req.cnf << EOF
ngdir/error_logs/fog_error_${version}.log 2>&1 << EOF [req]
. distinguished_name = req_distinguished_name
. req_extensions = v3_req
. prompt = yes
. [req_distinguished_name]
. CN = $ipaddress
[v3_req]
subjectAltName = @alt_names
[alt_names]
DNS.1 = $ipaddress
DNS.2 = $hostname
EOF
openssl req -new -sha512 -key $sslprivkey -out $sslpath/fog.csr -config
$sslpath/req.cnf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 << EOF
$ipaddress $ipaddress
.
EOF EOF
errorStat $? errorStat $?
fi fi
[[ ! -e $sslpath/.srvprivate.key ]] && ln -sf $sslprivkey $sslpath/.srvpriva te.key >>$workingdir/error_logs/fog_error_${version}.log 2>&1 [[ ! -e $sslpath/.srvprivate.key ]] && ln -sf $sslprivkey $sslpath/.srvpriva te.key >>$workingdir/error_logs/fog_error_${version}.log 2>&1
dots "Creating SSL Certificate" dots "Creating SSL Certificate"
mkdir -p $webdirdest/management/other/ssl >>$workingdir/error_logs/fog_error _${version}.log 2>&1 mkdir -p $webdirdest/management/other/ssl >>$workingdir/error_logs/fog_error _${version}.log 2>&1
openssl x509 -req -in $sslpath/fog.csr -CA $sslpath/CA/.fogCA.pem -CAkey $ss cat > $sslpath/ca.cnf << EOF
lpath/CA/.fogCA.key -CAcreateserial -out $webdirdest/management/other/ssl/srvpub [v3_ca]
lic.crt -days 3650 >>$workingdir/error_logs/fog_error_${version}.log 2>&1 subjectAltName = @alt_names
[alt_names]
DNS.1 = $ipaddress
DNS.2 = $hostname
EOF
openssl x509 -req -in $sslpath/fog.csr -CA $sslpath/CA/.fogCA.pem -CAkey $ss
lpath/CA/.fogCA.key -CAcreateserial -out $webdirdest/management/other/ssl/srvpub
lic.crt -days 3650 -extensions v3_ca -extfile $sslpath/ca.cnf >>$workingdir/erro
r_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
dots "Creating auth pub key and cert" dots "Creating auth pub key and cert"
cp $sslpath/CA/.fogCA.pem $webdirdest/management/other/ca.cert.pem >>$workin gdir/error_logs/fog_error_${version}.log 2>&1 cp $sslpath/CA/.fogCA.pem $webdirdest/management/other/ca.cert.pem >>$workin gdir/error_logs/fog_error_${version}.log 2>&1
openssl x509 -outform der -in $webdirdest/management/other/ca.cert.pem -out $webdirdest/management/other/ca.cert.der >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1 openssl x509 -outform der -in $webdirdest/management/other/ca.cert.pem -out $webdirdest/management/other/ca.cert.der >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1
errorStat $? errorStat $?
dots "Resetting SSL Permissions" dots "Resetting SSL Permissions"
chown -R $apacheuser:$apacheuser $webdirdest/management/other >>$workingdir/ error_logs/fog_error_${version}.log 2>&1 chown -R $apacheuser:$apacheuser $webdirdest/management/other >>$workingdir/ error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
[[ $httpproto == https ]] && sslenabled=" (SSL)" || sslenabled=" (no SSL)" [[ $httpproto == https ]] && sslenabled=" (SSL)" || sslenabled=" (no SSL)"
dots "Setting up Apache virtual host${sslenabled}" dots "Setting up Apache virtual host${sslenabled}"
skipping to change at line 1429 skipping to change at line 1684
if [[ $httpproto == https ]]; then if [[ $httpproto == https ]]; then
echo "<VirtualHost *:80>" > "$etcconf" echo "<VirtualHost *:80>" > "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf" echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$e tcconf" echo " SetHandler application/x-httpd-php" >> "$e tcconf"
else else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf" echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf"
fi fi
echo " </FilesMatch>" >> "$etcconf" echo " </FilesMatch>" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf" echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$etcconf"
echo " RewriteEngine On" >> "$etcconf" echo " RewriteEngine On" >> "$etcconf"
echo " RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" >> " $etcconf" echo " RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" >> " $etcconf"
echo " RewriteRule .* - [F]" >> "$etcconf" echo " RewriteRule .* - [F]" >> "$etcconf"
echo " RewriteRule /management/other/ca.cert.der$ - [L]" >> "$etcconf" echo " RewriteRule /management/other/ca.cert.der$ - [L]" >> "$etcconf"
echo " RewriteCond %{HTTPS} off" >> "$etcconf" echo " RewriteCond %{HTTPS} off" >> "$etcconf"
echo " RewriteRule (.*) https://%{HTTP_HOST}/\$1 [R,L]" > > "$etcconf" echo " RewriteRule (.*) https://%{HTTP_HOST}/\$1 [R,L]" > > "$etcconf"
echo "</VirtualHost>" >> "$etcconf" echo "</VirtualHost>" >> "$etcconf"
echo "<VirtualHost *:443>" >> "$etcconf" echo "<VirtualHost *:443>" >> "$etcconf"
echo " KeepAlive Off" >> "$etcconf" echo " KeepAlive Off" >> "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf" echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$e tcconf" echo " SetHandler application/x-httpd-php" >> "$e tcconf"
else else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf" echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf"
fi fi
echo " </FilesMatch>" >> "$etcconf" echo " </FilesMatch>" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf" echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$etcconf"
echo " DocumentRoot $docroot" >> "$etcconf" echo " DocumentRoot $docroot" >> "$etcconf"
echo " SSLEngine On" >> "$etcconf" echo " SSLEngine On" >> "$etcconf"
echo " SSLProtocol all -SSLv3 -SSLv2" >> "$etcconf" echo " SSLProtocol all -SSLv3 -SSLv2" >> "$etcconf"
echo " SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-E CDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384 :DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES12 8-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:E CDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDS A-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE- RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256 -GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-C BC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:! EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA" >> "$etcconf" echo " SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-E CDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384 :DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES12 8-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:E CDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDS A-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE- RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256 -GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-C BC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:! EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA" >> "$etcconf"
echo " SSLHonorCipherOrder On" >> "$etcconf" echo " SSLHonorCipherOrder On" >> "$etcconf"
echo " SSLCertificateFile $webdirdest/management/other/ss l/srvpublic.crt" >> "$etcconf" echo " SSLCertificateFile $webdirdest/management/other/ss l/srvpublic.crt" >> "$etcconf"
echo " SSLCertificateKeyFile $sslprivkey" >> "$etcconf" echo " SSLCertificateKeyFile $sslprivkey" >> "$etcconf"
echo " SSLCertificateChainFile $webdirdest/management/oth er/ca.cert.der" >> "$etcconf" echo " SSLCertificateChainFile $webdirdest/management/oth er/ca.cert.der" >> "$etcconf"
echo " <Directory $webdirdest>" >> "$etcconf" echo " <Directory $webdirdest>" >> "$etcconf"
echo " DirectoryIndex index.php index.html index.htm" >> "$etcconf" echo " DirectoryIndex index.php index.html index.htm" >> "$etcconf"
skipping to change at line 1475 skipping to change at line 1732
echo "<VirtualHost *:80>" > "$etcconf" echo "<VirtualHost *:80>" > "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf" echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$e tcconf" echo " SetHandler application/x-httpd-php" >> "$e tcconf"
else else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf" echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\ "" >> "$etcconf"
fi fi
echo " </FilesMatch>" >> "$etcconf" echo " </FilesMatch>" >> "$etcconf"
echo " KeepAlive Off" >> "$etcconf" echo " KeepAlive Off" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf" echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$etcconf"
echo " DocumentRoot $docroot" >> "$etcconf" echo " DocumentRoot $docroot" >> "$etcconf"
echo " <Directory $webdirdest>" >> "$etcconf" echo " <Directory $webdirdest>" >> "$etcconf"
echo " DirectoryIndex index.php index.html index.htm" >> "$etcconf" echo " DirectoryIndex index.php index.html index.htm" >> "$etcconf"
echo " </Directory>" >> "$etcconf" echo " </Directory>" >> "$etcconf"
echo " RewriteEngine On" >> "$etcconf" echo " RewriteEngine On" >> "$etcconf"
echo " RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" >> " $etcconf" echo " RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" >> " $etcconf"
echo " RewriteRule .* - [F]" >> "$etcconf" echo " RewriteRule .* - [F]" >> "$etcconf"
echo " RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} ! -f" >> "$etcconf" echo " RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} ! -f" >> "$etcconf"
echo " RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} ! -d" >> "$etcconf" echo " RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} ! -d" >> "$etcconf"
echo " RewriteRule ^/fog/(.*)$ /fog/api/index.php [QSA,L] " >> "$etcconf" echo " RewriteRule ^/fog/(.*)$ /fog/api/index.php [QSA,L] " >> "$etcconf"
skipping to change at line 1501 skipping to change at line 1759
phpfpmconf='/etc/php-fpm.d/www.conf'; phpfpmconf='/etc/php-fpm.d/www.conf';
;; ;;
2) 2)
if [[ $php_ver == 5 ]]; then if [[ $php_ver == 5 ]]; then
phpfpmconf="/etc/php$php_ver/fpm/pool.d/www.conf" phpfpmconf="/etc/php$php_ver/fpm/pool.d/www.conf"
else else
phpfpmconf="/etc/php/$php_ver/fpm/pool.d/www.conf" phpfpmconf="/etc/php/$php_ver/fpm/pool.d/www.conf"
fi fi
;; ;;
3) 3)
phpfpmconf='' phpfpmconf='/etc/php/php-fpm.d/www.conf'
;; ;;
esac esac
if [[ -n $phpfpmconf ]]; then if [[ -n $phpfpmconf ]]; then
sed -i 's/listen = .*/listen = 127.0.0.1:9000/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/listen = .*/listen = 127.0.0.1:9000/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/^[;]pm\.max_requests = .*/pm.max_requests = 2000/g ' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/^[;]pm\.max_requests = .*/pm.max_requests = 2000/g ' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/^[;]php_admin_value\[memory_limit\] = .*/php_admin _value[memory_limit] = 256M/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${ version}.log 2>&1 sed -i 's/^[;]php_admin_value\[memory_limit\] = .*/php_admin _value[memory_limit] = 256M/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${ version}.log 2>&1
sed -i 's/pm\.max_children = .*/pm.max_children = 50/g' $php fpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/pm\.max_children = .*/pm.max_children = 50/g' $php fpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/pm\.min_spare_servers = .*/pm.min_spare_servers = 5/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/pm\.min_spare_servers = .*/pm.min_spare_servers = 5/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/pm\.max_spare_servers = .*/pm.max_spare_servers = 10/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/pm\.max_spare_servers = .*/pm.max_spare_servers = 10/g' $phpfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/pm\.start_servers = 2/pm.start_servers = 5/g' $php fpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/pm\.start_servers = .*/pm.start_servers = 5/g' $ph pfpmconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
if [[ $osid -eq 2 ]]; then if [[ $osid -eq 2 ]]; then
a2enmod $phpcmd >>$workingdir/error_logs/fog_error_${version }.log 2>&1 a2enmod $phpcmd >>$workingdir/error_logs/fog_error_${version }.log 2>&1
a2enmod proxy_fcgi setenvif >>$workingdir/error_logs/fog_err or_${version}.log 2>&1 a2enmod proxy_fcgi setenvif >>$workingdir/error_logs/fog_err or_${version}.log 2>&1
a2enmod rewrite >>$workingdir/error_logs/fog_error_${version }.log 2>&1 a2enmod rewrite >>$workingdir/error_logs/fog_error_${version }.log 2>&1
a2enmod ssl >>$workingdir/error_logs/fog_error_${version}.lo g 2>&1 a2enmod ssl >>$workingdir/error_logs/fog_error_${version}.lo g 2>&1
a2ensite "001-fog" >>$workingdir/error_logs/fog_error_${vers ion}.log 2>&1 a2ensite "001-fog" >>$workingdir/error_logs/fog_error_${vers ion}.log 2>&1
a2dissite "000-default" >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1 a2dissite "000-default" >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
fi fi
fi fi
skipping to change at line 1581 skipping to change at line 1839
;; ;;
esac esac
errorStat $? errorStat $?
caCreated="yes" caCreated="yes"
} }
configureHttpd() { configureHttpd() {
dots "Stopping web service" dots "Stopping web service"
case $systemctl in case $systemctl in
yes) yes)
case $osid in case $osid in
1) 1|3)
systemctl stop httpd php-fpm >>$workingdir/error_logs/fog_er ror_${version}.log 2>&1 && sleep 2 systemctl stop httpd php-fpm >>$workingdir/error_logs/fog_er ror_${version}.log 2>&1 && sleep 2
;; ;;
2) 2)
systemctl stop apache2 php${php_ver}-fpm >>$workingdir/error _logs/fog_error_${version}.log 2>&1 && sleep 2 systemctl stop apache2 php${php_ver}-fpm >>$workingdir/error _logs/fog_error_${version}.log 2>&1 && sleep 2
;; ;;
esac esac
errorStat $? errorStat $?
;; ;;
*) *)
case $osid in case $osid in
skipping to change at line 1620 skipping to change at line 1878
dots "Removing vhost file" dots "Removing vhost file"
if [[ $osid -eq 2 ]]; then if [[ $osid -eq 2 ]]; then
a2dissite 001-fog >>$workingdir/error_logs/fog_error_${versi on}.log 2>&1 a2dissite 001-fog >>$workingdir/error_logs/fog_error_${versi on}.log 2>&1
a2ensite 000-default >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1 a2ensite 000-default >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1
fi fi
rm $etcconf >>$workingdir/error_logs/fog_error_${version}.log 2> &1 rm $etcconf >>$workingdir/error_logs/fog_error_${version}.log 2> &1
errorStat $? errorStat $?
;; ;;
esac esac
fi fi
if [[ $installtype == +([Nn]) && ! $fogupdateloaded -eq 1 && -z $autoaccept
]]; then
dummy=""
while [[ -z $dummy ]]; do
echo -n " * Is the MySQL password blank? (Y/n) "
read -r dummy
case $dummy in
[Yy]|[Yy][Ee][Ss]|"")
dummy='Y'
;;
[Nn]|[Nn][Oo])
echo -n " * Enter the MySQL password: "
read -rs PASSWORD1
echo
echo -n " * Re-enter the MySQL password: "
read -rs PASSWORD2
echo
if [[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1" ]]; then
dbpass=$PASSWORD1
else
dbpass=""
while ! [[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1"
]]; do
echo "Password entries were blank or didn't match!"
echo -n " * Enter the MySQL password: "
read -rs PASSWORD1
echo
echo -n " * Re-enter the MySQL password: "
read -rs PASSWORD2
echo
[[ ! -z $PASSWORD1 && $PASSWORD2 == "$PASSWORD1" ]]
&& dbpass=$PASSWORD1
done
fi
[[ $snmysqlpass != "$dbpass" ]] && snmysqlpass=$dbpass
;;
*)
dummy=""
echo " * Invalid input, please try again!"
;;
esac
done
fi
options=("-s")
[[ -n $snmysqlhost ]] && options=( "${options[@]}" "--host=$snmysqlhost" )
[[ -n $snmysqluser ]] && options=( "${options[@]}" "--user=$snmysqluser" )
[[ -n $snmysqlpass ]] && options=( "${options[@]}" "--password=$snmysqlpass"
)
sqlescsnmysqlpass=$(echo "$snmysqlpass" | sed -e s/\'/\'\'/g) # Replace ev
ery ' with '' for full MySQL escaping
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE User='root';
"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_${version}.l
og 2>&1
mysqlver=$(mysql -V | sed -n 's/.*Distrib[ ]\(\([0-9]\([.]\|\)\)*\).*\([-]\
|\)[,].*/\1/p')
mariadb=$(mysql -V | sed -n 's/.*Distrib[ ].*[-]\(.*\)[,].*/\1/p')
vertocheck="5.7"
[[ -n $mariadb ]] && vertocheck="10.2"
configureMySql
mysqlver=$(echo $mysqlver | awk -F'([.])' '{print $1"."$2}')
runTest=$(echo "$mysqlver < $vertocheck" | bc)
if [[ $runTest -eq 0 ]]; then
[[ -z $snmysqlhost ]] && snmysqlhost='localhost'
[[ -z $snmysqluser ]] && snmysqluser='root'
case $snmysqlhost in
127.0.0.1|[Ll][Oo][Cc][Aa][Ll][Hh][Oo][Ss][Tt])
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE
User='root';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'127.0.0.1' IDENTIFIED WITH mysql
_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'localhost' IDENTIFIED WITH mysql
_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
;;
*)
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE
User='root';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
sql="ALTER USER '$snmysqluser'@'$snmysqlhost' IDENTIFIED WITH my
sql_native_password BY '$sqlescsnmysqlpass';"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_
${version}.log 2>&1
;;
esac
fi
dots "Setting up Apache and PHP files" dots "Setting up Apache and PHP files"
if [[ ! -f $phpini ]]; then if [[ ! -f $phpini ]]; then
echo "Failed" echo "Failed"
echo " ###########################################" echo " ###########################################"
echo " # #" echo " # #"
echo " # PHP Failed to install properly #" echo " # PHP Failed to install properly #"
echo " # #" echo " # #"
echo " ###########################################" echo " ###########################################"
echo echo
echo " Could not find $phpini!" echo " Could not find $phpini!"
exit 1 exit 1
fi fi
if [[ $osid -eq 3 ]]; then if [[ $osid -eq 3 ]]; then
if [[ ! -f /etc/httpd/conf/httpd.conf ]]; then if [[ ! -f $httpdconf ]]; then
echo " Apache configs not found!" echo " Apache configs not found!"
exit 1 exit 1
fi fi
echo -e "<FilesMatch \.php$>\n\tSetHandler \"proxy:unix:/run/php-fpm/php -fpm.sock|fcgi://127.0.0.1/\"\n</FilesMatch>\n<IfModule dir_module>\n\tDirectory Index index.php index.html\n</IfModule>" >> /etc/httpd/conf/httpd.conf
# Enable Event # Enable Event
sed -i '/LoadModule mpm_event_module modules\/mod_mpm_event.so/s/^#//g' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2>& 1 sed -i '/LoadModule mpm_event_module modules\/mod_mpm_event.so/s/^#//g' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
# Disable prefork and worker # Disable prefork and worker
sed -i '/LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/s/^/# sed -i '/LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/s/^/#
/g' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log /g' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
2>&1 sed -i '/LoadModule mpm_worker_module modules\/mod_mpm_worker.so/s/^/#/g
sed -i '/LoadModule mpm_worker_module modules\/mod_mpm_worker.so/s/^/#/g ' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2
>&1
# Enable proxy # Enable proxy
sed -i '/LoadModule proxy_html_module modules\/mod_proxy_html.so/s/^#//g sed -i '/LoadModule proxy_html_module modules\/mod_proxy_html.so/s/^#//g
' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2 ' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
>&1 sed -i '/LoadModule xml2enc_module modules\/mod_xml2enc.so/s/^#//g' $htt
sed -i '/LoadModule proxy_module modules\/mod_proxy.so/s/^#//g' /etc/htt pdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
pd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i '/LoadModule proxy_module modules\/mod_proxy.so/s/^#//g' $httpdco
sed -i '/LoadModule proxy_http_module modules\/mod_proxy_http.so/s/^#//g nf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2 sed -i '/LoadModule proxy_http_module modules\/mod_proxy_http.so/s/^#//g
>&1 ' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i '/LoadModule proxy_fcgi_module modules\/mod_proxy_fcgi.so/s/^#//g sed -i '/LoadModule proxy_fcgi_module modules\/mod_proxy_fcgi.so/s/^#//g
' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2 ' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
>&1
# Enable socache # Enable socache
sed -i '/LoadModule socache_shmcb_module modules\/mod_socache_shmcb.so/s /^#//g' /etc/httpd/conf/httpd.conf >>$workingdir/error_logs/fog_error_${version} .log 2>&1 sed -i '/LoadModule socache_shmcb_module modules\/mod_socache_shmcb.so/s /^#//g' $httpdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
# Enable ssl # Enable ssl
sed -i '/LoadModule ssl_module modules\/mod_ssl.so/s/^#//g' /etc/httpd/c sed -i '/LoadModule ssl_module modules\/mod_ssl.so/s/^#//g' $httpdconf >
onf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 >$workingdir/error_logs/fog_error_${version}.log 2>&1
# Enable rewrite
sed -i '/LoadModule rewrite_module modules\/mod_rewrite.so/s/^#//g' $htt
pdconf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
# Enable our virtual host file for fog # Enable our virtual host file for fog
echo -e "# FOG Virtual Host\nInclude conf/extra/fog.conf" >> /etc/httpd/ conf/httpd.conf >>$workingdir/error_logs/fog_error_${version}.log 2>&1 grep -q "^Include conf/extra/fog\.conf" $httpdconf || echo -e "# FOG Vir tual Host\nListen 443\nInclude conf/extra/fog.conf" >>$httpdconf
# Enable php extensions # Enable php extensions
sed -i 's/;extension=bcmath/extension=bcmath/g' $phpini >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=bcmath/extension=bcmath/g' $phpini >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=curl/extension=curl/g' $phpini >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=curl/extension=curl/g' $phpini >>$workingdir/error_ logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=ftp/extension=ftp/g' $phpini >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 sed -i 's/;extension=ftp/extension=ftp/g' $phpini >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1
sed -i 's/;extension=gd/extension=gd/g' $phpini >>$workingdir/error_logs /fog_error_${version}.log 2>&1 sed -i 's/;extension=gd/extension=gd/g' $phpini >>$workingdir/error_logs /fog_error_${version}.log 2>&1
sed -i 's/;extension=gettext/extension=gettext/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=gettext/extension=gettext/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=ldap/extension=ldap/g' $phpini >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=ldap/extension=ldap/g' $phpini >>$workingdir/error_ logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=mysqli/extension=mysqli/g' $phpini >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=mysqli/extension=mysqli/g' $phpini >>$workingdir/er ror_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=openssl/extension=openssl/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=openssl/extension=openssl/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=pdo_mysql/extension=pdo_mysql/g' $phpini >>$working dir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=pdo_mysql/extension=pdo_mysql/g' $phpini >>$working dir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=posix/extension=posix/g' $phpini >>$workingdir/erro r_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=posix/extension=posix/g' $phpini >>$workingdir/erro r_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=sockets/extension=sockets/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1 sed -i 's/;extension=sockets/extension=sockets/g' $phpini >>$workingdir/ error_logs/fog_error_${version}.log 2>&1
sed -i 's/;extension=zip/extension=zip/g' $phpini >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 sed -i 's/;extension=zip/extension=zip/g' $phpini >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1
sed -i 's/open_basedir\ =/;open_basedir\ ="/g' $phpini >>$workingdir/err or_logs/fog_error_${version}.log 2>&1 sed -i 's/$open_basedir\ =/;open_basedir\ =/g' $phpini >>$workingdir/err or_logs/fog_error_${version}.log 2>&1
fi fi
sed -i 's/post_max_size\ \=\ 8M/post_max_size\ \=\ 3000M/g' $phpini >>$worki ngdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/post_max_size\ \=\ 8M/post_max_size\ \=\ 3000M/g' $phpini >>$worki ngdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/upload_max_filesize\ \=\ 2M/upload_max_filesize\ \=\ 3000M/g' $php ini >>$workingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/upload_max_filesize\ \=\ 2M/upload_max_filesize\ \=\ 3000M/g' $php ini >>$workingdir/error_logs/fog_error_${version}.log 2>&1
sed -i 's/.*max_input_vars\ \=.*$/max_input_vars\ \=\ 250000/g' $phpini >>$w orkingdir/error_logs/fog_error_${version}.log 2>&1 sed -i 's/.*max_input_vars\ \=.*$/max_input_vars\ \=\ 250000/g' $phpini >>$w orkingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
dots "Testing and removing symbolic links if found" dots "Testing and removing symbolic links if found"
if [[ -h ${docroot}fog ]]; then if [[ -h ${docroot}fog ]]; then
rm -f ${docroot}fog >>$workingdir/error_logs/fog_error_${version}.log 2> &1 rm -f ${docroot}fog >>$workingdir/error_logs/fog_error_${version}.log 2> &1
fi fi
if [[ -h ${docroot}${webroot} ]]; then if [[ -h ${docroot}${webroot} ]]; then
skipping to change at line 1920 skipping to change at line 2106
define('CHECKIN_TIMEOUT', 600); define('CHECKIN_TIMEOUT', 600);
define('USER_MINPASSLENGTH', 4); define('USER_MINPASSLENGTH', 4);
define('NFS_ETH_MONITOR', \"${interface}\"); define('NFS_ETH_MONITOR', \"${interface}\");
define('UDPCAST_INTERFACE', \"${interface}\"); define('UDPCAST_INTERFACE', \"${interface}\");
// Must be an even number! recommended between 49152 to 65535 // Must be an even number! recommended between 49152 to 65535
define('UDPCAST_STARTINGPORT', 63100); define('UDPCAST_STARTINGPORT', 63100);
define('FOG_MULTICAST_MAX_SESSIONS', 64); define('FOG_MULTICAST_MAX_SESSIONS', 64);
define('FOG_JPGRAPH_VERSION', '2.3'); define('FOG_JPGRAPH_VERSION', '2.3');
define('FOG_REPORT_DIR', './reports/'); define('FOG_REPORT_DIR', './reports/');
define('FOG_CAPTUREIGNOREPAGEHIBER', true); define('FOG_CAPTUREIGNOREPAGEHIBER', true);
define('FOG_THEME', 'default/fog.css');
} }
}" > "${webdirdest}/lib/fog/config.class.php" }" > "${webdirdest}/lib/fog/config.class.php"
errorStat $? errorStat $?
if [[ $fullrelease == 0 ]]; then downloadfiles
downloadfiles
else
if [[ ! -f ../binaries${fullrelease}.zip ]]; then
dots "Downloading binaries needed"
curl --silent -ko "../binaries${fullrelease}.zip" "https://fogprojec
t.org/binaries${fullrelease}.zip" >>$workingdir/error_logs/fog_error_${version}.
log 2>&1
errorStat $?
fi
dots "Unzipping the binaries"
cwd=$(pwd)
cd ..
unzip -o binaries${fullrelease}.zip >>$workingdir/error_logs/fog_error_$
{version}.log 2>&1
cd $cwd
echo "Done"
dots "Copying binaries where needed"
[[ -d ../packages/clientfiles/ ]] && cp -vf ../packages/clientfiles/* "$
{webdirdest}/client/" >>$workingdir/error_logs/fog_error_${version}.log 2>&1 ||
errorStat 1
[[ -d ../packages/kernels/ ]] && cp -vf ../packages/kernels/* "${webdird
est}/service/ipxe/" >>$workingdir/error_logs/fog_error_${version}.log 2>&1 || er
rorStat 1
[[ -d ../packages/inits/ ]] && cp -vf ../packages/inits/* "${webdirdest}
/service/ipxe/" >>$workingdir/error_logs/fog_error_${version}.log 2>&1 || errorS
tat 1
echo "Done"
fi
if [[ $osid -eq 2 ]]; then if [[ $osid -eq 2 ]]; then
php -m | grep mysqlnd >>$workingdir/error_logs/fog_error_${version}.log 2>&1 php -m | grep mysqlnd >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
${phpcmd}enmod mysqlnd >>$workingdir/error_logs/fog_error_${version} .log 2>&1 ${phpcmd}enmod mysqlnd >>$workingdir/error_logs/fog_error_${version} .log 2>&1
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
if [[ -e /etc/php${php_ver}/conf.d/mysqlnd.ini ]]; then if [[ -e /etc/php${php_ver}/conf.d/mysqlnd.ini ]]; then
cp -f "/etc/php${php_ver}/conf.d/mysqlnd.ini" "/etc/php${php _ver}/mods-available/php${php_ver}-mysqlnd.ini" >>$workingdir/error_logs/fog_err or_${version}.log 2>&1 cp -f "/etc/php${php_ver}/conf.d/mysqlnd.ini" "/etc/php${php _ver}/mods-available/php${php_ver}-mysqlnd.ini" >>$workingdir/error_logs/fog_err or_${version}.log 2>&1
${phpcmd}enmod mysqlnd >>$workingdir/error_logs/fog_error_${ version}.log 2>&1 ${phpcmd}enmod mysqlnd >>$workingdir/error_logs/fog_error_${ version}.log 2>&1
fi fi
fi fi
skipping to change at line 1984 skipping to change at line 2152
chmod +rx $apacheerrlog chmod +rx $apacheerrlog
chmod +rx $apacheacclog chmod +rx $apacheacclog
chown -R ${apacheuser}:${apacheuser} $webdirdest chown -R ${apacheuser}:${apacheuser} $webdirdest
errorStat $? errorStat $?
[[ -d /var/www/html/ && ! -e /var/www/html/fog/ ]] && ln -s "$webdirdest" /v ar/www/html/ [[ -d /var/www/html/ && ! -e /var/www/html/fog/ ]] && ln -s "$webdirdest" /v ar/www/html/
[[ -d /var/www/ && ! -e /var/www/fog ]] && ln -s "$webdirdest" /var/www/ [[ -d /var/www/ && ! -e /var/www/fog ]] && ln -s "$webdirdest" /var/www/
chown -R ${apacheuser}:${apacheuser} "$webdirdest" chown -R ${apacheuser}:${apacheuser} "$webdirdest"
chown -R ${username}:${apacheuser} "$webdirdest/service/ipxe" chown -R ${username}:${apacheuser} "$webdirdest/service/ipxe"
} }
downloadfiles() { downloadfiles() {
clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4}' .. dots "Downloading kernel, init and fog-client binaries"
/packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')" [[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
clienturl="https://github.com/FOGProject/fog-client/releases/download/${clie cwd=$(pwd)
ntVer}/FOGService.msi" cd ../tmp/
siurl="https://github.com/FOGProject/fog-client/releases/download/${clientVe if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]
r}/SmartInstaller.exe" then
[[ ! -d $workingdir/checksum_init ]] && mkdir -p $workingdir/checksum_init > urls=( "https://fogproject.org/binaries${version}.zip" )
/dev/null 2>&1 else
[[ ! -d $workingdir/checksum_kernel ]] && mkdir -p $workingdir/checksum_kern clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4}
el >/dev/null 2>&1 ' ../packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')"
dots "Getting checksum files for kernels and inits" urls=( "https://fogproject.org/inits/init.xz" "https://fogproject.org/in
curl --silent -ko "${workingdir}/checksum_init/checksums" https://fogproject its/init_32.xz" "https://fogproject.org/kernels/bzImage" "https://fogproject.org
.org/inits/index.php -ko "${workingdir}/checksum_kernel/checksums" https://fogpr /kernels/bzImage32" "https://github.com/FOGProject/fog-client/releases/download/
oject.org/kernels/index.php >>$workingdir/error_logs/fog_error_${version}.log 2> ${clientVer}/FOGService.msi" "https://github.com/FOGProject/fog-client/releases/
&1 download/${clientVer}/SmartInstaller.exe" )
errorStat $?
dots "Downloading inits, kernels, and the fog client"
curl --silent -ko "${webdirdest}/service/ipxe/init.xz" https://fogproject.or
g/inits/init.xz -ko "${webdirdest}/service/ipxe/init_32.xz" https://fogproject.o
rg/inits/init_32.xz -ko "${webdirdest}/service/ipxe/bzImage" https://fogproject.
org/kernels/bzImage -ko "${webdirdest}/service/ipxe/bzImage32" https://fogprojec
t.org/kernels/bzImage32 >>$workingdir/error_logs/fog_error_${version}.log 2>&1 &
& curl --silent -ko "${webdirdest}/client/FOGService.msi" -L $clienturl -ko "${w
ebdirdest}/client/SmartInstaller.exe" -L $siurl >> $workingdir/error_logs/fog_er
ror_${version}.log 2>&1
errorStat $?
dots "Comparing checksums of kernels and inits"
localinitsum=$(sha512sum $webdirdest/service/ipxe/init.xz | awk '{print $1}'
)
localinit_32sum=$(sha512sum $webdirdest/service/ipxe/init_32.xz | awk '{prin
t $1}')
localbzImagesum=$(sha512sum $webdirdest/service/ipxe/bzImage | awk '{print $
1}')
localbzImage32sum=$(sha512sum $webdirdest/service/ipxe/bzImage32 | awk '{pri
nt $1}')
remoteinitsum=$(awk '/init\.xz$/{print $1}' $workingdir/checksum_init/checks
ums)
remoteinit_32sum=$(awk '/init_32\.xz$/{print $1}' $workingdir/checksum_init/
checksums)
remotebzImagesum=$(awk '/bzImage$/{print $1}' $workingdir/checksum_kernel/ch
ecksums)
remotebzImage32sum=$(awk '/bzImage32$/{print $1}' $workingdir/checksum_kerne
l/checksums)
cnt=0
while [[ $localinitsum != $remoteinitsum && $cnt -lt 10 ]]; do
[[ $cnt -eq 0 ]] && echo "Failed init.xz"
let cnt+=1
dots "Attempting to redownload init.xz"
curl --silent -ko "${webdirdest}/service/ipxe/init.xz" https://fogprojec
t.org/inits/init.xz >/dev/null 2>&1
errorStat $?
localinitsum=$(sha512sum $webdirdest/service/ipxe/init.xz | awk '{print
$1}')
done
if [[ $localinitsum != $remoteinitsum ]]; then
echo " * Could not download init.xz properly"
[[ -z $exitFail ]] && exit 1
fi
cnt=0
while [[ $localinit_32sum != $remoteinit_32sum && $cnt -lt 10 ]]; do
[[ $cnt -eq 0 ]] && echo "Failed init_32.xz"
let cnt+=1
dots "Attempting to redownload init_32.xz"
curl --silent -ko "${webdirdest}/service/ipxe/init_32.xz" https://fogpro
ject.org/inits/init_32.xz >/dev/null 2>&1
errorStat $?
localinit_32sum=$(sha512sum $webdirdest/service/ipxe/init_32.xz | awk '{
print $1}')
done
if [[ $localinit_32sum != $remoteinit_32sum ]]; then
echo " * Could not download init_32.xz properly"
[[ -z $exitFail ]] && exit 1
fi fi
cnt=0 for url in "${urls[@]}"
while [[ $localbzImagesum != $remotebzImagesum && $cnt -lt 10 ]]; do do
[[ $cnt -eq 0 ]] && echo "Failed bzImage" checksum=1
let cnt+=1 cnt=0
dots "Attempting to redownload bzImage" filename=$(basename -- "$url")
curl --silent -ko "${webdirdest}/service/ipxe/bzImage" https://fogprojec hashfile="${filename}.sha256"
t.org/kernels/bzImage >/dev/null 2>&1 baseurl=$(dirname -- "$url")
errorStat $? hashurl="${baseurl}/${hashfile}"
localbzImagesum=$(sha512sum $webdirdest/service/ipxe/bzImage | awk '{pri while [[ $checksum -ne 0 && $cnt -lt 10 ]]
nt $1}') do
sha256sum --check $hashfile >>$workingdir/error_logs/fog_error_${ver
sion}.log 2>&1
checksum=$?
if [[ $checksum -ne 0 ]]
then
curl --silent -kOL $url >>$workingdir/error_logs/fog_error_${ver
sion}.log 2>&1
curl --silent -kOL $hashurl >>$workingdir/error_logs/fog_error_$
{version}.log 2>&1
fi
let cnt+=1
done
if [[ $checksum -ne 0 ]]
then
echo " * Could not download $filename properly"
[[ -z $exitFail ]] && exit 1
fi
done done
if [[ $localbzImagesum != $remotebzImagesum ]]; then echo "Done"
echo " * Could not download bzImage properly" if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]
[[ -z $exitFail ]] && exit 1 then
fi dots "Extracting the binaries archive"
cnt=0 unzip -o binaries${version}.zip >>$workingdir/error_logs/fog_error_${ver
while [[ $localbzImage32sum != $remotebzImage32sum && $cnt -lt 10 ]]; do sion}.log 2>&1
[[ $cnt -eq 0 ]] && echo "Failed bzImage32"
let cnt+=1
dots "Attempting to redownload bzImage32"
curl --silent -ko "${webdirdest}/service/ipxe/bzImage32" https://fogproj
ect.org/kernels/bzImage32 >/dev/null 2>&1
errorStat $? errorStat $?
localbzImage32sum=$(sha512sum $webdirdest/service/ipxe/bzImage32 | awk ' copypath="packages/*/"
{print $1}')
done
if [[ $localbzImage32sum != $remotebzImage32sum ]]; then
echo " * Could not download bzImage32 properly"
[[ -z $exitFail ]] && exit 1
fi fi
echo "Done" dots "Copying binaries to destination paths"
cp -vf ${copypath}bzImage* ${copypath}init*.xz ${webdirdest}/service/ipxe/ >
>$workingdir/error_logs/fog_error_${version}.log && cp -vf ${copypath}FOGService
.msi ${copypath}SmartInstaller.exe ${webdirdest}/client/ >>$workingdir/error_log
s/fog_error_${version}.log 2>&1
errorStat $?
cd $cwd
} }
configureDHCP() { configureDHCP() {
case $linuxReleaseName in case $linuxReleaseName in
*[Dd][Ee][Bb][Ii][Aa][Nn]*) *[Dd][Ee][Bb][Ii][Aa][Nn]*)
if [[ $bldhcp -eq 1 ]]; then if [[ $bldhcp -eq 1 ]]; then
dots "Setting up and starting DHCP Server (incl. debian 9 fix)" dots "Setting up and starting DHCP Server (incl. debian 9 fix)"
sed -i.fog "s/INTERFACESv4=\"\"/INTERFACESv4=\"$interface\"/g" / etc/default/isc-dhcp-server sed -i.fog "s/INTERFACESv4=\"\"/INTERFACESv4=\"$interface\"/g" / etc/default/isc-dhcp-server
else else
dots "Setting up and starting DHCP Server" dots "Setting up and starting DHCP Server"
fi fi
 End of changes. 68 change blocks. 
404 lines changed or deleted 544 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)