"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/common/functions.sh" between
fogproject-1.5.7.tar.gz and fogproject-1.5.8.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.7):functions.sh  (fogproject-1.5.8)
skipping to change at line 31 skipping to change at line 31
printf " * %s%*.*s" "$1" 0 $((60-${#1})) "$pad" printf " * %s%*.*s" "$1" 0 $((60-${#1})) "$pad"
return 0 return 0
} }
backupReports() { backupReports() {
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() {
dots "Checking connection to master database"
[[ -n $snmysqlhost ]] && host="--host=$snmysqlhost"
sqloptionsuser="${host} -s --user=${snmysqluser}"
mysql $sqloptionsuser --password=${snmysqlpass} --execute="quit" >/dev/null
2>&1
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"
wget --no-check-certificate -qO - $httpproto://$ipaddress/${webroot}/mai ntenance/create_update_node.php --post-data="newNode&name=$(echo -n $ipaddress| base64)&path=$(echo -n $storageLocation|base64)&ftppath=$(echo -n $storageLocati on|base64)&snapinpath=$(echo -n $snapindir|base64)&sslpath=$(echo -n $sslpath|ba se64)&ip=$(echo -n $ipaddress|base64)&maxClients=$(echo -n $maxClients|base64)&u ser=$(echo -n $username|base64)&pass=$(echo -n $password|base64)&interface=$(ech o -n $interface|base64)&bandwidth=$(echo -n $interface|base64)&webroot=$(echo -n $webroot|base64)&fogverified" curl -s -k -X POST -d "newNode" -d "name=$(echo -n $ipaddress|base64)" - d "path=$(echo -n $storageLocation|base64)" -d "ftppath=$(echo -n $storageLocati on|base64)" -d "snapinpath=$(echo -n $snapindir|base64)" -d "sslpath=$(echo -n $ sslpath|base64)" -d "ip=$(echo -n $ipaddress|base64)" -d "maxClients=$(echo -n $ maxClients|base64)" -d "user=$(echo -n $username|base64)" --data-urlencode "pass =$(echo -n $password|base64)" -d "interface=$(echo -n $interface|base64)" -d "ba ndwidth=1" -d "webroot=$(echo -n $webroot|base64)" -d "fogverified" $httpproto:/ /$ipaddress/${webroot}/maintenance/create_update_node.php
echo "Done" echo "Done"
else else
echo " * Node is registered" echo " * Node is registered"
fi fi
} }
updateStorageNodeCredentials() { updateStorageNodeCredentials() {
[[ -z $webroot ]] && webroot="/" [[ -z $webroot ]] && webroot="/"
dots "Ensuring node username and passwords match" dots "Ensuring node username and passwords match"
wget --no-check-certificate -qO - $httpproto://$ipaddress${webroot}maintenan ce/create_update_node.php --post-data="nodePass&ip=$(echo -n $ipaddress|base64)& user=$(echo -n $username|base64)&pass=$(echo -n $password|base64)&fogverified" curl -s -k -X POST -d "nodePass" -d "ip=$(echo -n $ipaddress|base64)" -d "us er=$(echo -n $username|base64)" --data-urlencode "pass=$(echo -n $password|base6 4)" -d "fogverified" $httpproto://$ipaddress${webroot}maintenance/create_update_ node.php
echo "Done" echo "Done"
} }
backupDB() { backupDB() {
dots "Backing up database" dots "Backing up database"
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 $? if [[ $? -ne 0 ]]; then
echo "Failed"
if [[ -z $autoaccept ]]; then
echo
echo " We were not able to backup the current database! Just press
"
echo " [Enter] to proceed anyway or Ctrl+C to stop the installer."
read
fi
else
echo "Done"
fi
} }
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 replace='s/[]"\/$&*.^|[]/\\&/g'
local escstorageLocation=$(echo $storageLocation | sed -e $replace) local escstorageLocation=$(echo $storageLocation | sed -e $replace)
sed -i -e "s/'\/images\/'/'$escstorageLocation'/g" $webdirdest/commo ns/schema.php 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 $?
skipping to change at line 80 skipping to change at line 97
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
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"
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
errorStat $?
dots "Granting access to fogstorage database user"
if [[ -n $snmysqlrootpass ]]; then
[[ ! -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' ;
GRANT INSERT,UPDATE ON $mysqldbname.hosts TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.inventory TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessions TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessionsAssoc TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.nfsGroupMembers TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.tasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskStates TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskLog TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinTasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinJobs TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.imagingLog TO 'fogstorage'@'%' ;
FLUSH PRIVILEGES ;
SET SQL_MODE=@OLD_SQL_MODE ;
EOF
mysql $sqloptionsroot --password=${snmysqlrootpass} <../tmp/fog-db-grant
-fogstorage-access.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1
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 304 skipping to change at line 348
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': ' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")" interfaces="$gatewayif $(ip -4 link | grep -v LOOPBACK | grep UP | awk -F': |@' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")"
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 384 skipping to change at line 428
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
[[ $osid -eq 3 ]] && tcpwrappers="NO" || tcpwrappers="YES" echo -e "max_per_ip=200\nanonymous_enable=NO\nlocal_enable=YES\nwrite_enabl
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_
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
port_20=YES\nxferlog_std_format=YES\nlisten=YES\npam_service_name=vsftpd\nuserli st_enable=NO\n$seccompsand" > "$ftpconfig"
st_enable=NO\ntcp_wrappers=$tcpwrappers\n$seccompsand" > "$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 430 skipping to change at line 473
[[ -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() {
[[ -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 if [[ "x$httpproto" = "xhttps" ]]; then
dots "Compiling iPXE binaries that trust our SSL certificate" dots "Compiling iPXE binaries trusting your SSL certificate"
cd $buildipxesrc cd $buildipxesrc
./buildipxe.sh ${sslpath}CA/.fogCA.pem >>$workingdir/error_logs/fog_erro r_${version}.log 2>&1 ./buildipxe.sh ${sslpath}CA/.fogCA.pem >>$workingdir/error_logs/fog_ipxe -build_${version}.log 2>&1
errorStat $? errorStat $?
cd $workingdir cd $workingdir
fi fi
dots "Setting up and starting TFTP and PXE Servers" dots "Setting up and starting TFTP and PXE Servers"
cd $tftpdirsrc cd $tftpdirsrc
for tftpdir in $(ls -d */); do find -type d -exec mkdir -p /tftpboot/{} \; >>$workingdir/error_logs/fog_err
[[ ! -d $tftpdirdst/$tftpdir ]] && mkdir -p $tftpdirdst/$tftpdir >>$work or_${version}.log 2>&1
ingdir/error_logs/fog_error_${version}.log 2>&1 find -type f -exec cp -Rfv {} $tftpdirdst/{} \; >>$workingdir/error_logs/fog
done _error_${version}.log 2>&1
local findoptions=""
[[ $notpxedefaultfile == true ]] && findoptions="! -name default"
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
find $tftpdirdst -type d -exec chmod 755 {} \; >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 find $tftpdirdst -type d -exec chmod 755 {} \; >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
find $webdirdest -type d -exec chmod 755 {} \; >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 find $webdirdest -type d -exec chmod 755 {} \; >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
find $tftpdirdst ! -type d -exec chmod 655 {} \; >>$workingdir/error_logs/fo g_error_${version}.log 2>&1 find $tftpdirdst ! -type d -exec chmod 655 {} \; >>$workingdir/error_logs/fo g_error_${version}.log 2>&1
configureDefaultiPXEfile configureDefaultiPXEfile
if [[ -f $tftpconfig ]]; then if [[ -f $tftpconfig ]]; then
cp -Rf $tftpconfig ${tftpconfig}.fogbackup >>$workingdir/error_logs/fog_ error_${version}.log 2>&1 cp -Rf $tftpconfig ${tftpconfig}.fogbackup >>$workingdir/error_logs/fog_ error_${version}.log 2>&1
fi fi
skipping to change at line 537 skipping to change at line 576
echo " * @license http://opensource.org/licenses/gpl-3.0 GPLv3" >> "$webdir dest/management/index.php" echo " * @license http://opensource.org/licenses/gpl-3.0 GPLv3" >> "$webdir dest/management/index.php"
echo " * @link https://fogproject.org" >> "$webdirdest/management/index. php" echo " * @link https://fogproject.org" >> "$webdirdest/management/index. php"
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() { addOndrejRepo() {
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 >>$workingdir/error_logs/fog_error_${version}.log 2>&1 DEBIAN_FRONTEND=noninteractive $packageinstaller python-software-properties >>$workingdir/error_logs/fog_error_${version}.log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller software-properties-common >>$workingdir/error_logs/fog_error_${version}.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 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 LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej/${r
8 ]]; then epo} >>$workingdir/error_logs/fog_error_${version}.log 2>&1
# Fix missing universe section for Ubuntu 18.04 LIVE LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej/apa
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y universe > che2 >>$workingdir/error_logs/fog_error_${version}.log 2>&1
>$workingdir/error_logs/fog_error_${version}.log 2>&1
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
/apache2 >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi
return $?
} }
installPackages() { installPackages() {
[[ $installlang -eq 1 ]] && packages="$packages gettext" [[ $installlang -eq 1 ]] && packages="$packages gettext"
packages="$packages unzip" packages="$packages unzip"
dots "Adding repository if needed" dots "Adjusting repository (can take a long time for cleanup)"
case $osid in case $osid in
1) 1)
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/}" packages="${packages// php-mcrypt/}"
case $linuxReleaseName in case $linuxReleaseName in
*[Ff][Ee][Dd][Oo][Rr][Aa]*) *[Ff][Ee][Dd][Oo][Rr][Aa]*)
packages="$packages php-json" packages="$packages php-json"
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
skipping to change at line 585 skipping to change at line 618
$packageinstaller $y >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1 $packageinstaller $y >>$workingdir/error_logs/fog_error_ ${version}.log 2>&1
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 rpm --import "http://rpms.remirepo.net/RPM-GPG-KEY-remi" >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi fi
if [[ -n $repoenable ]]; then if [[ -n $repoenable ]]; then
$repoenable epel >>$workingdir/error_logs/fog_error_${ve if [[ $OSVersion -le 7 ]]; then
rsion}.log 2>&1 || true $repoenable epel >>$workingdir/error_logs/fog_error_
$repoenable remi >>$workingdir/error_logs/fog_error_${ve ${version}.log 2>&1 || true
rsion}.log 2>&1 || true $repoenable remi >>$workingdir/error_logs/fog_error_
$repoenable remi-php72 >>$workingdir/error_logs/fog_erro ${version}.log 2>&1 || true
r_${version}.log 2>&1 || true $repoenable remi-php72 >>$workingdir/error_logs/fog_
error_${version}.log 2>&1 || true
fi
fi fi
;; ;;
esac esac
;; ;;
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}-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 if [[ $OSVersion -gt 17 ]]; then
packages="${packages// libcurl3 / libcurl4 }">>$workingd
ir/error_logs/fog_error_${version}.log 2>&1
fi
if [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]*) &&
$OSVersion -ge 18 ]]; then
# Fix missing universe section for Ubuntu 18.04 LIVE
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-reposito
ry -y universe >>$workingdir/error_logs/fog_error_${version}.log 2>&1
# check to see if we still have packages from deb.sury.o
rg (a.k.a ondrej) installed and try to clean it up
dpkg -l | grep -q "deb\.sury\.org"
if [[ $? -eq 0 ]]; then
# make sure we have ondrej repos enabled to be able
to use ppa-purge
addOndrejRepo
# use ppa-purge to not just remove the repo but also
downgrade packages to Ubuntu original versions
DEBIAN_FRONTEND=noninteractive apt-get install -yq p
pa-purge >>$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
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
DEBIAN_FRONTEND=noninteractive apt-get purge -yq ppa
-purge >>$workingdir/error_logs/fog_error_${version}.log 2>&1
fi
else
addOndrejRepo
fi
;; ;;
*[Dd][Ee][Bb][Ii][Aa][Nn]*) *[Dd][Ee][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 / mariadb }">>$workingdir/e rror_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)
echo $packages | grep -q -v " git" && packages="${packages} git" echo $packages | grep -q -v " git" && packages="${packages} git"
packages="${packages// php-mcrypt/}" packages="${packages// php-mcrypt/}"
;; ;;
skipping to change at line 754 skipping to change at line 810
;; ;;
*) *)
sedisable="" sedisable=""
echo " * Invalid input, please try again!" echo " * Invalid input, please try again!"
;; ;;
esac esac
done done
} }
checkFirewall() { checkFirewall() {
command -v iptables >>$workingdir/error_logs/fog_error_${version}.log 2>&1 command -v iptables >>$workingdir/error_logs/fog_error_${version}.log 2>&1
exitcode=$? iptcmd=$?
[[ $exitcode -ne 0 ]] && return if [[ $iptcmd -eq 0 ]]; then
rulesnum=$(iptables -L -n | wc -l) rulesnum=$(iptables -L -n | wc -l)
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c) policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c)
[[ $rulesnum -eq 8 && $policy -eq 0 ]] && return [[ $rulesnum -ne 8 || $policy -ne 0 ]] && fwrunning=1
fi
command -v firewall-cmd >>$workingdir/error_logs/fog_error_${version}.log 2>
&1
fwcmd=$?
if [[ $fwcmd -eq 0 ]]; then
fwstate=$(firewall-cmd --state 2>&1)
[[ "x$fwstate" == "xrunning" ]] && fwrunning=1
fi
[[ $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 " * Should the installer try to disable the local firewall for you now? (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
ufw disable >/dev/null 2>&1 ufw disable >/dev/null 2>&1
systemctl stop ufw >/dev/null 2>&1 systemctl stop ufw >/dev/null 2>&1
systemctl disable ufw >/dev/null 2>&1 systemctl disable ufw >/dev/null 2>&1
systemctl stop firewalld >/dev/null 2>&1 systemctl stop firewalld >/dev/null 2>&1
systemctl disable firewalld >/dev/null 2>&1 systemctl disable firewalld >/dev/null 2>&1
systemctl stop iptables >/dev/null 2>&1 systemctl stop iptables >/dev/null 2>&1
systemctl disable iptables >/dev/null 2>&1 systemctl disable iptables >/dev/null 2>&1
rulesnum=$(iptables -L -n | wc -l) if [[ $iptcmd -eq 0 ]]; then
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c) rulesnum=$(iptables -L -n | wc -l)
if [[ $rulesnum -ne 8 || $policy -ne 0 ]]; then policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -
c)
[[ $rulesnum -ne 8 || $policy -ne 0 ]] && cannotdisablefw=1
fi
if [[ $fwcmd -eq 0 ]]; then
fwstate=$(firewall-cmd --state 2>&1)
[[ "x$fwstate" == "xrunning" ]] && cannotdisablefw=1
fi
if [[ $cannotdisablefw -eq 1 ]]; then
echo " * We were unable to disable the firewall on your syst em. Read up on how" 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 " * you can disable it manually. Proceeding with the in stallation anyway..."
echo " * Hit ENTER so we know you've read this message." echo " * Hit [Enter] so we know you've read this message."
read read
else else
echo -e " * Firewall disabled - proceeding with installation ...\n" echo -e " * Firewall disabled - proceeding with installation ...\n"
fi fi
;; ;;
[Nn]|[Nn][Oo]|"") [Nn]|[Nn][Oo]|"")
fwdisable="N" fwdisable="N"
echo " * You sure know what you are doing, just keep in mind we told you! :-)" echo " * You sure know what you are doing, just keep in mind we told you! :-)"
if [[ -z $autoaccept ]]; then if [[ -z $autoaccept ]]; then
echo " * Hit ENTER so we know you've read this message." echo " * Hit ENTER so we know you've read this message."
skipping to change at line 966 skipping to change at line 1037
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 '@') 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 '@') [[ -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 && ! -f /var/lib/mysql/ibdata1 ]]; then if [[ $osid -eq 3 && ! -f /var/lib/mysql/ibdata1 ]]; then
mkdir -p /var/lib/mysql >>$workingdir/error_logs/fog_error_${version }.log 2>&1 mkdir -p /var/lib/mysql >>$workingdir/error_logs/fog_error_${version }.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 is-enabled --quiet $dbservice || systemctl enable $dbservice > >$workingdir/error_logs/fog_error_${version}.log 2>&1 systemctl is-enabled --quiet $dbservice || systemctl enable $dbservice > >$workingdir/error_logs/fog_error_${version}.log 2>&1
systemctl is-active --quiet $dbservice || systemctl start $dbservice >>$ systemctl is-active --quiet $dbservice && systemctl stop $dbservice >>$w
workingdir/error_logs/fog_error_${version}.log 2>&1 orkingdir/error_logs/fog_error_${version}.log 2>&1 && sleep 2
systemctl start $dbservice >>$workingdir/error_logs/fog_error_${version}
.log 2>&1
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 start >>$workingdir/error_logs/fog_error_${versio n}.log 2>&1 service mysqld start >>$workingdir/error_logs/fog_error_${versio n}.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 start >>$workingdir/error_logs/fog_error_${version }.log 2>&1 service mysql start >>$workingdir/error_logs/fog_error_${version }.log 2>&1
;; ;;
esac esac
fi fi
options=("-s") # if someone still has DB user root set in .fogsettings we want to change th
[[ -n $snmysqlhost ]] && options=( "${options[@]}" "--host=$snmysqlhost" ) at
[[ -n $snmysqluser ]] && options=( "${options[@]}" "--user=$snmysqluser" ) [[ "x$snmysqluser" == "xroot" ]] && snmysqluser='fogmaster'
[[ -n $snmysqlpass ]] && options=( "${options[@]}" "--password=$snmysqlpass" [[ -z $snmysqlpass ]] && snmysqlpass=$(generatePassword 20)
) [[ -n $snmysqlhost ]] && host="--host=$snmysqlhost"
sqlescsnmysqlpass=$(echo "$snmysqlpass" | sed -e s/\'/\'\'/g) # Replace ev sqloptionsroot="${host} --user=root"
ery ' with '' for full MySQL escaping sqloptionsuser="${host} -s --user=${snmysqluser}"
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE User='root'; mysqladmin $host ping >/dev/null 2>&1 || mysqladmin $host ping >/dev/null 2>
" &1 || mysqladmin $host ping >/dev/null 2>&1
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_${version}.l errorStat $?
og 2>&1 mysql $sqloptionsroot --execute="quit" >/dev/null 2>&1
mysqlver=$(mysql -V | sed -n 's/.*Distrib[ ]\(\([0-9]\([.]\|\)\)*\).*\([-]\ if [[ $? -eq 0 ]]; then
|\)[,].*/\1/p') mysqlrootauth=$(mysql $sqloptionsroot --database=mysql --execute="SELECT
mariadb=$(mysql -V | sed -n 's/.*Distrib[ ].*[-]\(.*\)[,].*/\1/p') Host,User,plugin FROM user WHERE Host='localhost' AND User='root' AND plugin='u
vertocheck="5.7" nix_socket'")
[[ -n $mariadb ]] && vertocheck="10.2" if [[ -z $mysqlrootauth && -z $autoaccept ]]; then
if [[ $systemctl == yes ]]; then echo
systemctl restart $dbservice >>$workingdir/error_logs/fog_error_${versio echo " The installer detected a blank database *root* password. Th
n}.log 2>&1 is"
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 " you to supply an appropriate database *root* password now."
echo
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 " The installer won't store the given password in any place"
echo " and it will be lost right after the installer finishes!"
echo
echo -n " Please enter a new database *root* password to be set: "
read -rs snmysqlrootpass
echo
echo
if [[ -z $snmysqlrootpass ]]; then
snmysqlrootpass=$(generatePassword 20)
echo
echo " We don't accept a blank database *root* password anymor
e and"
echo " will generate a password for you to use. Please make su
re"
echo " you save the following password in an appropriate place
as"
echo " the installer won't store it for you."
echo
echo " Database root password: $snmysqlrootpass"
echo
echo " Press [Enter] to procede..."
read -rs procede
echo
echo
fi
else
# Obviously this is an auto install with no DB root password paramet
er passed or
# a DB setup with authentication method being local unix_socket with
out password.
# Either way we don't care and just set a random password not being
used anyway.
snmysqlrootpass=$(generatePassword 20)
fi
mysqladmin $sqloptionsroot password "${snmysqlrootpass}" >>$workingdir/e
rror_logs/fog_error_${version}.log 2>&1
snmysqlstoragepass=$(mysql -s $sqloptionsroot --password=${snmysqlrootpa
ss} --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%F
OG_STORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
else else
case $osid in snmysqlstoragepass=$(mysql -s $sqloptionsuser --password=${snmysqlpass}
1) --execute="SELECT settingValue FROM globalSettings WHERE settingKey LIKE '%FOG_S
service mysqld restart >>$workingdir/error_logs/fog_error_${vers TORAGENODE_MYSQLPASS%'" $mysqldbname 2>/dev/null | tail -1)
ion}.log 2>&1 if [[ -z $snmysqlstoragepass && -z $autoaccept ]]; then
;; echo
2) echo " To improve the overall security the installer will create a
service mysql restart >>$workingdir/error_logs/fog_error_${versi n"
on}.log 2>&1 echo " unpriviledged database user account for FOG's database acce
;; ss."
esac echo " Please provide the database *root* user password. Be asured
"
echo " that this password will only be used while the FOG installe
r"
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 passw
ord!"
echo -n " Try again: "
read -rs snmysqlrootpass
echo
echo
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
mysqlver=$(echo $mysqlver | awk -F'([.])' '{print $1"."$2}') # generate a new fogstorage password if it doesn't exist yet or if it's old
runTest=$(echo "$mysqlver < $vertocheck" | bc) style fs0123456789
if [[ $runTest -eq 0 ]]; then if [[ -z $snmysqlstoragepass ]]; then
[[ -z $snmysqlhost ]] && snmysqlhost='localhost' snmysqlstoragepass=$(generatePassword 20)
[[ -z $snmysqluser ]] && snmysqluser='root' elif [[ -n $(echo $snmysqlstoragepass | grep "^fs[0-9][0-9]*$") ]]; then
case $snmysqlhost in snmysqlstoragepass=$(generatePassword 20)
127.0.0.1|[Ll][Oo][Cc][Aa][Ll][Hh][Oo][Ss][Tt]) echo
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE echo " The current fogstorage database password does not meet high"
User='root';" echo " security standards. We will generate a new password and update"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_ echo " all the settings on this FOG server for you. Please take note"
${version}.log 2>&1 echo " of the following credentials that you need to manually update"
sql="ALTER USER '$snmysqluser'@'127.0.0.1' IDENTIFIED WITH mysql echo " on all your storage nodes' /opt/fog/.fogsettings configuration"
_native_password BY '$sqlescsnmysqlpass';" echo " files and re-run (!) the FOG installer:"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_ echo " snmysqluser='fogstorage'"
${version}.log 2>&1 echo " snmysqlpass='${snmysqlstoragepass}'"
sql="ALTER USER '$snmysqluser'@'localhost' IDENTIFIED WITH mysql echo
_native_password BY '$sqlescsnmysqlpass';" if [[ -z $autoaccept ]]; then
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_ echo " Press [Enter] to proceed after you noted down the credentia
${version}.log 2>&1 ls."
;; read
*) fi
sql="UPDATE mysql.user SET plugin='mysql_native_password' WHERE fi
User='root';" dots "Setting up MySQL user and database"
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_ if [[ -n $snmysqlrootpass ]]; then
${version}.log 2>&1 [[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
sql="ALTER USER '$snmysqluser'@'$snmysqlhost' IDENTIFIED WITH my cat >../tmp/fog-db-and-user-setup.sql <<EOF
sql_native_password BY '$sqlescsnmysqlpass';" SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ;
mysql "${options}" -e "$sql" >>$workingdir/error_logs/fog_error_ DELETE FROM mysql.user WHERE User='' ;
${version}.log 2>&1 DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.
;; 1', '::1') ;
esac DROP DATABASE IF EXISTS test ;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%' ;
CREATE DATABASE IF NOT EXISTS $mysqldbname ;
USE $mysqldbname ;
DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ;
DELIMITER $$
CREATE PROCEDURE $mysqldbname.create_user_if_not_exists()
BEGIN
DECLARE masteruser BIGINT DEFAULT 0 ;
DECLARE storageuser BIGINT DEFAULT 0 ;
SELECT COUNT(*) INTO masteruser FROM mysql.user
WHERE User = '${snmysqluser}' and Host = '${snmysqlhost}' ;
IF masteruser > 0 THEN
DROP USER '${snmysqluser}'@'${snmysqlhost}';
END IF ;
CREATE USER '${snmysqluser}'@'${snmysqlhost}' IDENTIFIED BY '${snmysqlpass}' ;
GRANT ALL PRIVILEGES ON $mysqldbname.* TO '${snmysqluser}'@'${snmysqlhost}' ;
SELECT COUNT(*) INTO storageuser FROM mysql.user
WHERE User = 'fogstorage' and Host = '%' ;
IF storageuser > 0 THEN
DROP USER 'fogstorage'@'%';
END IF ;
CREATE USER 'fogstorage'@'%' IDENTIFIED BY '${snmysqlstoragepass}' ;
GRANT SELECT ON $mysqldbname.* TO 'fogstorage'@'%' ;
END ;$$
DELIMITER ;
CALL $mysqldbname.create_user_if_not_exists() ;
DROP PROCEDURE IF EXISTS $mysqldbname.create_user_if_not_exists ;
FLUSH PRIVILEGES ;
SET SQL_MODE=@OLD_SQL_MODE ;
EOF
mysql $sqloptionsroot --password=${snmysqlrootpass} <../tmp/fog-db-and-u
ser-setup.sql >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $?
else
echo "Skipped"
fi 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 1164 skipping to change at line 1288
chown -R $username:$apacheuser $snapindir chown -R $username:$apacheuser $snapindir
fi fi
errorStat $? errorStat $?
} }
configureUsers() { configureUsers() {
userexists=0 userexists=0
[[ -z $username || "x$username" = "xfog" ]] && username='fogproject' [[ -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
if [[ ! -f "$fogprogramdir/.fogsettings" ]]; then if [[ ! -f "$fogprogramdir/.fogsettings" && ! -x /home/$username/warnfog account.sh ]]; then
echo "Already exists" echo "Already exists"
echo echo
echo "The account \"$username\" already exists but this seems to be a" 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 "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 "beforehand as it is supposed to be a system account not meant"
echo "to be used to login and work on the machine!" echo "to be used to login and work on the machine!"
echo echo
echo "Please remove the account \"$username\" manually before runnin g" echo "Please remove the account \"$username\" manually before runnin g"
echo "the installer again. Run: userdel $username" echo "the installer again. Run: userdel $username"
echo echo
skipping to change at line 1191 skipping to change at line 1315
echo "The account \"$username\" already exists and has been used to" 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 "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 "use this account for your work as it is supposed to be a"
echo "system account!" echo "system account!"
echo echo
echo "Please remove the account \"$username\" manually before ru nning" echo "Please remove the account \"$username\" manually before ru nning"
echo "the installer again. Run: userdel $username" echo "the installer again. Run: userdel $username"
echo echo
exit 1 exit 1
fi fi
echo "Already setup" echo "Skipped"
fi fi
else 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: #"
skipping to change at line 1243 skipping to change at line 1367
then then
\$z --error --width=480 --text="\$text" --title="\$title" \$z --error --width=480 --text="\$text" --title="\$title"
elif [[ -x "\$x" ]] elif [[ -x "\$x" ]]
then then
echo -e "\$text" | \$x -center -file - echo -e "\$text" | \$x -center -file -
else else
\$n -u critical "\$title" "\$(echo \$text | sed -e 's/ \\n/ /g')" \$n -u critical "\$title" "\$(echo \$text | sed -e 's/ \\n/ /g')"
fi fi
EOF EOF
chmod 755 /home/$username/warnfogaccount.sh chmod 755 /home/$username/warnfogaccount.sh
chown $username:$username /home/$username/warnfogaccount.sh
errorStat $? 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 '"' - e '/TFTP_FTP_PASSWORD/,/);/{print $2}' $webdirdest/lib/fog/config.class.php | gr ep -v "^$") [[ -f $webdirdest/lib/fog/config.class.php ]] && password=$(awk -F '"' - e '/TFTP_FTP_PASSWORD/,/);/{print $2}' $webdirdest/lib/fog/config.class.php | gr ep -v "^$")
fi fi
passcheck=$(echo $password | tr -d '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[\\]^_{|}~' if [[ -n "$(checkPasswordChars)" ]]
)
if [[ -n "$passcheck" ]]
then then
echo "Failed" echo "Failed"
echo "# The fog system account password includes characters we cannot pr operly" 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 "# handle. Please remove the following character(s) from the passwo rd in"
echo "# your .fogsettings file before re-running the installer: $passche ck" echo "# your .fogsettings file before re-running the installer: $passche ck"
exit 1 exit 1
fi fi
cnt=0 cnt=0
ret=999 ret=999
while [[ $ret -ne 0 && $cnt -lt 10 ]] while [[ $ret -ne 0 && $cnt -lt 10 ]]
do do
[[ -z $password || $ret -ne 999 ]] && password=$(tr -cd '0-9a-zA-Z!#$%&( )*+,-./:;<=>?@[\\]^_{|}~' < /dev/urandom | fold -w12 | head -n1) [[ -z $password || $ret -ne 999 ]] && password=$(generatePassword 20)
echo -e "$password\n$password" | passwd $username >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1 echo -e "$password\n$password" | passwd $username >>$workingdir/error_lo gs/fog_error_${version}.log 2>&1
ret=$? ret=$?
let cnt+=1 let cnt+=1
done done
errorStat $ret errorStat $ret
unset cnt unset cnt
unset ret unset ret
} }
linkOptFogDir() { linkOptFogDir() {
if [[ ! -h /var/log/fog ]]; then if [[ ! -h /var/log/fog ]]; then
skipping to change at line 1346 skipping to change at line 1470
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
escsnmysqlhost=$(echo $snmysqlhost | sed -e $replace) escsnmysqlhost=$(echo $snmysqlhost | sed -e $replace)
escmysqldbname=$(echo $mysqldbname | sed -e $replace)
escinstalllang=$(echo $installlang | sed -e $replace) escinstalllang=$(echo $installlang | sed -e $replace)
escstorageLocation=$(echo $storageLocation | sed -e $replace) escstorageLocation=$(echo $storageLocation | sed -e $replace)
escfogupdateloaded=$(echo $fogupdateloaded | sed -e $replace) escfogupdateloaded=$(echo $fogupdateloaded | sed -e $replace)
escusername=$(echo $username | sed -e $replace) escusername=$(echo $username | sed -e $replace)
escdocroot=$(echo $docroot | sed -e $replace) escdocroot=$(echo $docroot | sed -e $replace)
escwebroot=$(echo $webroot | sed -e $replace) escwebroot=$(echo $webroot | sed -e $replace)
esccaCreated=$(echo $caCreated | sed -e $replace) esccaCreated=$(echo $caCreated | sed -e $replace)
eschttpproto=$(echo $httpproto | sed -e $replace) eschttpproto=$(echo $httpproto | sed -e $replace)
escstartrange=$(echo $startrange | sed -e $replace) escstartrange=$(echo $startrange | sed -e $replace)
escendrange=$(echo $endrange | sed -e $replace) escendrange=$(echo $endrange | sed -e $replace)
escbootfilename=$(echo $bootfilename | sed -e $replace) escbootfilename=$(echo $bootfilename | sed -e $replace)
escpackages=$(echo $packages | sed -e $replace) escpackages=$(echo $packages | sed -e $replace)
escnoTftpBuild=$(echo $noTftpBuild | sed -e $replace) escnoTftpBuild=$(echo $noTftpBuild | sed -e $replace)
escnotpxedefaultfile=$(echo $notpxedefaultfile | sed -e $replace)
escsslpath=$(echo $sslpath | sed -e $replace) escsslpath=$(echo $sslpath | sed -e $replace)
escbackupPath=$(echo $backupPath | sed -e $replace) escbackupPath=$(echo $backupPath | sed -e $replace)
escarmsupport=$(echo $sarmsupport | sed -e $replace)
escphp_ver=$(echo $php_ver | sed -e $replace) escphp_ver=$(echo $php_ver | sed -e $replace)
escphp_verAdds=$(echo $php_verAdds | sed -e $replace) escphp_verAdds=$(echo $php_verAdds | sed -e $replace)
escsslprivkey=$(echo $sslprivkey | sed -e $replace) escsslprivkey=$(echo $sslprivkey | sed -e $replace)
[[ -z $copybackold || $copybackold -lt 1 ]] && copybackold=0 [[ -z $copybackold || $copybackold -lt 1 ]] && copybackold=0
if [[ -f $fogprogramdir/.fogsettings ]]; then if [[ -f $fogprogramdir/.fogsettings ]]; then
grep -q "^## Start of FOG Settings" $fogprogramdir/.fogsettings || grep -q "^## Version:.*" $fogprogramdir/.fogsettings grep -q "^## Start of FOG Settings" $fogprogramdir/.fogsettings || grep -q "^## Version:.*" $fogprogramdir/.fogsettings
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
grep -q "^## Version:.*$" $fogprogramdir/.fogsettings && \ grep -q "^## Version:.*$" $fogprogramdir/.fogsettings && \
sed -i "s/^## Version:.*/## Version: $escversion/g" $fogprogramd ir/.fogsettings || \ sed -i "s/^## Version:.*/## Version: $escversion/g" $fogprogramd ir/.fogsettings || \
echo "## Version: $version" >> $fogprogramdir/.fogsettings echo "## Version: $version" >> $fogprogramdir/.fogsettings
skipping to change at line 1429 skipping to change at line 1554
echo "installtype='$installtype'" >> $fogprogramdir/.fogsettings echo "installtype='$installtype'" >> $fogprogramdir/.fogsettings
grep -q "snmysqluser=" $fogprogramdir/.fogsettings && \ grep -q "snmysqluser=" $fogprogramdir/.fogsettings && \
sed -i "s/snmysqluser=.*/snmysqluser='$escsnmysqluser'/g" $fogpr ogramdir/.fogsettings || \ sed -i "s/snmysqluser=.*/snmysqluser='$escsnmysqluser'/g" $fogpr ogramdir/.fogsettings || \
echo "snmysqluser='$snmysqluser'" >> $fogprogramdir/.fogsettings echo "snmysqluser='$snmysqluser'" >> $fogprogramdir/.fogsettings
grep -q "snmysqlpass=" $fogprogramdir/.fogsettings && \ grep -q "snmysqlpass=" $fogprogramdir/.fogsettings && \
sed -i "s/snmysqlpass=.*/snmysqlpass='$sedescsnmysqlpass'/g" $fo gprogramdir/.fogsettings || \ sed -i "s/snmysqlpass=.*/snmysqlpass='$sedescsnmysqlpass'/g" $fo gprogramdir/.fogsettings || \
echo "snmysqlpass='$escsnmysqlpass'" >> $fogprogramdir/.fogsetti ngs echo "snmysqlpass='$escsnmysqlpass'" >> $fogprogramdir/.fogsetti ngs
grep -q "snmysqlhost=" $fogprogramdir/.fogsettings && \ grep -q "snmysqlhost=" $fogprogramdir/.fogsettings && \
sed -i "s/snmysqlhost=.*/snmysqlhost='$escsnmysqlhost'/g" $fogpr ogramdir/.fogsettings || \ sed -i "s/snmysqlhost=.*/snmysqlhost='$escsnmysqlhost'/g" $fogpr ogramdir/.fogsettings || \
echo "snmysqlhost='$snmysqlhost'" >> $fogprogramdir/.fogsettings echo "snmysqlhost='$snmysqlhost'" >> $fogprogramdir/.fogsettings
grep -q "mysqldbname=" $fogprogramdir/.fogsettings && \
sed -i "s/mysqldbname=.*/mysqldbname='$escmysqldbname'/g" $fogpr
ogramdir/.fogsettings || \
echo "mysqldbname='$mysqldbname'" >> $fogprogramdir/.fogsettings
grep -q "installlang=" $fogprogramdir/.fogsettings && \ grep -q "installlang=" $fogprogramdir/.fogsettings && \
sed -i "s/installlang=.*/installlang='$escinstalllang'/g" $fogpr ogramdir/.fogsettings || \ sed -i "s/installlang=.*/installlang='$escinstalllang'/g" $fogpr ogramdir/.fogsettings || \
echo "installlang='$installlang'" >> $fogprogramdir/.fogsettings echo "installlang='$installlang'" >> $fogprogramdir/.fogsettings
grep -q "storageLocation=" $fogprogramdir/.fogsettings && \ grep -q "storageLocation=" $fogprogramdir/.fogsettings && \
sed -i "s/storageLocation=.*/storageLocation='$escstorageLocatio n'/g" $fogprogramdir/.fogsettings || \ sed -i "s/storageLocation=.*/storageLocation='$escstorageLocatio n'/g" $fogprogramdir/.fogsettings || \
echo "storageLocation='$storageLocation'" >> $fogprogramdir/.fog settings echo "storageLocation='$storageLocation'" >> $fogprogramdir/.fog settings
grep -q "fogupdateloaded=" $fogprogramdir/.fogsettings && \ grep -q "fogupdateloaded=" $fogprogramdir/.fogsettings && \
sed -i "s/fogupdateloaded=.*/fogupdateloaded=$escfogupdateloaded /g" $fogprogramdir/.fogsettings || \ sed -i "s/fogupdateloaded=.*/fogupdateloaded=$escfogupdateloaded /g" $fogprogramdir/.fogsettings || \
echo "fogupdateloaded=$fogupdateloaded" >> $fogprogramdir/.fogse ttings echo "fogupdateloaded=$fogupdateloaded" >> $fogprogramdir/.fogse ttings
grep -q "storageftpuser=" $fogprogramdir/.fogsettings && \ grep -q "storageftpuser=" $fogprogramdir/.fogsettings && \
skipping to change at line 1473 skipping to change at line 1601
grep -q "bootfilename=" $fogprogramdir/.fogsettings && \ grep -q "bootfilename=" $fogprogramdir/.fogsettings && \
sed -i "s/bootfilename=.*/bootfilename='$escbootfilename'/g" $fo gprogramdir/.fogsettings || \ sed -i "s/bootfilename=.*/bootfilename='$escbootfilename'/g" $fo gprogramdir/.fogsettings || \
echo "bootfilename='$bootfilename'" >> $fogprogramdir/.fogsettin gs echo "bootfilename='$bootfilename'" >> $fogprogramdir/.fogsettin gs
grep -q "packages=" $fogprogramdir/.fogsettings && \ grep -q "packages=" $fogprogramdir/.fogsettings && \
sed -i "s/packages=.*/packages='$escpackages'/g" $fogprogramdir/ .fogsettings || \ sed -i "s/packages=.*/packages='$escpackages'/g" $fogprogramdir/ .fogsettings || \
echo "packages='$packages'" >> $fogprogramdir/.fogsettings echo "packages='$packages'" >> $fogprogramdir/.fogsettings
grep -q "noTftpBuild=" $fogprogramdir/.fogsettings && \ grep -q "noTftpBuild=" $fogprogramdir/.fogsettings && \
sed -i "s/noTftpBuild=.*/noTftpBuild='$escnoTftpBuild'/g" $fogpr ogramdir/.fogsettings || \ sed -i "s/noTftpBuild=.*/noTftpBuild='$escnoTftpBuild'/g" $fogpr ogramdir/.fogsettings || \
echo "noTftpBuild='$noTftpBuild'" >> $fogprogramdir/.fogsettings echo "noTftpBuild='$noTftpBuild'" >> $fogprogramdir/.fogsettings
grep -q "notpxedefaultfile=" $fogprogramdir/.fogsettings && \ grep -q "notpxedefaultfile=" $fogprogramdir/.fogsettings && \
sed -i "s/notpxedefaultfile=.*/notpxedefaultfile='$notpxedefault sed -i "/notpxedefaultfile=.*$/d" $fogprogramdir/.fogsettings
file'/g" $fogprogramdir/.fogsettings || \
echo "notpxedefaultfile='$escnotpxedefaultfile'" >> $fogprogramd
ir/.fogsettings
grep -q "sslpath=" $fogprogramdir/.fogsettings && \ grep -q "sslpath=" $fogprogramdir/.fogsettings && \
sed -i "s/sslpath=.*/sslpath='$escsslpath'/g" $fogprogramdir/.fo gsettings || \ sed -i "s/sslpath=.*/sslpath='$escsslpath'/g" $fogprogramdir/.fo gsettings || \
echo "sslpath='$sslpath'" >> $fogprogramdir/.fogsettings echo "sslpath='$sslpath'" >> $fogprogramdir/.fogsettings
grep -q "backupPath=" $fogprogramdir/.fogsettings && \ grep -q "backupPath=" $fogprogramdir/.fogsettings && \
sed -i "s/backupPath=.*/backupPath='$esbackupPath'/g" $fogprogra mdir/.fogsettings || \ sed -i "s/backupPath=.*/backupPath='$escbackupPath'/g" $fogprogr amdir/.fogsettings || \
echo "backupPath='$backupPath'" >> $fogprogramdir/.fogsettings echo "backupPath='$backupPath'" >> $fogprogramdir/.fogsettings
grep -q "armsupport=" $fogprogramdir/.fogsettings && \
sed -i "s/armsupport=.*/armsupport='$escarmsupport'/g" $fogprogr
amdir/.fogsettings || \
echo "armsupport='$armsupport'" >> $fogprogramdir/.fogsettings
grep -q "php_ver=" $fogprogramdir/.fogsettings && \ grep -q "php_ver=" $fogprogramdir/.fogsettings && \
sed -i "s/php_ver=.*/php_ver='$php_ver'/g" $fogprogramdir/.fogse ttings || \ sed -i "s/php_ver=.*/php_ver='$php_ver'/g" $fogprogramdir/.fogse ttings || \
echo "php_ver='$php_ver'" >> $fogprogramdir/.fogsettings echo "php_ver='$php_ver'" >> $fogprogramdir/.fogsettings
grep -q "php_verAdds=" $fogprogramdir/.fogsettings && \ grep -q "php_verAdds=" $fogprogramdir/.fogsettings && \
sed -i "s/php_verAdds=.*/php_verAdds='$php_verAdds'/g" $fogprogr amdir/.fogsettings || \ sed -i "s/php_verAdds=.*/php_verAdds='$php_verAdds'/g" $fogprogr amdir/.fogsettings || \
echo "php_verAdds='$php_verAdds'" >> $fogprogramdir/.fogsettings echo "php_verAdds='$php_verAdds'" >> $fogprogramdir/.fogsettings
grep -q "sslprivkey=" $fogprogramdir/.fogsettings && \ grep -q "sslprivkey=" $fogprogramdir/.fogsettings && \
sed -i "s/sslprivkey=.*/sslprivkey='$escsslprivkey'/g" $fogprogr amdir/.fogsettings || \ sed -i "s/sslprivkey=.*/sslprivkey='$escsslprivkey'/g" $fogprogr amdir/.fogsettings || \
echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings
else else
skipping to change at line 1517 skipping to change at line 1647
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"
echo "blexports='$blexports'" >> "$fogprogramdir/.fogsettings" echo "blexports='$blexports'" >> "$fogprogramdir/.fogsettings"
echo "installtype='$installtype'" >> "$fogprogramdir/.fogsettings" echo "installtype='$installtype'" >> "$fogprogramdir/.fogsettings"
echo "snmysqluser='$snmysqluser'" >> "$fogprogramdir/.fogsettings" echo "snmysqluser='$snmysqluser'" >> "$fogprogramdir/.fogsettings"
echo "snmysqlpass='$escsnmysqlpass'" >> "$fogprogramdir/.fogsettings " echo "snmysqlpass='$escsnmysqlpass'" >> "$fogprogramdir/.fogsettings "
echo "snmysqlhost='$snmysqlhost'" >> "$fogprogramdir/.fogsettings" echo "snmysqlhost='$snmysqlhost'" >> "$fogprogramdir/.fogsettings"
echo "mysqldbname='$mysqldbname'" >> "$fogprogramdir/.fogsettings"
echo "installlang='$installlang'" >> "$fogprogramdir/.fogsettings" echo "installlang='$installlang'" >> "$fogprogramdir/.fogsettings"
echo "storageLocation='$storageLocation'" >> "$fogprogramdir/.fogset tings" echo "storageLocation='$storageLocation'" >> "$fogprogramdir/.fogset tings"
echo "fogupdateloaded=1" >> "$fogprogramdir/.fogsettings" echo "fogupdateloaded=1" >> "$fogprogramdir/.fogsettings"
echo "docroot='$docroot'" >> "$fogprogramdir/.fogsettings" echo "docroot='$docroot'" >> "$fogprogramdir/.fogsettings"
echo "webroot='$webroot'" >> "$fogprogramdir/.fogsettings" echo "webroot='$webroot'" >> "$fogprogramdir/.fogsettings"
echo "caCreated='$caCreated'" >> "$fogprogramdir/.fogsettings" echo "caCreated='$caCreated'" >> "$fogprogramdir/.fogsettings"
echo "httpproto='$httpproto'" >> "$fogprogramdir/.fogsettings" echo "httpproto='$httpproto'" >> "$fogprogramdir/.fogsettings"
echo "startrange='$startrange'" >> "$fogprogramdir/.fogsettings" echo "startrange='$startrange'" >> "$fogprogramdir/.fogsettings"
echo "endrange='$endrange'" >> "$fogprogramdir/.fogsettings" echo "endrange='$endrange'" >> "$fogprogramdir/.fogsettings"
echo "bootfilename='$bootfilename'" >> "$fogprogramdir/.fogsettings" echo "bootfilename='$bootfilename'" >> "$fogprogramdir/.fogsettings"
echo "packages='$packages'" >> "$fogprogramdir/.fogsettings" echo "packages='$packages'" >> "$fogprogramdir/.fogsettings"
echo "noTftpBuild='$noTftpBuild'" >> "$fogprogramdir/.fogsettings" echo "noTftpBuild='$noTftpBuild'" >> "$fogprogramdir/.fogsettings"
echo "notpxedefaultfile='$notpxedefaultfile'" >> "$fogprogramdir/.fo gsettings"
echo "sslpath='$sslpath'" >> "$fogprogramdir/.fogsettings" echo "sslpath='$sslpath'" >> "$fogprogramdir/.fogsettings"
echo "backupPath='$backupPath'" >> "$fogprogramdir/.fogsettings" echo "backupPath='$backupPath'" >> "$fogprogramdir/.fogsettings"
echo "armsupport='$armsupport'" >> "$fogprogramdir/.fogsettings"
echo "php_ver='$php_ver'" >> "$fogprogramdir/.fogsettings" echo "php_ver='$php_ver'" >> "$fogprogramdir/.fogsettings"
echo "php_verAdds='$php_verAdds'" >> "$fogprogramdir/.fogsettings" echo "php_verAdds='$php_verAdds'" >> "$fogprogramdir/.fogsettings"
echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings
echo "## End of FOG Settings" >> "$fogprogramdir/.fogsettings" echo "## End of FOG Settings" >> "$fogprogramdir/.fogsettings"
fi fi
else else
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"
skipping to change at line 1564 skipping to change at line 1695
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"
echo "blexports='$blexports'" >> "$fogprogramdir/.fogsettings" echo "blexports='$blexports'" >> "$fogprogramdir/.fogsettings"
echo "installtype='$installtype'" >> "$fogprogramdir/.fogsettings" echo "installtype='$installtype'" >> "$fogprogramdir/.fogsettings"
echo "snmysqluser='$snmysqluser'" >> "$fogprogramdir/.fogsettings" echo "snmysqluser='$snmysqluser'" >> "$fogprogramdir/.fogsettings"
echo "snmysqlpass='$escsnmysqlpass'" >> "$fogprogramdir/.fogsettings" echo "snmysqlpass='$escsnmysqlpass'" >> "$fogprogramdir/.fogsettings"
echo "snmysqlhost='$snmysqlhost'" >> "$fogprogramdir/.fogsettings" echo "snmysqlhost='$snmysqlhost'" >> "$fogprogramdir/.fogsettings"
echo "mysqldbname='$mysqldbname'" >> "$fogprogramdir/.fogsettings"
echo "installlang='$installlang'" >> "$fogprogramdir/.fogsettings" echo "installlang='$installlang'" >> "$fogprogramdir/.fogsettings"
echo "storageLocation='$storageLocation'" >> "$fogprogramdir/.fogsetting s" echo "storageLocation='$storageLocation'" >> "$fogprogramdir/.fogsetting s"
echo "fogupdateloaded=1" >> "$fogprogramdir/.fogsettings" echo "fogupdateloaded=1" >> "$fogprogramdir/.fogsettings"
echo "docroot='$docroot'" >> "$fogprogramdir/.fogsettings" echo "docroot='$docroot'" >> "$fogprogramdir/.fogsettings"
echo "webroot='$webroot'" >> "$fogprogramdir/.fogsettings" echo "webroot='$webroot'" >> "$fogprogramdir/.fogsettings"
echo "caCreated='$caCreated'" >> "$fogprogramdir/.fogsettings" echo "caCreated='$caCreated'" >> "$fogprogramdir/.fogsettings"
echo "httpproto='$httpproto'" >> "$fogprogramdir/.fogsettings" echo "httpproto='$httpproto'" >> "$fogprogramdir/.fogsettings"
echo "startrange='$startrange'" >> "$fogprogramdir/.fogsettings" echo "startrange='$startrange'" >> "$fogprogramdir/.fogsettings"
echo "endrange='$endrange'" >> "$fogprogramdir/.fogsettings" echo "endrange='$endrange'" >> "$fogprogramdir/.fogsettings"
echo "bootfilename='$bootfilename'" >> "$fogprogramdir/.fogsettings" echo "bootfilename='$bootfilename'" >> "$fogprogramdir/.fogsettings"
echo "packages='$packages'" >> "$fogprogramdir/.fogsettings" echo "packages='$packages'" >> "$fogprogramdir/.fogsettings"
echo "noTftpBuild='$noTftpBuild'" >> "$fogprogramdir/.fogsettings" echo "noTftpBuild='$noTftpBuild'" >> "$fogprogramdir/.fogsettings"
echo "notpxedefaultfile='$notpxedefaultfile'" >> "$fogprogramdir/.fogset tings"
echo "sslpath='$sslpath'" >> "$fogprogramdir/.fogsettings" echo "sslpath='$sslpath'" >> "$fogprogramdir/.fogsettings"
echo "backupPath='$backupPath'" >> "$fogprogramdir/.fogsettings" echo "backupPath='$backupPath'" >> "$fogprogramdir/.fogsettings"
echo "armsupport='$armsupport'" >> "$fogprogramdir/.fogsettings"
echo "php_ver='$php_ver'" >> "$fogprogramdir/.fogsettings" echo "php_ver='$php_ver'" >> "$fogprogramdir/.fogsettings"
echo "php_verAdds='$php_verAdds'" >> "$fogprogramdir/.fogsettings" echo "php_verAdds='$php_verAdds'" >> "$fogprogramdir/.fogsettings"
echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings echo "sslprivkey='$sslprivkey'" >> $fogprogramdir/.fogsettings
echo "## End of FOG Settings" >> "$fogprogramdir/.fogsettings" echo "## End of FOG Settings" >> "$fogprogramdir/.fogsettings"
fi fi
} }
displayBanner() { displayBanner() {
echo echo
echo echo
echo " +------------------------------------------+" echo " +------------------------------------------+"
skipping to change at line 1645 skipping to change at line 1777
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]
subjectAltName = @alt_names subjectAltName = @alt_names
[alt_names] [alt_names]
DNS.1 = $ipaddress IP.1 = $ipaddress
DNS.2 = $hostname DNS.1 = $hostname
EOF 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 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
cat > $sslpath/ca.cnf << EOF cat > $sslpath/ca.cnf << EOF
[v3_ca] [v3_ca]
subjectAltName = @alt_names subjectAltName = @alt_names
[alt_names] [alt_names]
DNS.1 = $ipaddress IP.1 = $ipaddress
DNS.2 = $hostname DNS.1 = $hostname
EOF 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 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 $?
skipping to change at line 1718 skipping to change at line 1850
echo " </FilesMatch>" >> "$etcconf" echo " </FilesMatch>" >> "$etcconf"
echo " ServerName $ipaddress" >> "$etcconf" echo " ServerName $ipaddress" >> "$etcconf"
echo " ServerAlias $hostname" >> "$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 " SSLCACertificateFile $webdirdest/management/other/ ca.cert.pem" >> "$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"
skipping to change at line 1994 skipping to change at line 2126
cp -Rf $i ${webdirdest}/management/other/ >>$workingdir/error_logs/fog_e rror_${version}.log 2>&1 cp -Rf $i ${webdirdest}/management/other/ >>$workingdir/error_logs/fog_e rror_${version}.log 2>&1
done done
if [[ $installlang -eq 1 ]]; then if [[ $installlang -eq 1 ]]; then
dots "Creating the language binaries" dots "Creating the language binaries"
langpath="${webdirdest}/management/languages" langpath="${webdirdest}/management/languages"
languagesfound=$(find $langpath -maxdepth 1 -type d -exec basename {} \; | awk -F. '/\./ {print $1}' 2>>$workingdir/error_logs/fog_error_${version}.log) languagesfound=$(find $langpath -maxdepth 1 -type d -exec basename {} \; | awk -F. '/\./ {print $1}' 2>>$workingdir/error_logs/fog_error_${version}.log)
languagemogen "$languagesfound" "$langpath" languagemogen "$languagesfound" "$langpath"
echo "Done" echo "Done"
fi fi
dots "Creating config file" dots "Creating config file"
[[ -z $snmysqlhost ]] && snmysqlhost='localhost'
[[ -z $snmysqluser ]] && snmysqluser='root'
phpescsnmysqlpass="${snmysqlpass//\\/\\\\}"; # Replace every \ with \\ ... phpescsnmysqlpass="${snmysqlpass//\\/\\\\}"; # Replace every \ with \\ ...
phpescsnmysqlpass="${phpescsnmysqlpass//\'/\\\'}" # and then every ' with \' for full PHP escaping phpescsnmysqlpass="${phpescsnmysqlpass//\'/\\\'}" # and then every ' with \' for full PHP escaping
echo "<?php echo "<?php
/** /**
* The main configuration FOG uses. * The main configuration FOG uses.
* *
* PHP Version 5 * PHP Version 5
* *
* Constructs the configuration we need to run FOG. * Constructs the configuration we need to run FOG.
* *
skipping to change at line 2046 skipping to change at line 2176
} }
/** /**
* Defines the database settings for FOG * Defines the database settings for FOG
* *
* @return void * @return void
*/ */
private static function _dbSettings() private static function _dbSettings()
{ {
define('DATABASE_TYPE', 'mysql'); // mysql or oracle define('DATABASE_TYPE', 'mysql'); // mysql or oracle
define('DATABASE_HOST', '$snmysqlhost'); define('DATABASE_HOST', '$snmysqlhost');
define('DATABASE_NAME', 'fog'); define('DATABASE_NAME', '$mysqldbname');
define('DATABASE_USERNAME', '$snmysqluser'); define('DATABASE_USERNAME', '$snmysqluser');
define('DATABASE_PASSWORD', '$phpescsnmysqlpass'); define('DATABASE_PASSWORD', '$phpescsnmysqlpass');
} }
/** /**
* Defines the service settings * Defines the service settings
* *
* @return void * @return void
*/ */
private static function _svcSetting() private static function _svcSetting()
{ {
skipping to change at line 2167 skipping to change at line 2297
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"
[[ ! -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=( "https://fogproject.org/binaries${version}.zip" )
if [[ $armsupport == 1 ]]; then
urls+=( "https://fogproject.org/binaries${version}_arm.zip" )
fi
else else
clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4} ' ../packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')" clientVer="$(awk -F\' /"define\('FOG_CLIENT_VERSION'[,](.*)"/'{print $4} ' ../packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')"
urls=( "https://fogproject.org/inits/init.xz" "https://fogproject.org/in its/init_32.xz" "https://fogproject.org/kernels/bzImage" "https://fogproject.org /kernels/bzImage32" "https://github.com/FOGProject/fog-client/releases/download/ ${clientVer}/FOGService.msi" "https://github.com/FOGProject/fog-client/releases/ download/${clientVer}/SmartInstaller.exe" ) urls=( "https://fogproject.org/inits/init.xz" "https://fogproject.org/in its/init_32.xz" "https://fogproject.org/kernels/bzImage" "https://fogproject.org /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
urls+=( "https://fogproject.org/inits/arm_init.cpio.gz" "https://fog
project.org/kernels/arm_Image" )
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"
baseurl=$(dirname -- "$url") baseurl=$(dirname -- "$url")
hashurl="${baseurl}/${hashfile}" hashurl="${baseurl}/${hashfile}"
# make sure we download the most recent hash file to start with
if [[ -f $hashfile ]]; then
rm -f $hashfile
curl --silent -kOL $hashurl >>$workingdir/error_logs/fog_error_${ver
sion}.log 2>&1
fi
while [[ $checksum -ne 0 && $cnt -lt 10 ]] while [[ $checksum -ne 0 && $cnt -lt 10 ]]
do do
[[ -f $hashfile ]] && sha256sum --check $hashfile >>$workingdir/erro r_logs/fog_error_${version}.log 2>&1 [[ -f $hashfile ]] && sha256sum --check $hashfile >>$workingdir/erro r_logs/fog_error_${version}.log 2>&1
checksum=$? checksum=$?
if [[ $checksum -ne 0 ]] if [[ $checksum -ne 0 ]]
then then
curl --silent -kOL $url >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1 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 curl --silent -kOL $hashurl >>$workingdir/error_logs/fog_error_$ {version}.log 2>&1
fi fi
let cnt+=1 let cnt+=1
skipping to change at line 2203 skipping to change at line 2344
[[ -z $exitFail ]] && exit 1 [[ -z $exitFail ]] && exit 1
fi fi
done done
echo "Done" echo "Done"
if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]] if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]]
then then
dots "Extracting the binaries archive" dots "Extracting the binaries archive"
unzip -o binaries${version}.zip >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1 unzip -o binaries${version}.zip >>$workingdir/error_logs/fog_error_${ver sion}.log 2>&1
errorStat $? errorStat $?
copypath="packages/*/" 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 fi
dots "Copying binaries to destination paths" dots "Copying binaries to destination paths"
cp -vf ${copypath}bzImage* ${copypath}init*.xz ${webdirdest}/service/ipxe/ > cp -vf ${copypath}bzImage ${webdirdest}/service/ipxe/ >>$workingdir/error_lo
>$workingdir/error_logs/fog_error_${version}.log && cp -vf ${copypath}FOGService gs/fog_error_${version}.log 2>&1 || errorStat $?
.msi ${copypath}SmartInstaller.exe ${webdirdest}/client/ >>$workingdir/error_log cp -vf ${copypath}bzImage32 ${webdirdest}/service/ipxe/ >>$workingdir/error_
s/fog_error_${version}.log 2>&1 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_32.xz ${webdirdest}/service/ipxe/ >>$workingdir/error
_logs/fog_error_${version}.log 2>&1 || errorStat $?
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_init.cpio.gz ${webdirdest}/service/ipxe/ >>$wo
rkingdir/error_logs/fog_error_${version}.log 2>&1 || errorStat $?
fi
cp -vf ${copypath}FOGService.msi ${copypath}SmartInstaller.exe ${webdirdest}
/client/ >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $? errorStat $?
cd $cwd 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
skipping to change at line 2380 skipping to change at line 2535
local IFS=$'\n' local IFS=$'\n'
local lang='' local lang=''
for lang in ${languages[@]}; do for lang in ${languages[@]}; do
[[ ! -d "${langpath}/${lang}.UTF-8" ]] && continue [[ ! -d "${langpath}/${lang}.UTF-8" ]] && continue
msgfmt -o \ msgfmt -o \
"${langpath}/${lang}.UTF-8/LC_MESSAGES/messages.mo" \ "${langpath}/${lang}.UTF-8/LC_MESSAGES/messages.mo" \
"${langpath}/${lang}.UTF-8/LC_MESSAGES/messages.po" \ "${langpath}/${lang}.UTF-8/LC_MESSAGES/messages.po" \
>>$workingdir/error_logs/fog_error_${version}.log 2>&1 >>$workingdir/error_logs/fog_error_${version}.log 2>&1
done done
} }
generatePassword() {
local length="$1"
[[ $length -ge 12 && $length -le 128 ]] || length=20
while [[ ${#genpassword} -lt $((length-1)) || -z $special ]]; do
newchar=$(head -c1 /dev/urandom | tr -dc '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[
]^_{|}~')
if [[ -n $(echo $newchar | tr -dc '!#$%&()*+,-./:;<=>?@[]^_{|}~') ]]; th
en
special=${newchar}
elif [[ ${#genpassword} -lt $((length-1)) ]]; then
genpassword=${genpassword}${newchar}
fi
done
# 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
position=$(( 9$(date +%N) % $length ))
# inject the special character at a random position
echo ${genpassword::($position)}$special${genpassword:($position)}
}
checkPasswordChars() {
echo "$i" | tr -d '0-9a-zA-Z!#$%&()*+,-./:;<=>?@[]^_{|}~'
}
 End of changes. 54 change blocks. 
182 lines changed or deleted 372 lines changed or added

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