From 4ff0e1e3922fa308dc6aa10053d5904116c543f2 Mon Sep 17 00:00:00 2001 From: Duncan McCracken Date: Mon, 26 Jun 2017 15:25:07 +1000 Subject: [PATCH] Fixed an issue with binary detection, to prevent errors when yum is detected on Ubuntu Prevented IPv6 Disable (breaks NFS on RHEL/CentOS) Re-designed NetBoot and added ability to edit images --- CHANGELOG.md | 3 + CreateNetSUSInstaller.sh | 1 + LDAPProxy/LDAPProxyInstall.sh | 3 +- NetBoot/netbootInstall.sh | 209 ++++++------ SUS/susInstall.sh | 3 +- base/NetSUSInstaller.sh | 23 +- webadmin/var/www/webadmin/SUS.php | 10 +- webadmin/var/www/webadmin/managenbi.php | 212 +++++++++++++ webadmin/var/www/webadmin/netBoot.php | 123 ++++--- .../var/www/webadmin/scripts/adminHelper.sh | 300 +++++++++--------- .../var/www/webadmin/scripts/nbiproperties.py | 113 +++++++ webadmin/webadminInstall.sh | 3 +- 12 files changed, 662 insertions(+), 341 deletions(-) create mode 100644 webadmin/var/www/webadmin/managenbi.php create mode 100755 webadmin/var/www/webadmin/scripts/nbiproperties.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c631e52..9dae6a5 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,10 @@ * Added validation for SUS Base URL and Branch name(s) with live feedback * Added (missing) option for SUS sync at 9:00 AM * Improved detection of the last SUS sync date and time +* Added proxy configuration to SUS * Added validation for NetBoot Image Name, Subnet and Netmask with live feedback +* Added checks for NetBoot supporting services +* Provisioned for NFS support for NetBoot Images * Updated service controls for TFTP on RHEL/CentOS * Added validation for Hostname, IP Address, Netmask, Gateway and DNS Servers with live feedback * Added functionality to dynamically determine primary network interface, to allow for variations diff --git a/CreateNetSUSInstaller.sh b/CreateNetSUSInstaller.sh index 8cc45f6..8d7affd 100755 --- a/CreateNetSUSInstaller.sh +++ b/CreateNetSUSInstaller.sh @@ -49,6 +49,7 @@ cp -R SUS/var/lib/reposado temp/installer/resources/reposado cp -R webadmin/webadminInstall.sh temp/installer/install-webadmin.sh cp -R webadmin/var/appliance/dialog.sh temp/installer/resources/dialog.sh cp -R webadmin/var/www temp/installer/resources/html +rm -f temp/installer/resources/html/webadmin/scripts/netbootname.py if [ -x "/usr/bin/xattr" ]; then find temp -exec xattr -c {} \; ;fi # Remove OS X extended attributes find temp -name .DS_Store -delete # Clean out .DS_Store files find temp -name .svn | xargs rm -Rf # Clean out SVN garbage diff --git a/LDAPProxy/LDAPProxyInstall.sh b/LDAPProxy/LDAPProxyInstall.sh index be7df26..c8a23e5 100644 --- a/LDAPProxy/LDAPProxyInstall.sh +++ b/LDAPProxy/LDAPProxyInstall.sh @@ -32,8 +32,7 @@ slapd slapd/password1 password netsuslp " | sudo debconf-set-selections apt_install slapd unset DEBIAN_FRONTEND -fi -if [[ $(which yum 2>&-) != "" ]]; then +elif [[ $(which yum 2>&-) != "" ]]; then yum_install openldap-servers yum_install expect fi diff --git a/NetBoot/netbootInstall.sh b/NetBoot/netbootInstall.sh index ef3667d..26a0f7a 100644 --- a/NetBoot/netbootInstall.sh +++ b/NetBoot/netbootInstall.sh @@ -30,10 +30,9 @@ if [[ $(which apt-get 2>&-) != "" ]]; then apt_install tftpd-hpa # apt_install openbsd-inetd apt_install netatalk - #apt_install nfs-kernel-server + apt_install nfs-kernel-server apt_install python-configparser -fi -if [[ $(which yum 2>&-) != "" ]]; then +elif [[ $(which yum 2>&-) != "" ]]; then yum_install avahi yum_install samba yum_install samba-client @@ -56,12 +55,14 @@ if [[ $(which yum 2>&-) != "" ]]; then fi sed -i 's/.*- -tcp -noddp -uamlist uams_dhx.so.*/- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so/' /etc/netatalk/afpd.conf fi - #yum_install nfs-utils + yum_install nfs-utils yum_install vim-common chkconfig messagebus on >> $logFile 2>&1 chkconfig avahi-daemon on >> $logFile 2>&1 + chkconfig rpcbind on >> $logFile 2>&1 service messagebus start >> $logFile 2>&1 service avahi-daemon start >> $logFile 2>&1 + service rpcbind start >> $logFile 2>&1 fi # Prepare the firewall in case it is enabled later @@ -78,14 +79,14 @@ if [[ $(which ufw 2>&-) != "" ]]; then # TFTP ufw allow 69/udp >> $logFile # NFS - #ufw allow 111/tcp >> $logFile - #ufw allow 111/udp >> $logFile - #ufw allow 892/tcp >> $logFile - #ufw allow 892/udp >> $logFile - #ufw allow 2049/tcp >> $logFile - #ufw allow 2049/udp >> $logFile - #ufw allow 32769/udp >> $logFile - #ufw allow 32803/tcp >> $logFile + ufw allow 111/tcp >> $logFile + ufw allow 111/udp >> $logFile + ufw allow 892/tcp >> $logFile + ufw allow 892/udp >> $logFile + ufw allow 2049/tcp >> $logFile + ufw allow 2049/udp >> $logFile + ufw allow 32769/udp >> $logFile + ufw allow 32803/tcp >> $logFile elif [[ $(which firewall-cmd 2>&-) != "" ]]; then # HTTP firewall-cmd --zone=public --add-port=80/tcp >> $logFile 2>&1 @@ -105,22 +106,22 @@ elif [[ $(which firewall-cmd 2>&-) != "" ]]; then firewall-cmd --zone=public --add-port=69/udp >> $logFile 2>&1 firewall-cmd --zone=public --add-port=69/udp --permanent >> $logFile 2>&1 # NFS - #firewall-cmd --zone=public --add-port=111/tcp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=111/tcp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=111/udp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=111/udp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=892/tcp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=892/tcp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=892/udp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=892/udp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=2049/tcp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=2049/tcp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=2049/udp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=2049/udp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=32769/udp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=32769/udp --permanent >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=32803/tcp >> $logFile 2>&1 - #firewall-cmd --zone=public --add-port=32803/tcp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=111/tcp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=111/tcp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=111/udp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=111/udp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=892/tcp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=892/tcp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=892/udp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=892/udp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=2049/tcp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=2049/tcp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=2049/udp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=2049/udp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=32769/udp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=32769/udp --permanent >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=32803/tcp >> $logFile 2>&1 + firewall-cmd --zone=public --add-port=32803/tcp --permanent >> $logFile 2>&1 else # HTTP if iptables -L | grep DROP | grep -v 'tcp dpt:https' | grep -q 'tcp dpt:http' ; then @@ -164,54 +165,54 @@ else iptables -I INPUT -p udp --dport 69 -j ACCEPT fi # NFS - #if iptables -L | grep DROP | grep -q 'tcp dpt:sunrpc' ; then - # iptables -D INPUT -p tcp --dport 111 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:sunrpc' ; then - # iptables -I INPUT -p tcp --dport 111 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'udp dpt:sunrpc' ; then - # iptables -D INPUT -p udp --dport 111 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:sunrpc' ; then - # iptables -I INPUT -p udp --dport 111 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'tcp dpt:892' ; then - # iptables -D INPUT -p tcp --dport 892 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:892' ; then - # iptables -I INPUT -p tcp --dport 892 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'udp dpt:892' ; then - # iptables -D INPUT -p udp --dport 892 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:892' ; then - # iptables -I INPUT -p udp --dport 892 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'tcp dpt:nfs' ; then - # iptables -D INPUT -p tcp --dport 2049 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:nfs' ; then - # iptables -I INPUT -p tcp --dport 2049 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'udp dpt:nfs' ; then - # iptables -D INPUT -p udp --dport 2049 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:nfs' ; then - # iptables -I INPUT -p udp --dport 2049 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'udp dpt:filenet-rpc' ; then - # iptables -D INPUT -p udp --dport 32769 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:filenet-rpc' ; then - # iptables -I INPUT -p udp --dport 32769 -j ACCEPT - #fi - #if iptables -L | grep DROP | grep -q 'tcp dpt:32803' ; then - # iptables -D INPUT -p tcp --dport 32803 -j DROP - #fi - #if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:32803' ; then - # iptables -I INPUT -p tcp --dport 32803 -j ACCEPT - #fi + if iptables -L | grep DROP | grep -q 'tcp dpt:sunrpc' ; then + iptables -D INPUT -p tcp --dport 111 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:sunrpc' ; then + iptables -I INPUT -p tcp --dport 111 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'udp dpt:sunrpc' ; then + iptables -D INPUT -p udp --dport 111 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:sunrpc' ; then + iptables -I INPUT -p udp --dport 111 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'tcp dpt:892' ; then + iptables -D INPUT -p tcp --dport 892 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:892' ; then + iptables -I INPUT -p tcp --dport 892 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'udp dpt:892' ; then + iptables -D INPUT -p udp --dport 892 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:892' ; then + iptables -I INPUT -p udp --dport 892 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'tcp dpt:nfs' ; then + iptables -D INPUT -p tcp --dport 2049 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:nfs' ; then + iptables -I INPUT -p tcp --dport 2049 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'udp dpt:nfs' ; then + iptables -D INPUT -p udp --dport 2049 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:nfs' ; then + iptables -I INPUT -p udp --dport 2049 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'udp dpt:filenet-rpc' ; then + iptables -D INPUT -p udp --dport 32769 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'udp dpt:filenet-rpc' ; then + iptables -I INPUT -p udp --dport 32769 -j ACCEPT + fi + if iptables -L | grep DROP | grep -q 'tcp dpt:32803' ; then + iptables -D INPUT -p tcp --dport 32803 -j DROP + fi + if ! iptables -L | grep ACCEPT | grep -q 'tcp dpt:32803' ; then + iptables -I INPUT -p tcp --dport 32803 -j ACCEPT + fi service iptables save >> $logFile 2>&1 fi @@ -340,34 +341,34 @@ if [ ! -d "/home/afpuser" ]; then fi # Configure nfs -#if [ -f "/etc/default/nfs-kernel-server" ]; then -# sed -i 's/.*RPCMOUNTDOPTS.*/RPCMOUNTDOPTS="--port 892"/' /etc/default/nfs-kernel-server -# touch /etc/modprobe.d/lockd.conf -# sed -i '/^lockd/d' /etc/modules -# echo "lockd" >> /etc/modules -#fi -#if [ -f "/etc/sysconfig/nfs" ]; then -# if grep -q LOCKD_TCPPORT /etc/sysconfig/nfs; then -# sed -i 's/.*LOCKD_TCPPORT.*/LOCKD_TCPPORT=32803/' /etc/sysconfig/nfs -# sed -i 's/.*LOCKD_UDPPORT.*/LOCKD_UDPPORT=32769/' /etc/sysconfig/nfs -# sed -i 's/.*MOUNTD_PORT.*/MOUNTD_PORT=892/' /etc/sysconfig/nfs -# else -# sed -i 's/.*RPCMOUNTDOPTS.*/RPCMOUNTDOPTS="-p 892"/' /etc/sysconfig/nfs -# fi -#fi -#if [ -f "/etc/modprobe.d/lockd.conf" ]; then -# if ! grep -q nlm_tcpport /etc/modprobe.d/lockd.conf; then -# echo "options lockd nlm_tcpport=32803" >> /etc/modprobe.d/lockd.conf -# fi -# sed -i 's/.*nlm_tcpport.*/options lockd nlm_tcpport=32803/' /etc/modprobe.d/lockd.conf -# if ! grep -q nlm_udpport /etc/modprobe.d/lockd.conf; then -# echo "options lockd nlm_udpport=32769" >> /etc/modprobe.d/lockd.conf -# fi -# sed -i 's/.*nlm_udpport.*/options lockd nlm_udpport=32769/' /etc/modprobe.d/lockd.conf -#fi -#sed -i "/NetBootSP0/d" /etc/exports -#echo "/srv/NetBoot/NetBootSP0 *(ro,no_subtree_check,no_root_squash,insecure)" >> "/etc/exports" -#exportfs -a +if [ -f "/etc/default/nfs-kernel-server" ]; then + sed -i 's/.*RPCMOUNTDOPTS.*/RPCMOUNTDOPTS="--port 892"/' /etc/default/nfs-kernel-server + touch /etc/modprobe.d/lockd.conf + sed -i '/^lockd/d' /etc/modules + echo "lockd" >> /etc/modules +fi +if [ -f "/etc/sysconfig/nfs" ]; then + if grep -q LOCKD_TCPPORT /etc/sysconfig/nfs; then + sed -i 's/.*LOCKD_TCPPORT.*/LOCKD_TCPPORT=32803/' /etc/sysconfig/nfs + sed -i 's/.*LOCKD_UDPPORT.*/LOCKD_UDPPORT=32769/' /etc/sysconfig/nfs + sed -i 's/.*MOUNTD_PORT.*/MOUNTD_PORT=892/' /etc/sysconfig/nfs + else + sed -i 's/.*RPCMOUNTDOPTS.*/RPCMOUNTDOPTS="-p 892"/' /etc/sysconfig/nfs + fi +fi +if [ -f "/etc/modprobe.d/lockd.conf" ]; then + if ! grep -q nlm_tcpport /etc/modprobe.d/lockd.conf; then + echo "options lockd nlm_tcpport=32803" >> /etc/modprobe.d/lockd.conf + fi + sed -i 's/.*nlm_tcpport.*/options lockd nlm_tcpport=32803/' /etc/modprobe.d/lockd.conf + if ! grep -q nlm_udpport /etc/modprobe.d/lockd.conf; then + echo "options lockd nlm_udpport=32769" >> /etc/modprobe.d/lockd.conf + fi + sed -i 's/.*nlm_udpport.*/options lockd nlm_udpport=32769/' /etc/modprobe.d/lockd.conf +fi +sed -i "/NetBootSP0/d" /etc/exports +echo "/srv/NetBoot/NetBootSP0 *(ro,no_subtree_check,no_root_squash,insecure)" >> "/etc/exports" +exportfs -a # Configure samba # Change SMB setting for guest access diff --git a/SUS/susInstall.sh b/SUS/susInstall.sh index 3215a3c..c26e400 100644 --- a/SUS/susInstall.sh +++ b/SUS/susInstall.sh @@ -27,8 +27,7 @@ if [[ $(which apt-get 2>&-) != "" ]]; then apt_install libapache2-mod-php apt_install php-xml apt_install curl -fi -if [[ $(which yum 2>&-) != "" ]]; then +elif [[ $(which yum 2>&-) != "" ]]; then yum_install mod_ssl yum_install php yum_install php-xml diff --git a/base/NetSUSInstaller.sh b/base/NetSUSInstaller.sh index 85740a0..2c89d60 100755 --- a/base/NetSUSInstaller.sh +++ b/base/NetSUSInstaller.sh @@ -144,11 +144,11 @@ if grep -q 'net.ipv6.conf.lo.disable_ipv6' /etc/sysctl.conf; then sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.conf sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.conf fi -echo " -# Disable IPv6 -net.ipv6.conf.all.disable_ipv6 = 1 -net.ipv6.conf.default.disable_ipv6 = 1 -" >> /etc/sysctl.conf +#echo " +## Disable IPv6 +#net.ipv6.conf.all.disable_ipv6 = 1 +#net.ipv6.conf.default.disable_ipv6 = 1 +#" >> /etc/sysctl.conf log "" log "The NetSUSLP has been installed." @@ -175,22 +175,21 @@ if [[ $(which update-rc.d 2>&-) != "" ]]; then if [[ $(which systemctl 2>&-) != "" ]]; then update-rc.d smbd disable >> $logFile 2>&1 update-rc.d tftpd-hpa disable >> $logFile 2>&1 - #systemctl disable nfs-server >> $logFile 2>&1 + systemctl disable nfs-server >> $logFile 2>&1 # systemctl disable openbsd-inetd >> $logFile 2>&1 - #service nfs-server stop >> $logFile 2>&1 + service nfs-server stop >> $logFile 2>&1 else echo manual > /etc/init/smbd.override echo manual > /etc/init/tftpd-hpa.override - #update-rc.d nfs-kernel-server disable >> $logFile 2>&1 + update-rc.d nfs-kernel-server disable >> $logFile 2>&1 # update-rc.d openbsd-inetd disable >> $logFile 2>&1 - #service nfs-kernel-server stop >> $logFile 2>&1 + service nfs-kernel-server stop >> $logFile 2>&1 fi log "If you are installing NetSUSLP for the first time, please follow the documentation for setup instructions." -fi -if [[ $(which chkconfig 2>&-) != "" ]]; then +elif [[ $(which chkconfig 2>&-) != "" ]]; then service httpd restart >> $logFile 2>&1 chkconfig tftp off >> $logFile 2>&1 - #chkconfig nfs off > /dev/null 2>&1 + chkconfig nfs off > /dev/null 2>&1 #if [ -f "/etc/sysconfig/xinetd" ]; then # service xinetd restart >> $logFile 2>&1 #fi diff --git a/webadmin/var/www/webadmin/SUS.php b/webadmin/var/www/webadmin/SUS.php index a8320da..b299f82 100644 --- a/webadmin/var/www/webadmin/SUS.php +++ b/webadmin/var/www/webadmin/SUS.php @@ -105,14 +105,14 @@ function enableButton(id, enable) function validateBaseURL() { - var validBaseURL = /^(http|https):\/\/[^ "]+$/.test(document.getElementById("baseurl").value); + var validBaseURL = /^http:\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][\/]|[1-9][0-9]|[1-9][0-9][\/]|1[0-9]{2}|1[0-9]{2}[\/]|2[0-4][0-9]|2[0-4][0-9][\/]|25[0-5]|25[0-5][\/])$|^http:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][\/]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9][\/])$/.test(document.getElementById("baseurl").value); showErr("baseurl", validBaseURL); enableButton("setbaseurl", validBaseURL); } function validateBranch() { - var validBranch = /^[A-Za-z0-9._+\-]{1,256}$/.test(document.getElementById("branchname").value); + var validBranch = /^[A-Za-z0-9._+\-]{1,128}$/.test(document.getElementById("branchname").value); showErr("branchname", validBranch); enableButton("addbranch", validBranch); } @@ -131,7 +131,7 @@ function toggleProxyAuth() function validateProxy() { var validHttpProxy = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/.test(document.getElementById("proxy_host").value) || !document.getElementById('http_proxy').checked; - var validHttpPort = document.getElementById("proxy_port").value != "" && !(parseInt(document.getElementById("proxy_port").value) < 0) && !(parseInt(document.getElementById("proxy_port").value) > 65535) || !document.getElementById('http_proxy').checked; + var validHttpPort = /^\d+$/.test(document.getElementById("proxy_port").value) && document.getElementById("proxy_port").value != "" && !(parseInt(document.getElementById("proxy_port").value) < 0) && !(parseInt(document.getElementById("proxy_port").value) > 65535) || !document.getElementById('http_proxy').checked; var validProxyUser = document.getElementById('http_proxy').checked && document.getElementById("proxy_user").value != "" || !document.getElementById('proxy_auth').checked || document.getElementById('proxy_auth').disabled; var validProxyPass = document.getElementById("proxy_user").value != "" && document.getElementById("proxy_pass").value != "" || !document.getElementById('proxy_auth').checked || document.getElementById('proxy_auth').disabled; showErr("proxy_host", validHttpProxy); @@ -165,7 +165,7 @@ function validateProxy() Base URL for the software update server (e.g. "http://sus.mycompany.corp")
- " onKeyUp="validateBaseURL();" onChange="validateBaseURL();"/> + " onClick="validateBaseURL();" onKeyUp="validateBaseURL();" onChange="validateBaseURL();"/> @@ -284,7 +284,7 @@ function validateProxy()
Port
- +

diff --git a/webadmin/var/www/webadmin/managenbi.php b/webadmin/var/www/webadmin/managenbi.php new file mode 100644 index 0000000..181537c --- /dev/null +++ b/webadmin/var/www/webadmin/managenbi.php @@ -0,0 +1,212 @@ +getSetting("netbootimage"); + $wasrunning = getNetBootStatus(); + if ($image == $curimg && $wasrunning) + { + $nbconf = file_get_contents("/var/appliance/conf/dhcpd.conf"); + $nbsubnets = ""; + foreach($conf->getSubnets() as $key => $value) + { + $nbsubnets .= "subnet ".$value['subnet']." netmask ".$value['netmask']." {\n\tallow unknown-clients;\n}\n\n"; + } + $nbconf = str_replace("##SUBNETS##", $nbsubnets, $nbconf); + suExec("touchconf \"/var/appliance/conf/dhcpd.conf.new\""); + if(file_put_contents("/var/appliance/conf/dhcpd.conf.new", $nbconf) === FALSE) + { + echo "
ERROR: Unable to update dhcpd.conf
"; + + } + suExec("disablenetboot"); + suExec("installdhcpdconf"); + suExec("setnbimages ".$image); + } +} + +if ($image != "") { + $Name = trim(suExec("getNBIproperty ".$image." Name")); + $Description = trim(suExec("getNBIproperty ".$image." Description")); + $Type = trim(suExec("getNBIproperty ".$image." Type")); + $Index = trim(suExec("getNBIproperty ".$image." Index")); + $SupportsDiskless = trim(suExec("getNBIproperty ".$image." SupportsDiskless")); + $imageType = trim(suExec("getNBIproperty ".$image." imageType")); + + if ($Name == "") { + $Name = str_replace(".nbi", "" , $image); + $errorMessage = "WARNING: Unable to read NBImageInfo.plist default values are being used"; + } + if ($Type == "") { $Type = "HTTP"; } + if ($Index == "") { $Index = rand(1, 4095); } + if ($SupportsDiskless == "") { $SupportsDiskless = "False"; } + if ($imageType == "") { $imageType = "netboot"; } +} + +?> + + + +$errorMessage
"; +} +else if ($statusMessage != "") +{ + echo "
$statusMessage
"; +} +?> + +
+
+ +

+ +
+ +
+ + Choose Image + + + +
+ +
+
+ Image Properties +
+ +
+
+
Network Disk
+ This name identifies the image in the Startup Disk preferences pane on client computers + /> +
+ +
+ +
+
Description
+ (Optional) Notes or other information to help you characterize the image + +
+ +
+ +
+
Make available over
+ By default, images are available over HTTP + +
+ +
+ +
+
Image Index
+ 1-4095 indicates a local image unique to this server + /> +
+ +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + +
+
+ + diff --git a/webadmin/var/www/webadmin/netBoot.php b/webadmin/var/www/webadmin/netBoot.php index c14caad..92c3105 100644 --- a/webadmin/var/www/webadmin/netBoot.php +++ b/webadmin/var/www/webadmin/netBoot.php @@ -15,26 +15,20 @@ $netbootimgdir = "/srv/NetBoot/NetBootSP0/"; $subnetcheck = $conf->getSubnets(); -if (isset($_POST['netbootName'])) -{ - $conf->setSetting("netbootname", $_POST['netbootName']); -} - -if ((isset($_POST['enablenetboot']) || isset($_POST['changenetboot'])) && empty($subnetcheck)) +if (isset($_POST['enablenetboot']) && empty($subnetcheck)) { echo "
ERROR: Ensure you added a proper Subnet and Netmask
"; } -if ((isset($_POST['enablenetboot']) || isset($_POST['changenetboot'])) && !isset($_POST['NetBootImage'])) +if (isset($_POST['enablenetboot']) && (!isset($_POST['NetBootImage']) || $_POST['NetBootImage'] == "")) { - echo "
ERROR: Ensure you have uploaded a properly configured NetBoot image
"; + echo "
ERROR: Ensure you have uploaded and selected a properly configured NetBoot image
"; } -if (isset($_POST['NetBootImage'])) +if (isset($_POST['NetBootImage']) && $_POST['NetBootImage'] != "") { $wasrunning = getNetBootStatus(); - $netbootname = $conf->getSetting("netbootname"); $nbi = $_POST['NetBootImage']; if ($nbi != "") { @@ -54,12 +48,12 @@ suExec("disablenetboot"); suExec("installdhcpdconf"); - if ($wasrunning || isset($_POST['enablenetboot']) || isset($_POST['changenetboot'])) { - suExec("setnbimages " . $nbi . " " . $netbootname); + if ($wasrunning || isset($_POST['enablenetboot'])) { + suExec("setnbimages " . $nbi); } $conf->setSetting("netbootimage", $nbi); - if ((isset($_POST['enablenetboot']) || isset($_POST['changenetboot'])) && !getNetBootStatus() && !empty($subnetcheck)) { + if (isset($_POST['enablenetboot']) && !getNetBootStatus() && !empty($subnetcheck)) { echo "
ERROR: Unable to start NetBoot service. Ensure your .nbi directory is properly configured
"; } } @@ -130,16 +124,16 @@ if (!isset($_POST['disablenetboot']) && getNetBootStatus()) { $tftp_running = (trim(suExec("gettftpstatus")) === "true"); - // $nfs_running = (trim(suExec("getnfsstatus")) === "true"); + $nfs_running = (trim(suExec("getnfsstatus")) === "true"); $afp_running = (trim(suExec("getafpstatus")) === "true"); if (!$tftp_running) { echo "
ERROR: TFTP is not running, restart NetBoot
"; } - /* if (!$nfs_running) + if (!$nfs_running) { echo "
ERROR: NFS is not running, restart NetBoot
"; - } */ + } if (!$afp_running) { echo "
WARNING: AFP is not running, diskless will be unavailable
"; @@ -170,13 +164,6 @@ function enableButton(id, enable) document.getElementById(id).disabled = !enable; } -function validateName() -{ - var validName = /^[A-Za-z0-9._ +\-]{1,256}$/.test(document.getElementById("netbootName").value) || document.getElementById("netbootName").value == ""; - showErr("netbootName", validName); - enableButton("changenetboot", validName); -} - function validateSubnet() { var validSubnet = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(document.getElementById("subnet").value); @@ -199,7 +186,7 @@ function validateSubnet()
Enabled @@ -223,54 +210,54 @@ function validateSubnet()

-
+
- NetBoot Image and Name + NetBoot Images
-
-
-
Image
- NetBoot image that computers boot to - onChange="document.getElementById('NetBootImage').value = this.value; javascript:ajaxPost('ajax.php?service=NetBoot', 'NetBootImage='+this.value);"/> + + + + + + - -
- -
- -
-
Name
- (Optional) NetBoot name to appear on receiving boot devices. Defaults to the .nbi folder name - " onKeyUp="validateName();" onChange="validateName();" /> -
-
- - - + $i++; + } + ?> + +
+ +
Netboot Subnet and Netmask @@ -281,14 +268,14 @@ function validateSubnet()
Subnet
One of the subnets must include the IP address of the NetBoot server - getSubnets())) { echo $currentSubnet; } ?>" onKeyUp="validateSubnet();" onChange="validateSubnet();" /> + getSubnets())) { echo $currentSubnet; } ?>" onClick="validateSubnet();" onKeyUp="validateSubnet();" onChange="validateSubnet();" />

Netmask
- getSubnets())) { echo $currentNetmask; } ?>" onKeyUp="validateSubnet();" onChange="validateSubnet();" /> + getSubnets())) { echo $currentNetmask; } ?>" onClick="validateSubnet();" onKeyUp="validateSubnet();" onChange="validateSubnet();" />
@@ -312,7 +299,7 @@ function validateSubnet() "> - Delete + Delete diff --git a/webadmin/var/www/webadmin/scripts/adminHelper.sh b/webadmin/var/www/webadmin/scripts/adminHelper.sh index b26ff3e..f04666e 100644 --- a/webadmin/var/www/webadmin/scripts/adminHelper.sh +++ b/webadmin/var/www/webadmin/scripts/adminHelper.sh @@ -193,8 +193,7 @@ service avahi-daemon restart 2>&- #restartsmb) #if [ "$(which update-rc.d 2>&-)" != '' ]; then # SERVICE=smbd -#fi -#if [ "$(which chkconfig 2>&-)" != '' ]; then +#elif [ "$(which chkconfig 2>&-)" != '' ]; then # SERVICE=smb #fi #service $SERVICE restart 2>&- @@ -208,8 +207,7 @@ if [ "$(which update-rc.d 2>&-)" != '' ]; then else rm -f /etc/init/$SERVICE.override fi -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then SERVICE=smb chkconfig $SERVICE on > /dev/null 2>&1 fi @@ -240,18 +238,13 @@ service $SERVICE start 2>&- #Needs updating if we do multiple NetBoot images setnbimages) nbi=$2 -name=$3 if python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')" >/dev/null 2>&1; then index=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Index']" 2>&-) isinstall=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['IsInstall']" 2>&-) kind=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Kind']" 2>&-) - if [ "$name" = '' ]; then - name=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Name']" 2>&-) - else - python /var/www/html/webadmin/scripts/netbootname.py "$name" "/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist" - fi + name=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Name']" 2>&-) rootpath=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['RootPath']" 2>&-) - #type=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Type']" 2>&-) + type=$(python -c "import plistlib; print plistlib.readPlist('/srv/NetBoot/NetBootSP0/${nbi}/NBImageInfo.plist')['Type']" 2>&-) fi if [ "$index" = '' ]; then index=526 @@ -309,25 +302,24 @@ if [ "$(which update-rc.d 2>&-)" != '' ]; then # update-rc.d smbd enable > /dev/null 2>&1 update-rc.d tftpd-hpa enable > /dev/null 2>&1 # systemctl enable openbsd-inetd > /dev/null 2>&1 - #systemctl enable nfs-server > /dev/null 2>&1 - #service nfs-server start 2>&- + systemctl enable nfs-server > /dev/null 2>&1 + service nfs-server start 2>&- else # rm -f /etc/init/smbd.override rm -f /etc/init/tftpd-hpa.override # update-rc.d openbsd-inetd enable > /dev/null 2>&1 - #update-rc.d nfs-kernel-server enable > /dev/null 2>&1 - #service nfs-kernel-server start 2>&- + update-rc.d nfs-kernel-server enable > /dev/null 2>&1 + service nfs-kernel-server start 2>&- fi update-rc.d netatalk enable > /dev/null 2>&1 # service smbd start 2>&- service tftpd-hpa start 2>&- # service openbsd-inetd start 2>&- cp -f /var/appliance/configurefornetboot /etc/network/if-up.d/configurefornetboot -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then # chkconfig smb on > /dev/null 2>&1 chkconfig tftp on > /dev/null 2>&1 - #chkconfig nfs on > /dev/null 2>&1 + chkconfig nfs on > /dev/null 2>&1 chkconfig netatalk on > /dev/null 2>&1 # service smb start 2>&- if [ "$(which systemctl 2>&-)" != '' ]; then @@ -335,7 +327,7 @@ if [ "$(which chkconfig 2>&-)" != '' ]; then else service xinetd restart 2>&- fi - #service nfs start 2>&- + service nfs start 2>&- cp -f /var/appliance/configurefornetboot /sbin/ifup-local fi service netatalk start 2>&- @@ -345,8 +337,7 @@ service netatalk start 2>&- disableproxy) if [ "$(which update-rc.d 2>&-)" != '' ]; then update-rc.d slapd disable > /dev/null 2>&1 -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then chkconfig slapd off > /dev/null 2>&1 fi service slapd stop 2>&- @@ -355,8 +346,7 @@ service slapd stop 2>&- enableproxy) if [ "$(which update-rc.d 2>&-)" != '' ]; then update-rc.d slapd enable > /dev/null 2>&1 -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then chkconfig slapd on > /dev/null 2>&1 fi service slapd start 2>&- @@ -368,33 +358,32 @@ if [ "$(which update-rc.d 2>&-)" != '' ]; then # update-rc.d smbd disable > /dev/null 2>&1 update-rc.d tftpd-hpa disable > /dev/null 2>&1 # systemctl disable openbsd-inetd > /dev/null 2>&1 - #systemctl disable nfs-server > /dev/null 2>&1 - #service nfs-server stop 2>&- + systemctl disable nfs-server > /dev/null 2>&1 + service nfs-server stop 2>&- else # echo manual > /etc/init/smbd.override echo manual > /etc/init/tftpd-hpa.override # update-rc.d openbsd-inetd disable > /dev/null 2>&1 - #update-rc.d nfs-kernel-server disable > /dev/null 2>&1 - #service nfs-kernel-server stop 2>&- + update-rc.d nfs-kernel-server disable > /dev/null 2>&1 + service nfs-kernel-server stop 2>&- fi update-rc.d netatalk disable > /dev/null 2>&1 # service smbd stop 2>&- service tftpd-hpa stop 2>&- # service openbsd-inetd stop 2>&- rm -f /etc/network/if-up.d/configurefornetboot -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then chkconfig netatalk off > /dev/null 2>&1 # chkconfig smb off > /dev/null 2>&1 chkconfig tftp off > /dev/null 2>&1 - #chkconfig nfs off > /dev/null 2>&1 + chkconfig nfs off > /dev/null 2>&1 # service smb stop 2>&- if [ "$(which systemctl 2>&-)" != '' ]; then service tftp stop 2>&- else service xinetd restart 2>&- fi - #service nfs stop 2>&- + service nfs stop 2>&- rm -f /sbin/ifup-local fi service netatalk stop 2>&- @@ -631,71 +620,71 @@ crontab /tmp/mycron rm /tmp/mycron ;; -#JSScreateConf) +JSScreateConf) # $2: JSS URL # $3: Allow untrusted SSL certificate -#logFile="/usr/local/jds/logs/jdsinstaller.log" -#if [ "$3" = 'True' ]; then -# result=$(/usr/local/sbin/jamfds createConf -k -url $2 2>&1) -#else -# result=$(/usr/local/sbin/jamfds createConf -url $2 2>&1) -#fi -#if [ $? -ne 0 ]; then -# echo "$result" | sed -e 's/^error: //' -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Failed to create configuration file" >> $logFile -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Check /usr/local/jds/logs/jamf.log for more information" >> $logFile -#else -# echo "Created configuration file for $2" -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Created configuration file for $2" >> $logFile -#fi -#;; +logFile="/usr/local/jds/logs/jdsinstaller.log" +if [ "$3" = 'True' ]; then + result=$(/usr/local/sbin/jamfds createConf -k -url $2 2>&1) +else + result=$(/usr/local/sbin/jamfds createConf -url $2 2>&1) +fi +if [ $? -ne 0 ]; then + echo "$result" | sed -e 's/^error: //' + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Failed to create configuration file" >> $logFile + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Check /usr/local/jds/logs/jamf.log for more information" >> $logFile +else + echo "Created configuration file for $2" + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Created configuration file for $2" >> $logFile +fi +;; -#JSSenroll) -#logFile="/usr/local/jds/logs/jdsinstaller.log" -#if [ -d "/etc/apache2/sites-enabled" ]; then -# conf="/etc/apache2/sites-enabled/jds.conf" -# www_service=apache2 -#fi -#if [ -d "/etc/httpd/conf.d" ]; then -# conf="/etc/httpd/conf.d/jds.conf" -# www_service=httpd -#fi -#echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Configuring site..." >> $logFile -#echo "" > $conf -#echo " SSLEngine on" >> $conf -#echo "" >> $conf -#echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Writing API RewriteRule..." >> $logFile -#sed -i 's##\n\tRewriteEngine on\n\tRewriteRule ^/jds/api/([0-9a-z/]*)$ /jds/api.php?call=$2 [QSA,NC]#' $conf -#if [ -f "/etc/apache2/sites-enabled/jds.conf" ]; then -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Disabling Indexes on API..." >> $logFile -# sed -i 's##\n\t\n\t\tSSLVerifyClient require\n\t\tOptions None\n\t\tAllowOverride None\n\t#' $conf -#fi -#if [ -f "/etc/httpd/conf.d/jds.conf" ]; then -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Disabling Indexes on API..." >> $logFile -# sed -i 's##\n\t\n\t\tSSLVerifyClient require\n\t\tOptions None\n\t\tAllowOverride None\n\t#' $conf -#fi -#result=$(/usr/local/sbin/jamfds enroll -uri $2 -u $3 -p $4 2>&1) -#if [ $? -ne 0 ]; then -# echo "$result" | sed -e 's/^error: //' -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Failed to enroll" >> $logFile -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Check /usr/local/jds/logs/jamf.log for more information" >> $logFile -# rm -f $conf -# exit -#else -# echo "Enrolment complete" -# echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Enrolment complete" >> $logFile -# /usr/local/sbin/jamfds policy > /dev/null 2>&1 -#fi -#service $www_service reload 2>&- -#;; +JSSenroll) +logFile="/usr/local/jds/logs/jdsinstaller.log" +if [ -d "/etc/apache2/sites-enabled" ]; then + conf="/etc/apache2/sites-enabled/jds.conf" + www_service=apache2 +fi +if [ -d "/etc/httpd/conf.d" ]; then + conf="/etc/httpd/conf.d/jds.conf" + www_service=httpd +fi +echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Configuring site..." >> $logFile +echo "" > $conf +echo " SSLEngine on" >> $conf +echo "" >> $conf +echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Writing API RewriteRule..." >> $logFile +sed -i 's##\n\tRewriteEngine on\n\tRewriteRule ^/jds/api/([0-9a-z/]*)$ /jds/api.php?call=$2 [QSA,NC]#' $conf +if [ -f "/etc/apache2/sites-enabled/jds.conf" ]; then + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Disabling Indexes on API..." >> $logFile + sed -i 's##\n\t\n\t\tSSLVerifyClient require\n\t\tOptions None\n\t\tAllowOverride None\n\t#' $conf +fi +if [ -f "/etc/httpd/conf.d/jds.conf" ]; then + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Disabling Indexes on API..." >> $logFile + sed -i 's##\n\t\n\t\tSSLVerifyClient require\n\t\tOptions None\n\t\tAllowOverride None\n\t#' $conf +fi +result=$(/usr/local/sbin/jamfds enroll -uri $2 -u $3 -p $4 2>&1) +if [ $? -ne 0 ]; then + echo "$result" | sed -e 's/^error: //' + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Failed to enroll" >> $logFile + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Check /usr/local/jds/logs/jamf.log for more information" >> $logFile + rm -f $conf + exit +else + echo "Enrolment complete" + echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Enrolment complete" >> $logFile + /usr/local/sbin/jamfds policy > /dev/null 2>&1 +fi +service $www_service reload 2>&- +;; -#checkin) -#/usr/local/sbin/jamfds policy > /dev/null 2>&1 -#;; +checkin) +/usr/local/sbin/jamfds policy > /dev/null 2>&1 +;; -#JSSinventory) -#/usr/local/sbin/jamfds inventory > /dev/null 2>&1 -#;; +JSSinventory) +/usr/local/sbin/jamfds inventory > /dev/null 2>&1 +;; #enableAvahi) #if [ "$(which apt-get 2>&-)" != '' ]; then @@ -708,8 +697,7 @@ rm /tmp/mycron # else # rm -f /etc/init/avahi-daemon.override # fi -#fi -#if [ "$(which yum 2>&-)" != '' ]]; then +#elif [ "$(which yum 2>&-)" != '' ]]; then # chkconfig messagebus on > /dev/null 2>&1 # service messagebus start 2>&- # chkconfig avahi-daemon on > /dev/null 2>&1 @@ -741,8 +729,7 @@ if [ "$(which apt-get 2>&-)" != '' ]; then else rm -f /etc/init/$SERVICE.override fi -fi -if [ "$(which yum 2>&-)" != '' ]]; then +elif [ "$(which yum 2>&-)" != '' ]]; then SERVICE=sshd if [ "$(rpm -qa openssh-server)" = '' ]; then yum install openssh-server -y -q @@ -760,8 +747,7 @@ if [ "$(which update-rc.d 2>&-)" != '' ]; then else echo manual > /etc/init/$SERVICE.override fi -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then SERVICE=sshd chkconfig $SERVICE off > /dev/null 2>&1 fi @@ -820,8 +806,7 @@ fi enableFirewall) if [ "$(which ufw 2>&-)" != '' ]; then ufw --force enable -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then if [ "$(which firewalld 2>&-)" != '' ]; then chkconfig firewalld on > /dev/null 2>&1 service firewalld start 2>&- @@ -835,8 +820,7 @@ fi disableFirewall) if [ "$(which ufw 2>&-)" != '' ]; then ufw disable -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then if [ "$(which firewalld 2>&-)" != '' ]; then chkconfig firewalld off > /dev/null 2>&1 service firewalld stop 2>&- @@ -896,6 +880,67 @@ if [ "$5" != '' ]; then fi ;; +# NetBoot +getNBIproperty) +# $2: NBI +# $3: Property +plistfile=$(ls "/srv/NetBoot/NetBootSP0/${2}/"*.plist 2>/dev/null) +if [ "$plistfile" != '' ]; then + value=$(python -c "import plistlib; print plistlib.readPlist('${plistfile}')['${3}']" 2>/dev/null) +fi +echo "${value}" +;; + +setNBIproperties) +Image=$2 +Name="$(echo $3 | sed -e 's/\\//g')" +Description="$(echo $4 | sed -e 's/\\//g')" +Type=$5 +Index=$6 +SupportsDiskless=$7 +if [ -f "/srv/NetBoot/NetBootSP0/${Image}/"*.dmg ]; then + RootPath=$(basename "/srv/NetBoot/NetBootSP0/${Image}/"*.dmg) +elif [ -f "/srv/NetBoot/NetBootSP0/${Image}/"*.sparseimage ]; then + RootPath=$(basename "/srv/NetBoot/NetBootSP0/${Image}/"*.sparseimage) +else + exit 1 +fi +python /var/www/html/webadmin/scripts/nbiproperties.py "/srv/NetBoot/NetBootSP0/${Image}/NBImageInfo.plist" "$RootPath" "$Name" "$Description" $Type $Index $SupportsDiskless +;; + +gettftpstatus) +if [ "$(which update-rc.d 2>&-)" != '' ]; then + if service tftpd-hpa status 2>/dev/null | grep -q running ; then + echo "true" + else + echo "false" + fi +elif [ "$(which chkconfig 2>&-)" != '' ]; then + if [ "$(which systemctl 2>&-)" != '' ]; then + if systemctl status tftp | grep -q running ; then + echo "true" + else + echo "false" + fi + else + if service xinetd status | grep -q running && chkconfig | sed 's/[ \t]//g' | grep tftp | grep -q ':on' ; then + echo "true" + else + echo "false" + fi + fi +fi +;; + +getnfsstatus) +SERVICE=nfsd +if ps acx | grep -v grep | grep -q $SERVICE ; then + echo "true" +else + echo "false" +fi +;; + # Certificates createCsr) common_name=$2 @@ -1005,11 +1050,11 @@ echo "A restart is required for changes to take effect" # Logs displayLogList) -jdsLogList=$(find /usr/local/jds/logs -type f -exec file {} \; 2>/dev/null | grep 'ASCII text' | awk -F : '{print $1}' | sort) -jssLogList=$(find /usr/local/jss/logs -type f -exec file {} \; 2>/dev/null | grep 'ASCII text' | awk -F : '{print $1}' | sort) -tomcatLogList=$(find /usr/local/jss/tomcat/logs -type f -exec file {} \; 2>/dev/null | grep 'ASCII text' | awk -F : '{print $1}' | sort) -applianceLogList=$(find /var/appliance/logs -type f -exec file {} \; 2>/dev/null | grep 'ASCII text' | awk -F : '{print $1}' | sort) -varLogList=$(find /var/log \( \! -path /var/log/sudo-io/* \) -a -type f -exec file {} \; 2>/dev/null | grep 'ASCII text' | awk -F : '{print $1}' | sort) +jdsLogList=$(find /usr/local/jds/logs -type f -exec file {} \; 2>/dev/null | grep '\(ASCII\|Unicode\) text' | awk -F : '{print $1}' | sort) +jssLogList=$(find /usr/local/jss/logs -type f -exec file {} \; 2>/dev/null | grep '\(ASCII\|Unicode\) text' | awk -F : '{print $1}' | sort) +tomcatLogList=$(find /usr/local/jss/tomcat/logs -type f -exec file {} \; 2>/dev/null | grep '\(ASCII\|Unicode\) text' | awk -F : '{print $1}' | sort) +applianceLogList=$(find /var/appliance/logs -type f -exec file {} \; 2>/dev/null | grep '\(ASCII\|Unicode\) text' | awk -F : '{print $1}' | sort) +varLogList=$(find /var/log \( \! -path /var/log/sudo-io/* \) -a -type f -exec file {} \; 2>/dev/null | grep '\(ASCII\|Unicode\) text' | awk -F : '{print $1}' | sort) echo $jdsLogList $jssLogList $tomcatLogList $applianceLogList $varLogList ;; @@ -1064,8 +1109,7 @@ if [ "$(which update-rc.d 2>&-)" != '' ]; then else echo manual > /etc/init/$SERVICE.override fi -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then SERVICE=smb chkconfig $SERVICE off > /dev/null 2>&1 fi @@ -1085,8 +1129,7 @@ startafp) SERVICE=netatalk if [ "$(which update-rc.d 2>&-)" != '' ]; then update-rc.d $SERVICE enable > /dev/null 2>&1 -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then chkconfig $SERVICE on > /dev/null 2>&1 fi service $SERVICE start 2>&- @@ -1096,8 +1139,7 @@ stopafp) SERVICE=netatalk if [ "$(which update-rc.d 2>&-)" != '' ]; then update-rc.d $SERVICE disable > /dev/null 2>&1 -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then +elif [ "$(which chkconfig 2>&-)" != '' ]; then chkconfig $SERVICE off > /dev/null 2>&1 fi service $SERVICE stop 2>&- @@ -1139,38 +1181,4 @@ elif [ "$(which yum 2>&-)" != '' ]; then fi ;; -gettftpstatus) -if [ "$(which update-rc.d 2>&-)" != '' ]; then - if service tftpd-hpa status 2>/dev/null | grep -q running ; then - echo "true" - else - echo "false" - fi -fi -if [ "$(which chkconfig 2>&-)" != '' ]; then - if [ "$(which systemctl 2>&-)" != '' ]; then - if systemctl status tftp | grep -q running ; then - echo "true" - else - echo "false" - fi - else - if service xinetd status | grep -q running && chkconfig | sed 's/[ \t]//g' | grep tftp | grep -q ':on' ; then - echo "true" - else - echo "false" - fi - fi -fi -;; - -#getnfsstatus) -#SERVICE=nfsd -#if ps acx | grep -v grep | grep -q $SERVICE ; then -# echo "true" -#else -# echo "false" -#fi -#;; - esac \ No newline at end of file diff --git a/webadmin/var/www/webadmin/scripts/nbiproperties.py b/webadmin/var/www/webadmin/scripts/nbiproperties.py new file mode 100755 index 0000000..798d5e1 --- /dev/null +++ b/webadmin/var/www/webadmin/scripts/nbiproperties.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +import sys, plistlib + +try: + RootPath = sys.argv[2] +except: + RootPath = 'NetBoot.dmg' +try: + Name = sys.argv[3] +except: + Name = 'Faux NetBoot' +try: + Description = sys.argv[4] +except: + Description = '' +try: + Type = sys.argv[5] +except: + Type = 'HTTP' +try: + Index = int(sys.argv[6]) +except: + Index = 526 +try: + SupportsDiskless = sys.argv[7] == 'True' +except: + SupportsDiskless = False + +try: + p = plistlib.readPlist(sys.argv[1]) +except: + p = {} +try: + p['Architectures'] +except: + p['Architectures'] = ['i386'] +try: + p['BackwardCompatible'] +except: + p['BackwardCompatible'] = False +try: + p['BootFile'] +except: + p['BootFile'] = 'booter' +try: + p['Description'] +except: + p['Description'] = '' +try: + p['DisabledSystemIdentifiers'] +except: + p['DisabledSystemIdentifiers'] = ['MacBook1,1', 'MacBook2,1', 'MacBook3,1', 'MacBook4,1', 'MacBook5,1', 'MacBook5,2', 'MacBook6,1', 'MacBook7,1', 'MacBook8,1', 'MacBook9,1', 'MacBookAir1,1', 'MacBookAir2,1', 'MacBookAir3,1', 'MacBookAir3,2', 'MacBookAir4,1', 'MacBookAir4,2', 'MacBookAir5,1', 'MacBookAir5,2', 'MacBookAir6,1', 'MacBookAir6,2', 'MacBookAir7,1', 'MacBookAir7,2', 'MacBookPro1,1', 'MacBookPro1,2', 'MacBookPro2,1', 'MacBookPro2,2', 'MacBookPro3,1', 'MacBookPro4,1', 'MacBookPro5,1', 'MacBookPro5,2', 'MacBookPro5,3', 'MacBookPro5,4', 'MacBookPro5,5', 'MacBookPro6,1', 'MacBookPro6,2', 'MacBookPro7,1', 'MacBookPro8,1', 'MacBookPro8,2', 'MacBookPro8,3', 'MacBookPro9,1', 'MacBookPro9,2', 'MacBookPro10,1', 'MacBookPro10,2', 'MacBookPro11,1', 'MacBookPro11,2', 'MacBookPro11,3', 'MacBookPro11,4', 'MacBookPro11,5', 'MacBookPro12,1', 'MacBookPro13,1', 'MacBookPro13,2', 'MacBookPro13,3', 'MacPro1,1', 'MacPro1,1,Quad', 'MacPro2,1', 'MacPro3,1', 'MacPro4,1', 'MacPro5,1', 'MacPro6,1', 'Macmini1,1', 'Macmini2,1', 'Macmini3,1', 'Macmini4,1', 'Macmini5,1', 'Macmini5,2', 'Macmini5,3', 'Macmini6,1', 'Macmini6,2', 'Macmini7,1', 'PowerBook1,1', 'PowerBook2,1', 'PowerBook2,2', 'PowerBook2,3', 'PowerBook3,1', 'PowerBook3,2', 'PowerBook3,3', 'PowerBook3,4', 'PowerBook3,5', 'PowerBook4,1', 'PowerBook4,2', 'PowerBook4,3', 'PowerBook4,4', 'PowerBook5,1', 'PowerBook5,2', 'PowerBook5,3', 'PowerBook5,4', 'PowerBook5,5', 'PowerBook5,6', 'PowerBook5,7', 'PowerBook5,8', 'PowerBook5,9', 'PowerBook6,1', 'PowerBook6,2', 'PowerBook6,3', 'PowerBook6,4', 'PowerBook6,5', 'PowerBook6,7', 'PowerBook6,8', 'PowerMac1,1', 'PowerMac1,2', 'PowerMac2,1', 'PowerMac2,2', 'PowerMac3,1', 'PowerMac3,2', 'PowerMac3,3', 'PowerMac3,4', 'PowerMac3,5', 'PowerMac3,6', 'PowerMac4,1', 'PowerMac4,2', 'PowerMac4,4', 'PowerMac4,5', 'PowerMac5,1', 'PowerMac5,2', 'PowerMac6,1', 'PowerMac6,3', 'PowerMac6,4', 'PowerMac7,2', 'PowerMac7,3', 'PowerMac8,1', 'PowerMac8,2', 'PowerMac9,1', 'PowerMac10,1', 'PowerMac10,2', 'PowerMac11,2', 'PowerMac11,2,Quad', 'PowerMac12,1', 'RackMac1,1', 'RackMac1,2', 'RackMac3,1', 'Xserve1,1', 'Xserve2,1', 'Xserve3,1', 'iMac4,1', 'iMac4,2', 'iMac5,1', 'iMac5,2', 'iMac6,1', 'iMac7,1', 'iMac8,1', 'iMac9,1', 'iMac10,1', 'iMac11,1', 'iMac11,2', 'iMac11,3', 'iMac12,1', 'iMac12,2', 'iMac13,1', 'iMac13,2', 'iMac13,3', 'iMac14,1', 'iMac14,2', 'iMac14,3', 'iMac14,4', 'iMac15,1', 'iMac16,1', 'iMac16,2', 'iMac17,1'] +try: + p['EnabledSystemIdentifiers'] +except: + p['EnabledSystemIdentifiers'] = [] +try: + p['Index'] +except: + p['Index'] = 526 +try: + p['IsDefault'] +except: + p['IsDefault'] = False +try: + p['IsEnabled'] +except: + p['IsEnabled'] = True +try: + p['IsInstall'] +except: + p['IsInstall'] = False +try: + p['Kind'] +except: + p['Kind'] = 1 +try: + p['Language'] +except: + p['Language'] = 'Default' +try: + p['Name'] +except: + p['Name'] = 'Faux NetBoot' +try: + p['RootPath'] +except: + p['RootPath'] = 'NetBoot.dmg' +try: + p['SupportsDiskless'] +except: + p['SupportsDiskless'] = False +try: + p['Type'] +except: + p['Type'] = 'HTTP' +try: + p['imageType'] +except: + p['imageType'] = 'netboot' +try: + p['osVersion'] +except: + p['osVersion'] = '10.12' + +p['Name'] = Name +p['Description'] = Description +p['Type'] = Type +p['Index'] = Index +p['SupportsDiskless'] = SupportsDiskless +p['RootPath'] = RootPath + +plistlib.writePlist(p, sys.argv[1]) diff --git a/webadmin/webadminInstall.sh b/webadmin/webadminInstall.sh index e851c50..6e51a5c 100755 --- a/webadmin/webadminInstall.sh +++ b/webadmin/webadminInstall.sh @@ -38,8 +38,7 @@ if [[ $(which apt-get 2>&-) != "" ]]; then apt_install php-xml www_user=www-data www_service=apache2 -fi -if [[ $(which yum 2>&-) != "" ]]; then +elif [[ $(which yum 2>&-) != "" ]]; then yum_install python-pycurl yum_install parted yum_install dmidecode