"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/common/functions.sh" between
fogproject-1.5.8.tar.gz and fogproject-1.5.9.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.8):functions.sh  (fogproject-1.5.9)
skipping to change at line 35 skipping to change at line 35
dots "Backing up user reports" dots "Backing up user reports"
[[ ! -d ../rpttmp/ ]] && mkdir ../rpttmp/ >>$workingdir/error_logs/fog_error _${version}.log [[ ! -d ../rpttmp/ ]] && mkdir ../rpttmp/ >>$workingdir/error_logs/fog_error _${version}.log
[[ -d $webdirdest/management/reports/ ]] && cp -a $webdirdest/management/rep orts/* ../rpttmp/ >>$workingdir/error_logs/fog_error_${version}.log [[ -d $webdirdest/management/reports/ ]] && cp -a $webdirdest/management/rep orts/* ../rpttmp/ >>$workingdir/error_logs/fog_error_${version}.log
echo "Done" echo "Done"
return 0 return 0
} }
checkDatabaseConnection() { checkDatabaseConnection() {
dots "Checking connection to master database" dots "Checking connection to master database"
[[ -n $snmysqlhost ]] && host="--host=$snmysqlhost" [[ -n $snmysqlhost ]] && host="--host=$snmysqlhost"
sqloptionsuser="${host} -s --user=${snmysqluser}" sqloptionsuser="${host} -s --user=${snmysqluser}"
mysql $sqloptionsuser --password=${snmysqlpass} --execute="quit" >/dev/null 2>&1 mysql $sqloptionsuser --password="${snmysqlpass}" --execute="quit" >/dev/nul l 2>&1
errorStat $? errorStat $?
} }
registerStorageNode() { registerStorageNode() {
[[ -z $webroot ]] && webroot="/" [[ -z $webroot ]] && webroot="/"
dots "Checking if this node is registered" dots "Checking if this node is registered"
storageNodeExists=$(wget --no-check-certificate -qO - ${httpproto}://$ipaddr ess/${webroot}/maintenance/check_node_exists.php --post-data="ip=${ipaddress}") storageNodeExists=$(wget --no-check-certificate -qO - ${httpproto}://$ipaddr ess/${webroot}/maintenance/check_node_exists.php --post-data="ip=${ipaddress}")
echo "Done" echo "Done"
if [[ $storageNodeExists != exists ]]; then if [[ $storageNodeExists != exists ]]; then
[[ -z $maxClients ]] && maxClients=10 [[ -z $maxClients ]] && maxClients=10
dots "Node being registered" dots "Node being registered"
skipping to change at line 98 skipping to change at line 98
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
read -p " * Press [Enter] key when database is updated/installed." read -p " * Press [Enter] key when database is updated/installed."
echo echo
;; ;;
esac esac
dots "Update fogstorage database password" dots "Update fogstorage database password"
mysql $sqloptionsuser --password=${snmysqlpass} --execute="INSERT INTO globa lSettings (settingKey, settingDesc, settingValue, settingCategory) VALUES ('FOG_ STORAGENODE_MYSQLPASS', 'This setting defines the password the storage nodes sho uld use to connect to the fog server.', \"$snmysqlstoragepass\", 'FOG Storage No des') ON DUPLICATE KEY UPDATE settingValue=\"$snmysqlstoragepass\"" $mysqldbname >>$workingdir/error_logs/fog_error_${version}.log 2>&1 mysql $sqloptionsuser --password="${snmysqlpass}" --execute="INSERT INTO glo balSettings (settingKey, settingDesc, settingValue, settingCategory) VALUES ('FO G_STORAGENODE_MYSQLPASS', 'This setting defines the password the storage nodes s hould use to connect to the fog server.', \"$snmysqlstoragepass\", 'FOG Storage Nodes') ON DUPLICATE KEY UPDATE settingValue=\"$snmysqlstoragepass\"" $mysqldbna me >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
dots "Granting access to fogstorage database user" dots "Granting access to fogstorage database user"
if [[ -n $snmysqlrootpass ]]; then mysql ${host} -s --user=fogstorage --password="${snmysqlstoragepass}" --exec
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1 ute="INSERT INTO $mysqldbname.taskLog VALUES ( 0, '999test', 3, '127.0.0.1', NOW
cat >../tmp/fog-db-grant-fogstorage-access.sql <<EOF (), 'fog');" >/dev/null 2>&1
connect_as_fogstorage=$?
if [[ $connect_as_fogstorage -eq 0 ]]; then
mysql $sqloptionsuser --password="${snmysqlpass}" --execute="DELETE FROM
$mysqldbname.taskLog WHERE taskID='999test' AND ip='127.0.0.1';" >/dev/null 2>&
1
echo "Skipped"
return
fi
# we still need to grant access for the fogstorage DB user
# and therefore need root DB access
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >>$wo
rkingdir/error_logs/fog_error_${version}.log 2>&1
if [[ $? -ne 0 ]]; then
echo
echo " To improve the overall security the installer will restrict"
echo " permissions for the *fogstorage* database user."
echo " Please provide the database *root* user password. Be asured"
echo " that this password will only be used while the FOG installer"
echo -n " is running and won't be stored anywhere: "
read -rs snmysqlrootpass
echo
echo
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >
/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo " Unable to connect to the database using the given password!
"
echo -n " Try again: "
read -rs snmysqlrootpass
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="qui
t" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo
echo " Failed! Terminating installer now."
exit 1
fi
fi
fi
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
cat >../tmp/fog-db-grant-fogstorage-access.sql <<EOF
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ;
GRANT SELECT ON $mysqldbname.* TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.hosts TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.hosts TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.inventory TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.inventory TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessions TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.multicastSessions TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessionsAssoc TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.multicastSessionsAssoc TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.nfsGroupMembers TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.nfsGroupMembers TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.tasks TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.tasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskStates TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.taskStates TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskLog TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.taskLog TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinTasks TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.snapinTasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinJobs TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.snapinJobs TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.imagingLog TO 'fogstorage'@'%' ; GRANT INSERT,UPDATE ON $mysqldbname.imagingLog TO 'fogstorage'@'%' ;
FLUSH PRIVILEGES ; FLUSH PRIVILEGES ;
SET SQL_MODE=@OLD_SQL_MODE ; SET SQL_MODE=@OLD_SQL_MODE ;
EOF EOF
mysql $sqloptionsroot --password=${snmysqlrootpass} <../tmp/fog-db-grant mysql $sqloptionsroot --password="${snmysqlrootpass}" <../tmp/fog-db-grant-f
-fogstorage-access.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1 ogstorage-access.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
else
echo "Skipped"
fi
} }
validip() { validip() {
local ip=$1 local ip=$1
local stat=1 local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS OIFS=$IFS
IFS='.' IFS='.'
ip=($ip) ip=($ip)
IFS=$OIFS IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
skipping to change at line 348 skipping to change at line 379
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
} }
getAllNetworkInterfaces() { getAllNetworkInterfaces() {
gatewayif=$(ip -4 route show | grep "^default via" | awk '{print $5}') gatewayif=$(ip -4 route show | grep "^default via" | awk '{print $5}')
interfaces="$gatewayif $(ip -4 link | grep -v LOOPBACK | grep UP | awk -F': if [[ -z ${gatewayif} ]]; then
|@' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")" interfaces="$(ip -4 link | grep -v LOOPBACK | grep UP | awk -F': |@' '{p
rint $2}' | tr '\n' ' ')"
else
interfaces="$gatewayif $(ip -4 link | grep -v LOOPBACK | grep UP | awk -
F': |@' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")"
fi
echo -n $interfaces echo -n $interfaces
} }
checkInternetConnection() { checkInternetConnection() {
sites=( "k.root-servers.net" "m.root-servers.net" "f.root-servers.net" ) sites=( "k.root-servers.net" "m.root-servers.net" "f.root-servers.net" )
ips=( "193.0.14.129" "202.12.27.33" "192.5.5.241" ) ips=( "193.0.14.129" "202.12.27.33" "192.5.5.241" )
dots "Testing internet connection" dots "Testing internet connection"
for i in $(seq 0 2); do for i in $(seq 0 2); do
ping -c 1 ${ips[$i]} >/dev/null 2>&1 ping -c 1 ${ips[$i]} >/dev/null 2>&1
[[ $? -ne 0 ]] && continue [[ $? -ne 0 ]] && continue
ping -c 1 ${sites[$i]} >/dev/null 2>&1 ping -c 1 ${sites[$i]} >/dev/null 2>&1
skipping to change at line 400 skipping to change at line 435
mkdir -p $servicelogs mkdir -p $servicelogs
errorStat $? errorStat $?
} }
configureUDPCast() { configureUDPCast() {
dots "Setting up UDPCast" dots "Setting up UDPCast"
cp -Rf "$udpcastsrc" "$udpcasttmp" cp -Rf "$udpcastsrc" "$udpcasttmp"
cur=$(pwd) cur=$(pwd)
cd /tmp cd /tmp
tar xvzf "$udpcasttmp" >>$workingdir/error_logs/fog_error_${version}.log 2>& 1 tar xvzf "$udpcasttmp" >>$workingdir/error_logs/fog_error_${version}.log 2>& 1
cd $udpcastout cd $udpcastout
grep -q 'BCM[0-9][0-9][0-9][0-9]' /proc/cpuinfo >>$workingdir/error_logs/fog
_error_${version}.log 2>&1
if [[ $? -eq 0 ]]; then
wget -qO config.guess "https://git.savannah.gnu.org/gitweb/?p=config.git
;a=blob_plain;f=config.guess" >>$workingdir/error_logs/fog_error_${version}.log
2>&1
wget -qO config.sub "https://git.savannah.gnu.org/gitweb/?p=config.git;a
=blob_plain;f=config.sub" >>$workingdir/error_logs/fog_error_${version}.log 2>&1
chmod +x config.guess config.sub >>$workingdir/error_logs/fog_error_${ve
rsion}.log 2>&1
fi
errorStat $? errorStat $?
dots "Configuring UDPCast" dots "Configuring UDPCast"
./configure >>$workingdir/error_logs/fog_error_${version}.log 2>&1 ./configure >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
dots "Building UDPCast" dots "Building UDPCast"
make >>$workingdir/error_logs/fog_error_${version}.log 2>&1 make >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
dots "Installing UDPCast" dots "Installing UDPCast"
make install >>$workingdir/error_logs/fog_error_${version}.log 2>&1 make install >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
cd $cur cd $cur
} }
configureFTP() { configureFTP() {
dots "Setting up and starting VSFTP Server..." dots "Setting up and starting VSFTP Server..."
if [[ -f $ftpconfig ]]; then
mv $ftpconfig ${ftpconfig}.fogbackup
fi
if [[ -f $ftpxinetd ]]; then if [[ -f $ftpxinetd ]]; then
mv $ftpxinetd ${ftpxinetd}.fogbackup mv $ftpxinetd ${ftpxinetd}.fogbackup
fi fi
vsftp=$(vsftpd -version 0>&1 | awk -F'version ' '{print $2}') vsftp=$(vsftpd -version 0>&1 | awk -F'version ' '{print $2}')
vsvermaj=$(echo $vsftp | awk -F. '{print $1}') vsvermaj=$(echo $vsftp | awk -F. '{print $1}')
vsverbug=$(echo $vsftp | awk -F. '{print $3}') vsverbug=$(echo $vsftp | awk -F. '{print $3}')
seccompsand="" seccompsand=""
allow_writeable_chroot="" allow_writeable_chroot=""
if [[ $vsvermaj -gt 3 ]] || [[ $vsvermaj -eq 3 && $vsverbug -ge 2 ]]; then if [[ $vsvermaj -gt 3 ]] || [[ $vsvermaj -eq 3 && $vsverbug -ge 2 ]]; then
seccompsand="seccomp_sandbox=NO" seccompsand="seccomp_sandbox=NO"
fi fi
mv -fv "${ftpconfig}" "${ftpconfig}.${timestamp}" >>$workingdir/error_logs/f og_error_${version}.log 2>&1
echo -e "max_per_ip=200\nanonymous_enable=NO\nlocal_enable=YES\nwrite_enabl e=YES\nlocal_umask=022\ndirmessage_enable=YES\nxferlog_enable=YES\nconnect_from_ port_20=YES\nxferlog_std_format=YES\nlisten=YES\npam_service_name=vsftpd\nuserli st_enable=NO\n$seccompsand" > "$ftpconfig" echo -e "max_per_ip=200\nanonymous_enable=NO\nlocal_enable=YES\nwrite_enabl e=YES\nlocal_umask=022\ndirmessage_enable=YES\nxferlog_enable=YES\nconnect_from_ port_20=YES\nxferlog_std_format=YES\nlisten=YES\npam_service_name=vsftpd\nuserli st_enable=NO\n$seccompsand" > "$ftpconfig"
diffconfig "${ftpconfig}"
case $systemctl in case $systemctl in
yes) yes)
systemctl enable vsftpd >>$workingdir/error_logs/fog_error_${version }.log 2>&1 systemctl enable vsftpd >>$workingdir/error_logs/fog_error_${version }.log 2>&1
sleep 2 sleep 2
systemctl stop vsftpd >>$workingdir/error_logs/fog_error_${version}. log 2>&1 systemctl stop vsftpd >>$workingdir/error_logs/fog_error_${version}. log 2>&1
sleep 2 sleep 2
systemctl start vsftpd >>$workingdir/error_logs/fog_error_${version} .log 2>&1 systemctl start vsftpd >>$workingdir/error_logs/fog_error_${version} .log 2>&1
sleep 2 sleep 2
systemctl status vsftpd >>$workingdir/error_logs/fog_error_${version }.log 2>&1 systemctl status vsftpd >>$workingdir/error_logs/fog_error_${version }.log 2>&1
;; ;;
skipping to change at line 609 skipping to change at line 649
packages="${packages// mysql / mariadb }">>$workingdir/error _logs/fog_error_${version}.log 2>&1 packages="${packages// mysql / mariadb }">>$workingdir/error _logs/fog_error_${version}.log 2>&1
packages="${packages// mysql-server / mariadb-server }">>$wo rkingdir/error_logs/fog_error_${version}.log 2>&1 packages="${packages// mysql-server / mariadb-server }">>$wo rkingdir/error_logs/fog_error_${version}.log 2>&1
packages="${packages// dhcp / dhcp-server }">>$workingdir/er ror_logs/fog_error_${version}.log 2>&1 packages="${packages// dhcp / dhcp-server }">>$workingdir/er ror_logs/fog_error_${version}.log 2>&1
;; ;;
*) *)
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
y="https://dl.fedoraproject.org/pub/epel/epel-release-la test-${OSVersion}.noarch.rpm" y="https://dl.fedoraproject.org/pub/epel/epel-release-la test-${OSVersion}.noarch.rpm"
$packageinstaller $y >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 $packageinstaller $y >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1
errorStat $? "skipOk"
fi fi
y="http://rpms.remirepo.net/enterprise/remi-release-${OSVers ion}.rpm" y="http://rpms.remirepo.net/enterprise/remi-release-${OSVers ion}.rpm"
x=$(basename $y | awk -F[.] '{print $1}') x="$(basename $y | awk -F[.] '{print $1}')*"
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
rpm -Uvh $y >>$workingdir/error_logs/fog_error_${version }.log 2>&1 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 errorStat $? "skipOk"
fi fi
rpm --import "http://rpms.remirepo.net/RPM-GPG-KEY-remi" >>$
workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? "skipOk"
if [[ -n $repoenable ]]; then if [[ -n $repoenable ]]; then
if [[ $OSVersion -le 7 ]]; then if [[ $OSVersion -le 7 ]]; then
$repoenable epel >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 || true $repoenable epel >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 || true
$repoenable remi >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 || true $repoenable remi >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 || true
$repoenable remi-php72 >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 || true $repoenable remi-php72 >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 || true
fi fi
fi fi
;; ;;
esac esac
;; ;;
skipping to change at line 657 skipping to change at line 700
ppa-purge -y ppa:ondrej/apache2 >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 ppa-purge -y ppa:ondrej/apache2 >>$workingdir/error_ logs/fog_error_${version}.log 2>&1
# for php we want to purge all packages first as we don't want ppa-purge to try downgrading those # for php we want to purge all packages first as we don't want ppa-purge to try downgrading those
DEBIAN_FRONTEND=noninteractive apt-get purge -yq 'ph p5*' 'php7*' 'libapache*' >>$workingdir/error_logs/fog_error_${version}.log 2>&1 DEBIAN_FRONTEND=noninteractive apt-get purge -yq 'ph p5*' 'php7*' 'libapache*' >>$workingdir/error_logs/fog_error_${version}.log 2>&1
ppa-purge -y ppa:ondrej/php >>$workingdir/error_logs /fog_error_${version}.log 2>&1 ppa-purge -y ppa:ondrej/php >>$workingdir/error_logs /fog_error_${version}.log 2>&1
DEBIAN_FRONTEND=noninteractive apt-get purge -yq ppa -purge >>$workingdir/error_logs/fog_error_${version}.log 2>&1 DEBIAN_FRONTEND=noninteractive apt-get purge -yq ppa -purge >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
else else
addOndrejRepo addOndrejRepo
fi fi
;; ;;
*[Dd][Ee][Bb][Ii][Aa][Nn]*) *[Bb][Ii][Aa][Nn]*)
if [[ $OSVersion -ge 10 ]]; then if [[ $OSVersion -ge 10 ]]; then
packages="${packages// libcurl3 / libcurl4 }">>$workingd ir/error_logs/fog_error_${version}.log 2>&1 packages="${packages// libcurl3 / libcurl4 }">>$workingd ir/error_logs/fog_error_${version}.log 2>&1
packages="${packages// mysql-client / mariadb-client }"> >$workingdir/error_logs/fog_error_${version}.log 2>&1 packages="${packages// mysql-client / mariadb-client }"> >$workingdir/error_logs/fog_error_${version}.log 2>&1
packages="${packages// mysql-server / mariadb-server }"> >$workingdir/error_logs/fog_error_${version}.log 2>&1 packages="${packages// mysql-server / mariadb-server }"> >$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
;; ;;
esac esac
;; ;;
3) 3)
skipping to change at line 783 skipping to change at line 826
} }
checkSELinux() { checkSELinux() {
command -v sestatus >>$workingdir/error_logs/fog_error_${version}.log 2>&1 command -v sestatus >>$workingdir/error_logs/fog_error_${version}.log 2>&1
exitcode=$? exitcode=$?
[[ $exitcode -ne 0 ]] && return [[ $exitcode -ne 0 ]] && return
currentmode=$(LANG=C sestatus | grep "^Current mode" | awk '{print $3}') currentmode=$(LANG=C sestatus | grep "^Current mode" | awk '{print $3}')
configmode=$(LANG=C sestatus | grep "^Mode from config file" | awk '{print $ 5}') configmode=$(LANG=C sestatus | grep "^Mode from config file" | awk '{print $ 5}')
[[ "$currentmode" != "enforcing" && "$configmode" != "enforcing" ]] && retur n [[ "$currentmode" != "enforcing" && "$configmode" != "enforcing" ]] && retur n
echo " * SELinux is currently enabled on your system. This is often causing" 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 " * issues and we recommend to disable it on FOG servers as of now."
echo " * Should the installer disable SELinux for you now? (Y/n)" echo -n " * Should the installer disable SELinux for you now? (Y/n) "
sedisable="" sedisable=""
while [[ -z $sedisable ]]; do while [[ -z $sedisable ]]; do
if [[ -n $autoaccept ]]; then if [[ -n $autoaccept ]]; then
sedisable="Y" sedisable="Y"
else else
read -r sedisable read -r sedisable
fi fi
case $sedisable in case $sedisable in
[Yy]|[Yy][Ee][Ss]|"") [Yy]|[Yy][Ee][Ss]|"")
sedisable="Y" sedisable="Y"
skipping to change at line 825 skipping to change at line 868
fi fi
command -v firewall-cmd >>$workingdir/error_logs/fog_error_${version}.log 2> &1 command -v firewall-cmd >>$workingdir/error_logs/fog_error_${version}.log 2> &1
fwcmd=$? fwcmd=$?
if [[ $fwcmd -eq 0 ]]; then if [[ $fwcmd -eq 0 ]]; then
fwstate=$(firewall-cmd --state 2>&1) fwstate=$(firewall-cmd --state 2>&1)
[[ "x$fwstate" == "xrunning" ]] && fwrunning=1 [[ "x$fwstate" == "xrunning" ]] && fwrunning=1
fi fi
[[ $fwrunning -ne 1 ]] && return [[ $fwrunning -ne 1 ]] && return
echo " * The local firewall seems to be currently enabled on your system. Th is can cause" 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 " * 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)" echo -n " * Should the installer try to disable the local firewall for you n ow? (y/N) "
fwdisable="" fwdisable=""
while [[ -z $fwdisable ]]; do while [[ -z $fwdisable ]]; do
if [[ -n $autoaccept ]]; then if [[ -n $autoaccept ]]; then
fwdisable="N" fwdisable="N"
else else
read -r fwdisable read -r fwdisable
fi fi
case $fwdisable in case $fwdisable in
[Yy]|[Yy][Ee][Ss]) [Yy]|[Yy][Ee][Ss])
ufw stop >/dev/null 2>&1 ufw stop >/dev/null 2>&1
skipping to change at line 948 skipping to change at line 991
echo "Please change installation directory." echo "Please change installation directory."
echo "Running from here will fail." echo "Running from here will fail."
echo "You are in $currentdir which is a folder that will" echo "You are in $currentdir which is a folder that will"
echo "be moved during installation." echo "be moved during installation."
exit 1 exit 1
;; ;;
esac esac
} }
errorStat() { errorStat() {
local status=$1 local status=$1
local skipOk=$2
if [[ $status != 0 ]]; then if [[ $status != 0 ]]; then
echo "Failed!" echo "Failed!"
[[ -z $exitFail ]] && exit $status if [[ -z $exitFail ]]; then
echo
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!"
echo "!! The installer was not able to run all the way to the end as
!!"
echo "!! something has caused it to fail. The following few lines ar
e !!"
echo "!! from the error log file which might help us figure out what
's !!"
echo "!! wrong. Please add this information when reporting an error.
!!"
echo "!! As well you might want to take a look at the full error log
!!"
echo "!! in $workingdir/error_logs/fog_error_${version}.log !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!"
echo
tail -n 5 $workingdir/error_logs/fog_error_${version}.log
exit $status
fi
fi fi
echo "OK" [[ -z $skipOk ]] && 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 is-active --quiet $serviceItem && systemctl stop $serviceI tem >>$workingdir/error_logs/fog_error_${version}.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 ]] && continue [[ ! -x $initdpath/$serviceItem ]] && continue
$initdpath/$serviceItem status >/dev/null 2>&1 && $initdpath/$servic eItem stop >>$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
skipping to change at line 1075 skipping to change at line 1132
esac esac
fi fi
# if someone still has DB user root set in .fogsettings we want to change th at # if someone still has DB user root set in .fogsettings we want to change th at
[[ "x$snmysqluser" == "xroot" ]] && snmysqluser='fogmaster' [[ "x$snmysqluser" == "xroot" ]] && snmysqluser='fogmaster'
[[ -z $snmysqlpass ]] && snmysqlpass=$(generatePassword 20) [[ -z $snmysqlpass ]] && snmysqlpass=$(generatePassword 20)
[[ -n $snmysqlhost ]] && host="--host=$snmysqlhost" [[ -n $snmysqlhost ]] && host="--host=$snmysqlhost"
sqloptionsroot="${host} --user=root" sqloptionsroot="${host} --user=root"
sqloptionsuser="${host} -s --user=${snmysqluser}" sqloptionsuser="${host} -s --user=${snmysqluser}"
mysqladmin $host ping >/dev/null 2>&1 || mysqladmin $host ping >/dev/null 2> &1 || mysqladmin $host ping >/dev/null 2>&1 mysqladmin $host ping >/dev/null 2>&1 || mysqladmin $host ping >/dev/null 2> &1 || mysqladmin $host ping >/dev/null 2>&1
errorStat $? errorStat $?
dots "Setting up MySQL user and database"
mysql $sqloptionsroot --execute="quit" >/dev/null 2>&1 mysql $sqloptionsroot --execute="quit" >/dev/null 2>&1
if [[ $? -eq 0 ]]; then connect_as_root=$?
if [[ $connect_as_root -eq 0 ]]; then
mysqlrootauth=$(mysql $sqloptionsroot --database=mysql --execute="SELECT Host,User,plugin FROM user WHERE Host='localhost' AND User='root' AND plugin='u nix_socket'") mysqlrootauth=$(mysql $sqloptionsroot --database=mysql --execute="SELECT Host,User,plugin FROM user WHERE Host='localhost' AND User='root' AND plugin='u nix_socket'")
if [[ -z $mysqlrootauth && -z $autoaccept ]]; then if [[ -z $mysqlrootauth && -z $autoaccept ]]; then
echo echo
echo " The installer detected a blank database *root* password. Th is" echo " The installer detected a blank database *root* password. Th is"
echo " is very common on a new install or if you upgrade from any" echo " is very common on a new install or if you upgrade from any"
echo " version of FOG before 1.5.8. To improve overall security we ask" echo " version of FOG before 1.5.8. To improve overall security we ask"
echo " you to supply an appropriate database *root* password now." echo " you to supply an appropriate database *root* password now."
echo echo
echo " NOTICE: Make sure you choose a good password but also one" echo " NOTICE: Make sure you choose a good password but also one"
echo " you can remember or use a password manager to store it." echo " you can remember or use a password manager to store it."
skipping to change at line 1109 skipping to change at line 1169
echo " you save the following password in an appropriate place as" echo " you save the following password in an appropriate place as"
echo " the installer won't store it for you." echo " the installer won't store it for you."
echo echo
echo " Database root password: $snmysqlrootpass" echo " Database root password: $snmysqlrootpass"
echo echo
echo " Press [Enter] to procede..." echo " Press [Enter] to procede..."
read -rs procede read -rs procede
echo echo
echo echo
fi fi
else # WARN: Since MariaDB 10.3 (maybe earlier) setting a password when a
# Obviously this is an auto install with no DB root password paramet uth plugin is
er passed or # set to unix_socket will actually switch to auth plugin mysql_nativ
# a DB setup with authentication method being local unix_socket with e_password
out password. # automatically which was not the case in MariaDB 10.1 and is causin
# Either way we don't care and just set a random password not being g trouble.
used anyway. # So now we try to be more conservative and only reset the pass when
snmysqlrootpass=$(generatePassword 20) we get one
# to make sure the user is in charge of this.
mysqladmin $sqloptionsroot password "${snmysqlrootpass}" >>$workingd
ir/error_logs/fog_error_${version}.log 2>&1
fi fi
mysqladmin $sqloptionsroot password "${snmysqlrootpass}" >>$workingdir/e snmysqlstoragepass=$(mysql -s $sqloptionsroot --password="${snmysqlrootp
rror_logs/fog_error_${version}.log 2>&1 ass}" --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '
snmysqlstoragepass=$(mysql -s $sqloptionsroot --password=${snmysqlrootpa %FOG_STORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
ss} --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%F
OG_STORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
else else
snmysqlstoragepass=$(mysql -s $sqloptionsuser --password=${snmysqlpass} snmysqlstoragepass=$(mysql $sqloptionsuser --password="${snmysqlpass}" -
--execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%FOG_S -execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%FOG_ST
TORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1) ORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
if [[ -z $snmysqlstoragepass && -z $autoaccept ]]; then fi
echo mysql $sqloptionsuser --password="${snmysqlpass}" --execute="quit" >/dev/nul
echo " To improve the overall security the installer will create a l 2>&1
n" connect_as_fogmaster=$?
echo " unpriviledged database user account for FOG's database acce mysql ${host} -s --user=fogstorage --password="${snmysqlstoragepass}" --exec
ss." ute="quit" >/dev/null 2>&1
echo " Please provide the database *root* user password. Be asured connect_as_fogstorage=$?
" if [[ $connect_as_fogmaster -eq 0 && $connect_as_fogstorage -eq 0 ]]; then
echo " that this password will only be used while the FOG installe echo "Skipped"
r" return
echo -n " is running and won't be stored anywhere: " fi
# If we reach this point it's clear that this install is not setup with
# unpriviledged DB users yet and we need to have root DB access now.
if [[ $connect_as_root -ne 0 ]]; then
echo
echo " To improve the overall security the installer will create an"
echo " unpriviledged database user account for FOG's database access."
echo " Please provide the database *root* user password. Be asured"
echo " that this password will only be used while the FOG installer"
echo -n " is running and won't be stored anywhere: "
read -rs snmysqlrootpass
echo
echo
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >
/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo " Unable to connect to the database using the given password!
"
echo -n " Try again: "
read -rs snmysqlrootpass read -rs snmysqlrootpass
echo mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="qui
echo t" >/dev/null 2>&1
mysql $sqloptionsroot --password=${snmysqlrootpass} --execute="quit"
>/dev/null 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo " Unable to connect to the database using the given passw
ord!"
echo -n " Try again: "
read -rs snmysqlrootpass
echo
echo echo
echo " Failed! Terminating installer now."
exit 1
fi fi
snmysqlstoragepass=$(mysql -s $sqloptionsroot --password=${snmysqlro otpass} --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%FOG_STORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
fi fi
fi fi
snmysqlstoragepass=$(mysql -s $sqloptionsroot --password="${snmysqlrootpass}
" --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%FOG
_STORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
# generate a new fogstorage password if it doesn't exist yet or if it's old style fs0123456789 # generate a new fogstorage password if it doesn't exist yet or if it's old style fs0123456789
if [[ -z $snmysqlstoragepass ]]; then if [[ -z $snmysqlstoragepass ]]; then
snmysqlstoragepass=$(generatePassword 20) snmysqlstoragepass=$(generatePassword 20)
elif [[ -n $(echo $snmysqlstoragepass | grep "^fs[0-9][0-9]*$") ]]; then elif [[ -n $(echo $snmysqlstoragepass | grep "^fs[0-9][0-9]*$") ]]; then
snmysqlstoragepass=$(generatePassword 20) snmysqlstoragepass=$(generatePassword 20)
echo echo
echo " The current fogstorage database password does not meet high" echo " The current *fogstorage* database password does not meet high"
echo " security standards. We will generate a new password and update" echo " security standards. We will generate a new password and update"
echo " all the settings on this FOG server for you. Please take note" echo " all the settings on this FOG server for you. Please take note"
echo " of the following credentials that you need to manually update" echo " of the following credentials that you need to manually update"
echo " on all your storage nodes' /opt/fog/.fogsettings configuration" echo " on all your storage nodes' /opt/fog/.fogsettings configuration"
echo " files and re-run (!) the FOG installer:" echo " files and re-run (!) the FOG installer:"
echo " snmysqluser='fogstorage'" echo " snmysqluser='fogstorage'"
echo " snmysqlpass='${snmysqlstoragepass}'" echo " snmysqlpass='${snmysqlstoragepass}'"
echo echo
if [[ -z $autoaccept ]]; then if [[ -z $autoaccept ]]; then
echo " Press [Enter] to proceed after you noted down the credentia ls." echo " Press [Enter] to proceed after you noted down the credentia ls."
read read
fi fi
fi fi
dots "Setting up MySQL user and database" [[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
if [[ -n $snmysqlrootpass ]]; then cat >../tmp/fog-db-and-user-setup.sql <<EOF
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
cat >../tmp/fog-db-and-user-setup.sql <<EOF
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ;
DELETE FROM mysql.user WHERE User='' ; DELETE FROM mysql.user WHERE User='' ;
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0. 1', '::1') ; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0. 1', '::1') ;
DROP DATABASE IF EXISTS test ; DROP DATABASE IF EXISTS test ;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%' ; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%' ;
CREATE DATABASE IF NOT EXISTS $mysqldbname ; CREATE DATABASE IF NOT EXISTS $mysqldbname ;
USE $mysqldbname ; USE $mysqldbname ;
DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ; DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ;
DELIMITER $$ DELIMITER $$
CREATE PROCEDURE $mysqldbname.create_user_if_not_exists() CREATE PROCEDURE $mysqldbname.create_user_if_not_exists()
skipping to change at line 1192 skipping to change at line 1266
END IF ; END IF ;
CREATE USER '${snmysqluser}'@'${snmysqlhost}' IDENTIFIED BY '${snmysqlpass}' ; CREATE USER '${snmysqluser}'@'${snmysqlhost}' IDENTIFIED BY '${snmysqlpass}' ;
GRANT ALL PRIVILEGES ON $mysqldbname.* TO '${snmysqluser}'@'${snmysqlhost}' ; GRANT ALL PRIVILEGES ON $mysqldbname.* TO '${snmysqluser}'@'${snmysqlhost}' ;
SELECT COUNT(*) INTO storageuser FROM mysql.user SELECT COUNT(*) INTO storageuser FROM mysql.user
WHERE User = 'fogstorage' and Host = '%' ; WHERE User = 'fogstorage' and Host = '%' ;
IF storageuser > 0 THEN IF storageuser > 0 THEN
DROP USER 'fogstorage'@'%'; DROP USER 'fogstorage'@'%';
END IF ; END IF ;
CREATE USER 'fogstorage'@'%' IDENTIFIED BY '${snmysqlstoragepass}' ; CREATE USER 'fogstorage'@'%' IDENTIFIED BY '${snmysqlstoragepass}' ;
GRANT SELECT ON $mysqldbname.* TO 'fogstorage'@'%' ;
END ;$$ END ;$$
DELIMITER ; DELIMITER ;
CALL $mysqldbname.create_user_if_not_exists() ; CALL $mysqldbname.create_user_if_not_exists() ;
DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ; DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ;
FLUSH PRIVILEGES ; FLUSH PRIVILEGES ;
SET SQL_MODE=@OLD_SQL_MODE ; SET SQL_MODE=@OLD_SQL_MODE ;
EOF EOF
mysql $sqloptionsroot --password=${snmysqlrootpass} <../tmp/fog-db-and-u mysql $sqloptionsroot --password="${snmysqlrootpass}" <../tmp/fog-db-and-use
ser-setup.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1 r-setup.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
else
echo "Skipped"
fi
} }
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
echo "Skipped" echo "Skipped"
else else
mv -fv "${nfsconfig}" "${nfsconfig}.${timestamp}" >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1
echo -e "$storageLocation *(ro,sync,no_wdelay,no_subtree_check,insecure_ locks,no_root_squash,insecure,fsid=0)\n$storageLocation/dev *(rw,async,no_wdelay ,no_subtree_check,no_root_squash,insecure,fsid=1)" > "$nfsconfig" echo -e "$storageLocation *(ro,sync,no_wdelay,no_subtree_check,insecure_ locks,no_root_squash,insecure,fsid=0)\n$storageLocation/dev *(rw,async,no_wdelay ,no_subtree_check,no_root_squash,insecure,fsid=1)" > "$nfsconfig"
diffconfig "${nfsconfig}"
errorStat $? errorStat $?
dots "Setting up and starting RPCBind" dots "Setting up and starting RPCBind"
if [[ $systemctl == yes ]]; then if [[ $systemctl == yes ]]; then
systemctl enable rpcbind.service >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 systemctl enable rpcbind.service >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1
systemctl stop rpcbind.service >>$workingdir/error_logs/fog_error_${ version}.log 2>&1 systemctl stop rpcbind.service >>$workingdir/error_logs/fog_error_${ version}.log 2>&1
sleep 2 sleep 2
systemctl start rpcbind.service >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1 systemctl start rpcbind.service >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
sleep 2 sleep 2
systemctl status rpcbind.service >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 systemctl status rpcbind.service >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1
else else
skipping to change at line 1765 skipping to change at line 1837
. .
. .
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"
if [[ $(validip $ipaddress) -ne 0 ]]; then
echo -e "\n"
echo " You seem to be using a DNS name instead of an IP address."
echo " This would cause an error when generating SSL key and certs"
echo " and so we will stop here! Please adjust variable 'ipaddress'
"
echo " in .fogsettings file if this is an update and make sure you"
echo " provide an IP address when re-running the installer."
exit 1
fi
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
cat > $sslpath/req.cnf << EOF cat > $sslpath/req.cnf << EOF
[req] [req]
distinguished_name = req_distinguished_name distinguished_name = req_distinguished_name
req_extensions = v3_req req_extensions = v3_req
prompt = yes prompt = yes
[req_distinguished_name] [req_distinguished_name]
CN = $ipaddress CN = $ipaddress
[v3_req] [v3_req]
skipping to change at line 1811 skipping to change at line 1892
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}"
case $novhost in case $novhost in
[Yy]|[Yy][Ee][Ss]) [Yy]|[Yy][Ee][Ss])
echo "Skipped" echo "Skipped"
;; ;;
*) *)
if [[ $recreateCA != yes && $recreateKeys != yes && -f $etcconf ]]; if [[ $osid -eq 2 ]]; then
then a2dissite 001-fog >>$workingdir/error_logs/fog_error_${versi
echo "Skipped" on}.log 2>&1
else a2ensite 000-default >>$workingdir/error_logs/fog_error_${ve
rsion}.log 2>&1
fi
mv -fv "${etcconf}" "${etcconf}.${timestamp}" >>$workingdir/erro
r_logs/fog_error_${version}.log 2>&1
echo "<VirtualHost *:80>" > "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$etcco
nf"
else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\"" >
> "$etcconf"
fi
echo " </FilesMatch>" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$etcconf"
echo " DocumentRoot $docroot" >> "$etcconf"
if [[ $httpproto == https ]]; then if [[ $httpproto == https ]]; then
echo "<VirtualHost *:80>" > "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$e
tcconf"
else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\
"" >> "$etcconf"
fi
echo " </FilesMatch>" >> "$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"
skipping to change at line 1862 skipping to change at line 1946
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"
echo "</VirtualHost>" >> "$etcconf" echo "</VirtualHost>" >> "$etcconf"
else else
echo "<VirtualHost *:80>" > "$etcconf"
echo " <FilesMatch \"\.php\$\">" >> "$etcconf"
if [[ $osid -eq 1 && $OSVersion -lt 7 ]]; then
echo " SetHandler application/x-httpd-php" >> "$e
tcconf"
else
echo " SetHandler \"proxy:fcgi://127.0.0.1:9000/\
"" >> "$etcconf"
fi
echo " </FilesMatch>" >> "$etcconf"
echo " KeepAlive Off" >> "$etcconf" echo " KeepAlive Off" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$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"
echo "</VirtualHost>" >> "$etcconf" echo "</VirtualHost>" >> "$etcconf"
fi fi
diffconfig "${etcconf}"
errorStat $? errorStat $?
ln -s $webdirdest $webdirdest/ >>$workingdir/error_logs/fog_erro r_${version}.log 2>&1 ln -s $webdirdest $webdirdest/ >>$workingdir/error_logs/fog_erro r_${version}.log 2>&1
case $osid in case $osid in
1) 1)
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
skipping to change at line 1919 skipping to change at line 1993
sed -i 's/pm\.start_servers = .*/pm.start_servers = 5/g' $ph pfpmconf >>$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
;; ;;
esac esac
dots "Starting and checking status of web services" dots "Starting and checking status of web services"
case $systemctl in case $systemctl in
yes) yes)
case $osid in case $osid in
2) 2)
systemctl stop apache2 $phpfpm >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 systemctl stop apache2 $phpfpm >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
sleep 2 sleep 2
systemctl start apache2 $phpfpm >>$workingdir/error_logs/fog _error_${version}.log 2>&1 systemctl start apache2 $phpfpm >>$workingdir/error_logs/fog _error_${version}.log 2>&1
skipping to change at line 2003 skipping to change at line 2076
errorStat $? errorStat $?
;; ;;
2) 2)
service apache2 stop >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1 && sleep 2 service apache2 stop >>$workingdir/error_logs/fog_error_${ve rsion}.log 2>&1 && sleep 2
errorStat $? errorStat $?
service php${php_ver}-fpm stop >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 service php${php_ver}-fpm stop >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
;; ;;
esac esac
;; ;;
esac esac
if [[ -f $etcconf ]]; then
case $novhost in
[Yy]|[Yy][Ee][Ss])
;;
*)
dots "Removing vhost file"
if [[ $osid -eq 2 ]]; then
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
fi
rm $etcconf >>$workingdir/error_logs/fog_error_${version}.log 2>
&1
errorStat $?
;;
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!"
skipping to change at line 2248 skipping to change at line 2306
// 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'); define('FOG_THEME', 'default/fog.css');
} }
}" > "${webdirdest}/lib/fog/config.class.php" }" > "${webdirdest}/lib/fog/config.class.php"
errorStat $? errorStat $?
dots "Creating redirection index file"
if [[ ! -f ${docroot}/index.php ]]; then
echo "<?php
header('Location: /fog/index.php');
die();
?>" > ${docroot}/index.php && chown ${apacheuser}:${apacheuser} ${docroot}/index
.php
errorStat $?
else
echo "Skipped"
fi
downloadfiles downloadfiles
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
skipping to change at line 2291 skipping to change at line 2359
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() {
dots "Downloading kernel, init and fog-client binaries" dots "Downloading kernel, init and fog-client binaries"
clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4}' ..
/packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')"
fosURL="https://github.com/FOGProject/fos/releases/download"
fogclientURL="https://github.com/FOGProject/fog-client/releases/download"
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1 [[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
cwd=$(pwd) cwd=$(pwd)
cd ../tmp/ cd ../tmp/
if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]] if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]
then then
urls=( "https://fogproject.org/binaries${version}.zip" ) urls=( "${fosURL}/${version}/init.xz" "${fosURL}/${version}/init_32.xz" "${fosURL}/${version}/bzImage" "${fosURL}/${version}/bzImage32" "${fogclientURL} /${clientVer}/FOGService.msi" "${fogclientURL}/${clientVer}/SmartInstaller.exe" )
if [[ $armsupport == 1 ]]; then if [[ $armsupport == 1 ]]; then
urls+=( "https://fogproject.org/binaries${version}_arm.zip" ) urls+=( "${fosURL}/${version}/arm_init.cpio.gz" "${fosURL}/${version }/arm_Image" )
fi fi
else else
clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4} urls=( "https://fogproject.org/inits/init.xz" "https://fogproject.org/in
' ../packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')" its/init_32.xz" "https://fogproject.org/kernels/bzImage" "https://fogproject.org
urls=( "https://fogproject.org/inits/init.xz" "https://fogproject.org/in /kernels/bzImage32" "${fogclientURL}/${clientVer}/FOGService.msi" "${fogclientUR
its/init_32.xz" "https://fogproject.org/kernels/bzImage" "https://fogproject.org L}/${clientVer}/SmartInstaller.exe" )
/kernels/bzImage32" "https://github.com/FOGProject/fog-client/releases/download/
${clientVer}/FOGService.msi" "https://github.com/FOGProject/fog-client/releases/
download/${clientVer}/SmartInstaller.exe" )
if [[ $armsupport == 1 ]]; then if [[ $armsupport == 1 ]]; then
urls+=( "https://fogproject.org/inits/arm_init.cpio.gz" "https://fog project.org/kernels/arm_Image" ) urls+=( "https://fogproject.org/inits/arm_init.cpio.gz" "https://fog project.org/kernels/arm_Image" )
fi fi
fi fi
for url in "${urls[@]}" for url in "${urls[@]}"
do do
checksum=1 checksum=1
cnt=0 cnt=0
filename=$(basename -- "$url") filename=$(basename -- "$url")
hashfile="${filename}.sha256" hashfile="${filename}.sha256"
skipping to change at line 2338 skipping to change at line 2408
fi fi
let cnt+=1 let cnt+=1
done done
if [[ $checksum -ne 0 ]] if [[ $checksum -ne 0 ]]
then then
echo " * Could not download $filename properly" echo " * Could not download $filename properly"
[[ -z $exitFail ]] && exit 1 [[ -z $exitFail ]] && exit 1
fi fi
done done
echo "Done" echo "Done"
if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]
then
dots "Extracting the binaries archive"
unzip -o binaries${version}.zip >>$workingdir/error_logs/fog_error_${ver
sion}.log 2>&1
errorStat $?
copypath="packages/*/"
if [[ $armsupport == 1 ]]; then
dots "Extracting the ARM binaries archive"
unzip -o binaries${version}_arm.zip >>$workingdir/error_logs/fog_err
or_${version}.log 2>&1
errorStat $?
copypath_arm="packages_arm/*/"
fi
fi
dots "Copying binaries to destination paths" dots "Copying binaries to destination paths"
cp -vf ${copypath}bzImage ${webdirdest}/service/ipxe/ >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath}bzImage ${webdirdest}/service/ipxe/ >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 || errorStat $?
cp -vf ${copypath}bzImage32 ${webdirdest}/service/ipxe/ >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath}bzImage32 ${webdirdest}/service/ipxe/ >>$workingdir/error_ logs/fog_error_${version}.log 2>&1 || errorStat $?
cp -vf ${copypath}init.xz ${webdirdest}/service/ipxe/ >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath}init.xz ${webdirdest}/service/ipxe/ >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 || errorStat $?
cp -vf ${copypath}init_32.xz ${webdirdest}/service/ipxe/ >>$workingdir/error _logs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath}init_32.xz ${webdirdest}/service/ipxe/ >>$workingdir/error _logs/fog_error_${version}.log 2>&1 || errorStat $?
if [[ $armsupport == 1 ]]; then if [[ $armsupport == 1 ]]; then
cp -vf ${copypath_arm}arm_Image ${webdirdest}/service/ipxe/ >>$workingdi r/error_logs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath_arm}arm_Image ${webdirdest}/service/ipxe/ >>$workingdi r/error_logs/fog_error_${version}.log 2>&1 || errorStat $?
cp -vf ${copypath_arm}arm_init.cpio.gz ${webdirdest}/service/ipxe/ >>$wo rkingdir/error_logs/fog_error_${version}.log 2>&1 || errorStat $? cp -vf ${copypath_arm}arm_init.cpio.gz ${webdirdest}/service/ipxe/ >>$wo rkingdir/error_logs/fog_error_${version}.log 2>&1 || errorStat $?
fi fi
cp -vf ${copypath}FOGService.msi ${copypath}SmartInstaller.exe ${webdirdest} /client/ >>$workingdir/error_logs/fog_error_${version}.log 2>&1 cp -vf ${copypath}FOGService.msi ${copypath}SmartInstaller.exe ${webdirdest} /client/ >>$workingdir/error_logs/fog_error_${version}.log 2>&1
skipping to change at line 2380 skipping to change at line 2437
else else
dots "Setting up and starting DHCP Server" dots "Setting up and starting DHCP Server"
fi fi
;; ;;
*) *)
dots "Setting up and starting DHCP Server" dots "Setting up and starting DHCP Server"
;; ;;
esac esac
case $bldhcp in case $bldhcp in
1) 1)
[[ -f $dhcpconfig ]] && cp -f $dhcpconfig ${dhcpconfig}.fogbackup
serverip=$(ip -4 -o addr show $interface | awk -F'([ /])+' '/global/ {print $4}') serverip=$(ip -4 -o addr show $interface | awk -F'([ /])+' '/global/ {print $4}')
[[ -z $serverip ]] && serverip=$(/sbin/ifconfig $interface | grep -o E 'inet[:]? addr[:]?([0-9]{1,3}\.){3}[0-9]{1,3}' | awk -F'(inet[:]? ?addr[:]?)' '{print $2}') [[ -z $serverip ]] && serverip=$(/sbin/ifconfig $interface | grep -o E 'inet[:]? addr[:]?([0-9]{1,3}\.){3}[0-9]{1,3}' | awk -F'(inet[:]? ?addr[:]?)' '{print $2}')
[[ -z $submask ]] && submask=$(cidr2mask $(getCidr $interface)) [[ -z $submask ]] && submask=$(cidr2mask $(getCidr $interface))
network=$(mask2network $serverip $submask) network=$(mask2network $serverip $submask)
[[ -z $startrange ]] && startrange=$(addToAddress $network 10) [[ -z $startrange ]] && startrange=$(addToAddress $network 10)
[[ -z $endrange ]] && endrange=$(subtract1fromAddress $(echo $(inter face2broadcast $interface))) [[ -z $endrange ]] && endrange=$(subtract1fromAddress $(echo $(inter face2broadcast $interface)))
[[ -f $dhcpconfig ]] && dhcptouse=$dhcpconfig [[ -f $dhcpconfig ]] && dhcptouse=$dhcpconfig
[[ -f $dhcpconfigother ]] && dhcptouse=$dhcpconfigother [[ -f $dhcpconfigother ]] && dhcptouse=$dhcpconfigother
if [[ -z $dhcptouse || ! -f $dhcptouse ]]; then if [[ -z $dhcptouse || ! -f $dhcptouse ]]; then
echo "Failed" echo "Failed"
echo "Could not find dhcp config file" echo "Could not find dhcp config file"
exit 1 exit 1
fi fi
mv -fv "${dhcptouse}" "${dhcptouse}.${timestamp}" >>$workingdir/erro r_logs/fog_error_${version}.log 2>&1
[[ -z $bootfilename ]] && bootfilename="undionly.kpxe" [[ -z $bootfilename ]] && bootfilename="undionly.kpxe"
echo "# DHCP Server Configuration file\n#see /usr/share/doc/dhcp*/dh cpd.conf.sample" > $dhcptouse echo "# DHCP Server Configuration file\n#see /usr/share/doc/dhcp*/dh cpd.conf.sample" > $dhcptouse
echo "# This file was created by FOG" >> "$dhcptouse" echo "# This file was created by FOG" >> "$dhcptouse"
echo "#Definition of PXE-specific options" >> "$dhcptouse" echo "#Definition of PXE-specific options" >> "$dhcptouse"
echo "# Code 1: Multicast IP Address of bootfile" >> "$dhcptouse" echo "# Code 1: Multicast IP Address of bootfile" >> "$dhcptouse"
echo "# Code 2: UDP Port that client should monitor for MTFTP Respon ses" >> "$dhcptouse" echo "# Code 2: UDP Port that client should monitor for MTFTP Respon ses" >> "$dhcptouse"
echo "# Code 3: UDP Port that MTFTP servers are using to listen for MTFTP requests" >> "$dhcptouse" echo "# Code 3: UDP Port that MTFTP servers are using to listen for MTFTP requests" >> "$dhcptouse"
echo "# Code 4: Number of seconds a client must listen for activity before trying" >> "$dhcptouse" echo "# Code 4: Number of seconds a client must listen for activity before trying" >> "$dhcptouse"
echo "# to start a new MTFTP transfer" >> "$dhcptouse" echo "# to start a new MTFTP transfer" >> "$dhcptouse"
echo "# Code 5: Number of seconds a client must listen before trying to restart" >> "$dhcptouse" echo "# Code 5: Number of seconds a client must listen before trying to restart" >> "$dhcptouse"
skipping to change at line 2469 skipping to change at line 2526
echo " if (option dhcp-message-type = 8) {" >> "$dhcptouse" echo " if (option dhcp-message-type = 8) {" >> "$dhcptouse"
echo " option vendor-class-identifier \"AAPLBSDPC\";" >> "$dhcptouse" echo " option vendor-class-identifier \"AAPLBSDPC\";" >> "$dhcptouse"
echo " if (substring(option vendor-encapsulated-options, 0, 3) = 01:01:01) {" >> "$dhcptouse" echo " if (substring(option vendor-encapsulated-options, 0, 3) = 01:01:01) {" >> "$dhcptouse"
echo " # BSDP List" >> "$dhcptouse" echo " # BSDP List" >> "$dhcptouse"
echo " option vendor-encapsulated-options 01:01:01:04 :02:80:00:07:04:81:00:05:2a:09:0D:81:00:05:2a:08:69:50:58:45:2d:46:4f:47;" >> "$ dhcptouse" echo " option vendor-encapsulated-options 01:01:01:04 :02:80:00:07:04:81:00:05:2a:09:0D:81:00:05:2a:08:69:50:58:45:2d:46:4f:47;" >> "$ dhcptouse"
echo " filename \"ipxe.efi\";" >> "$dhcptouse" echo " filename \"ipxe.efi\";" >> "$dhcptouse"
echo " }" >> "$dhcptouse" echo " }" >> "$dhcptouse"
echo " }" >> "$dhcptouse" echo " }" >> "$dhcptouse"
echo " }" >> "$dhcptouse" echo " }" >> "$dhcptouse"
echo "}" >> "$dhcptouse" echo "}" >> "$dhcptouse"
diffconfig "${dhcptouse}"
case $systemctl in case $systemctl in
yes) yes)
systemctl enable $dhcpd >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1 systemctl enable $dhcpd >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
systemctl stop $dhcpd >>$workingdir/error_logs/fog_error_${v ersion}.log 2>&1 systemctl stop $dhcpd >>$workingdir/error_logs/fog_error_${v ersion}.log 2>&1
sleep 2 sleep 2
systemctl start $dhcpd >>$workingdir/error_logs/fog_error_${ version}.log 2>&1 systemctl start $dhcpd >>$workingdir/error_logs/fog_error_${ version}.log 2>&1
sleep 2 sleep 2
systemctl status $dhcpd >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1 systemctl status $dhcpd >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
;; ;;
*) *)
skipping to change at line 2556 skipping to change at line 2614
done done
# 9$(date +%N) seems weird but it's important because date may return # 9$(date +%N) seems weird but it's important because date may return
# a leading 0 causing modulo to fail on reading it as octal number # a leading 0 causing modulo to fail on reading it as octal number
position=$(( 9$(date +%N) % $length )) position=$(( 9$(date +%N) % $length ))
# inject the special character at a random position # inject the special character at a random position
echo ${genpassword::($position)}$special${genpassword:($position)} echo ${genpassword::($position)}$special${genpassword:($position)}
} }
checkPasswordChars() { checkPasswordChars() {
echo "$i" | tr -d '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[]^_{|}~' echo "$i" | tr -d '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[]^_{|}~'
} }
diffconfig() {
local conffile="$1"
[[ ! -f "${conffile}.${timestamp}" ]] && return 0
diff -q "${conffile}" "${conffile}.${timestamp}" >>$workingdir/error_logs/fo
g_error_${version}.log 2>&1
if [[ $? -eq 0 ]]; then
rm -f "${conffile}.${timestamp}" >>$workingdir/error_logs/fog_error_${ve
rsion}.log 2>&1
else
backupconfig="${backupconfig} ${conffile}"
fi
}
 End of changes. 54 change blocks. 
146 lines changed or deleted 224 lines changed or added

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