Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Minor code housekeeping standardisation
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan-mccracken committed Jun 14, 2017
1 parent 7bfc538 commit 6055023
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CreateNetSUSInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +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
if [ -x /usr/bin/xattr ]; then find temp -exec xattr -c {} \; ;fi # Remove OS X extended attributes
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

Expand Down
14 changes: 7 additions & 7 deletions NetBoot/netbootInstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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
Expand All @@ -56,7 +56,7 @@ 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
Expand Down Expand Up @@ -102,7 +102,7 @@ touch /var/db/dhcpd.leases
cp ./resources/dhcp/* /usr/local/sbin/ >> $logFile

# Update netatalk configuration
if [ -e /etc/default/netatalk ]; then
if [ -f "/etc/default/netatalk" ]; then
sed -i 's:.*ATALK_NAME=.*:ATALK_NAME=`/bin/hostname --short`:' /etc/default/netatalk
sed -i 's:.*AFPD_MAX_CLIENTS=.*:AFPD_MAX_CLIENTS=200:' /etc/default/netatalk
sed -i 's:.*AFPD_GUEST=.*:AFPD_GUEST=nobody:' /etc/default/netatalk
Expand All @@ -117,7 +117,7 @@ if [ -e /etc/default/netatalk ]; then
sed -i '/End of File/ i\
/srv/NetBootClients/$i "NetBoot" allow:afpuser rwlist:afpuser options:upriv preexec:"mkdir -p /srv/NetBootClients/$i/NetBoot001" postexec:"rm -rf /srv/NetBootClients/$i"' /etc/netatalk/AppleVolumes.default
fi
if [ -e /etc/netatalk/netatalk.conf ]; then
if [ -f "/etc/netatalk/netatalk.conf" ]; then
if ! grep -q '\- \-setuplog "default log_info /var/log/afpd.log"' /etc/netatalk/afpd.conf; then
echo '- -setuplog "default log_info /var/log/afpd.log"' >> /etc/netatalk/afpd.conf
fi
Expand Down Expand Up @@ -189,9 +189,9 @@ if [ ! -d "/home/afpuser" ]; then
fi

# Configure nfs
sed -i "/NetBootSP0/d" /etc/exports
echo "/srv/NetBoot/NetBootSP0 *(ro,no_subtree_check,no_root_squash,insecure)" >> "/etc/exports"
exportfs -a
# 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
Expand Down
4 changes: 2 additions & 2 deletions base/NetSUSInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ if [[ $INTERACTIVE = true ]]; then
echo "
The following will be installed
* Appliance Web Interface
* Software Update Server
* NetBoot Server
* Software Updates Server
* LDAP Proxy Server
* LDAP Proxy
"

# shellcheck disable=SC2162,SC2034
Expand Down
2 changes: 1 addition & 1 deletion base/testOSRequirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

logNoNewLine "Checking for a supported OS..."

if [ -e "/etc/os-release" ]; then
if [ -f "/etc/os-release" ]; then
source /etc/os-release
elif [ -e "/etc/system-release" ]; then
NAME=$(sed -e 's/ release.*//' /etc/system-release)
Expand Down
4 changes: 2 additions & 2 deletions webadmin/var/www/webadmin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
echo "<li>libapache2-mod-php</li>"; }
?>
<li>netatalk</li>
<li>nfs-kernel-server</li>
<!-- <li>nfs-kernel-server</li> -->
<li>openbsd-inetd</li>
<li>parted</li>
<?php if (version_compare(phpversion(), "7.0") < 0) {
Expand Down Expand Up @@ -85,7 +85,7 @@
<li>m2crypto</li>
<li>mod_ssl</li>
<li>netatalk</li>
<li>nfs-utils</li>
<!-- <li>nfs-utils</li> -->
<li>ntpdate</li>
<li>openldap-servers</li>
<li>parted</li>
Expand Down
30 changes: 15 additions & 15 deletions webadmin/var/www/webadmin/scripts/adminHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ case $1 in

getnettype)
interface=$(ip addr show to 0.0.0.0/0 scope global | sed -e :a -e '$!N;s/\n[[:blank:]]/ /;ta' -e 'P;D' | awk -F ': ' '{print $2}')
if [ -f /etc/network/interfaces ]; then
if [ -f "/etc/network/interfaces" ]; then
if [ "$(grep -i static /etc/network/interfaces)" != '' ]; then
echo "static"
else
Expand Down Expand Up @@ -58,7 +58,7 @@ gateway=$4
dns1=$5
dns2=$6
interface=$(ip addr show to 0.0.0.0/0 scope global | sed -e :a -e '$!N;s/\n[[:blank:]]/ /;ta' -e 'P;D' | awk -F ': ' '{print $2}')
if [ -f /etc/network/interfaces ]; then
if [ -f "/etc/network/interfaces" ]; then
echo "# Created by JSS Appliance Admin" > /etc/network/interfaces
echo auto lo >> /etc/network/interfaces
echo iface lo inet loopback >> /etc/network/interfaces
Expand Down Expand Up @@ -90,7 +90,7 @@ fi

setdhcp)
interface=$(ip addr show to 0.0.0.0/0 scope global | sed -e :a -e '$!N;s/\n[[:blank:]]/ /;ta' -e 'P;D' | awk -F ': ' '{print $2}')
if [ -f /etc/network/interfaces ]; then
if [ -f "/etc/network/interfaces" ]; then
echo "# Created by JSS Appliance Admin" > /etc/network/interfaces
echo auto lo >> /etc/network/interfaces
echo iface lo inet loopback >> /etc/network/interfaces
Expand Down Expand Up @@ -139,7 +139,7 @@ echo $(date)

#Get the time server that is set
gettimeserver)
if [ -f /etc/ntp/step-tickers ]; then
if [ -f "/etc/ntp/step-tickers" ]; then
echo $(cat /etc/ntp/step-tickers 2>/dev/null | grep -v "^$" | grep -m 1 -v '#')
else
echo $(cat /etc/cron.daily/ntpdate 2>/dev/null | awk '{print $2}')
Expand All @@ -149,7 +149,7 @@ fi
#Set the time server
settimeserver)
newTimeServer=$2
if [ -f /etc/ntp/step-tickers ]; then
if [ -f "/etc/ntp/step-tickers" ]; then
currentTimeServer=$(cat /etc/ntp/step-tickers | grep -v "^$" | grep -m 1 -v '#')
if [ "$currentTimeServer" != "$newTimeServer" ]; then
echo "# List of NTP servers used by the ntpdate service." > /etc/ntp/step-tickers
Expand Down Expand Up @@ -179,10 +179,10 @@ sethostname)
newname=$2
oldname=$(hostname)
sed -i "s/$oldname/$newname/g" /etc/hosts
if [ -f /etc/hostname ]; then
if [ -f "/etc/hostname" ]; then
echo $newname > /etc/hostname
fi
if [ -f /etc/sysconfig/network ]; then
if [ -f "/etc/sysconfig/network" ]; then
sed -i "s/$oldname/$newname/g" /etc/sysconfig/network
fi
hostname $newname
Expand Down Expand Up @@ -540,7 +540,7 @@ sed -i "/LocalCatalogURLBase/ a\
# echo $(df -H / | awk '{print $3}' | sed 's/Used//g' | tr -d "\n")
#else
# echo $(df -H --type=ext4 | awk '{print $4}' | sed 's/Avail//g' | tr -d "\n")
#fi
#fi
#;;

netbootusage)
Expand Down Expand Up @@ -624,7 +624,7 @@ else
result=$(/usr/local/sbin/jamfds createConf -url $2 2>&1)
fi
if [ $? -ne 0 ]; then
echo "$result" | sed -e 's/^error: //'
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
Expand All @@ -648,7 +648,7 @@ echo "<VirtualHost *:443>" > $conf
echo " SSLEngine on" >> $conf
echo "</VirtualHost>" >> $conf
echo "$(date '+[%Y-%m-%d %H:%M:%S]:') Writing API RewriteRule..." >> $logFile
sed -i 's#<VirtualHost \*:443>#<VirtualHost \*:443>\n\tRewriteEngine on\n\tRewriteRule ^/jds/api/([0-9a-z/]*)$ /jds/api.php?call=$2 [QSA,NC]#' $conf
sed -i 's#<VirtualHost \*:443>#<VirtualHost \*:443>\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#<VirtualHost \*:443>#<VirtualHost \*:443>\n\t<Directory /var/www/jds/>\n\t\tSSLVerifyClient require\n\t\tOptions None\n\t\tAllowOverride None\n\t</Directory>#' $conf
Expand Down Expand Up @@ -770,21 +770,21 @@ else
else
echo "false"
fi
fi
fi
;;

updateCert)
if [ -f "/etc/ssl/certs/ssl-cert-snakeoil.pem" ]; then
cp /var/appliance/conf/appliance.certificate.pem /etc/ssl/certs/ssl-cert-snakeoil.pem
cp /var/appliance/conf/appliance.private.key /etc/ssl/private/ssl-cert-snakeoil.key
mkdir -p /etc/apache2/ssl.crt/
mkdir -p /etc/apache2/ssl.crt/
cp /var/appliance/conf/appliance.chain.pem /etc/apache2/ssl.crt/server-ca.crt
chown openldap /var/appliance/conf/appliance.private.key
sed -i "s/#SSLCertificateChainFile \/etc\/apache2\/ssl.crt\/server-ca.crt/SSLCertificateChainFile \/etc\/apache2\/ssl.crt\/server-ca.crt/g" /etc/apache2/sites-enabled/default-ssl.conf
fi
if [ -f "/etc/pki/tls/certs/localhost.crt" ]; then
cp /var/appliance/conf/appliance.certificate.pem /etc/pki/tls/certs/localhost.crt
cp /var/appliance/conf/appliance.private.key /etc/pki/tls/private/localhost.key
cp /var/appliance/conf/appliance.private.key /etc/pki/tls/private/localhost.key
cp /var/appliance/conf/appliance.chain.pem /etc/pki/tls/certs/server-chain.crt
sed -i "s/#SSLCertificateChainFile \/etc\/pki\/tls\/certs\/server-chain.crt/SSLCertificateChainFile \/etc\/pki\/tls\/certs\/server-chain.crt/g" /etc/httpd/conf.d/ssl.conf
chown ldap /var/appliance/conf/appliance.private.key
Expand Down Expand Up @@ -1053,7 +1053,7 @@ rm -rf /srv/NetBootClients/*

# System Information
getName)
if [ -e "/etc/os-release" ]; then
if [ -f "/etc/os-release" ]; then
. /etc/os-release
elif [ -e "/etc/system-release" ]; then
NAME=$(sed -e 's/ release.*//' /etc/system-release)
Expand All @@ -1062,7 +1062,7 @@ echo "$NAME"
;;

getHomeUrl)
if [ -e "/etc/os-release" ]; then
if [ -f "/etc/os-release" ]; then
. /etc/os-release
if [ "$NAME" = 'Ubuntu' ] && [ "$HOME_URL" = '' ]; then
HOME_URL="http://www.ubuntu.com/"
Expand Down
6 changes: 3 additions & 3 deletions webadmin/webadminInstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ exit 0' >> $rc_local
chmod +x $rc_local

# Configure php
if [ -e /etc/php/7.0/apache2/php.ini ]; then
if [ -f "/etc/php/7.0/apache2/php.ini" ]; then
php_ini=/etc/php/7.0/apache2/php.ini
elif [ -e /etc/php5/apache2/php.ini ]; then
elif [ -f "/etc/php5/apache2/php.ini" ]; then
php_ini=/etc/php5/apache2/php.ini
elif [ -e /etc/php.ini ]; then
elif [ -f "/etc/php.ini" ]; then
php_ini=/etc/php.ini
else
log "Error: Failed to locate php.ini"
Expand Down

0 comments on commit 6055023

Please sign in to comment.