├── README.md ├── General ├── Fun with MAN pages.txt ├── com.apple.networkConnect.plist ├── PurgeRam │ ├── README.md │ ├── com.justinrummel.resetRAM.plist │ └── resetRAM.sh ├── APNS-Port-test.sh ├── SSH-keygen-copy.sh ├── Ubuntu-SSLCert-jks.sh ├── image_cleaner.sh └── PCPdelete.sh ├── VMWare ├── README.md ├── Backup │ ├── README.md │ ├── com.justinrummel.vmware.backup.plist │ └── backupVM.sh ├── VMwareTools_Linux.sh └── ubuntuSetup.sh ├── LICENSE └── JAMF ├── EA-RecoveryHD.sh ├── adminWiFi.sh ├── enable_firewall.sh ├── EA-Firmware.sh ├── setperfmode.sh ├── OSX-removeRecovery.sh ├── EA-OS.sh ├── EA-gatekeeper.sh ├── FileShare_mount.sh ├── EA-Flash-Version.sh ├── EA-prey-version.sh ├── EA-JavaVendor-Version.sh ├── purge.sh ├── EA-Dashboard-JavaCompliant.sh ├── jamfHelper-Notify.sh ├── prey-install.sh ├── EA-Dashboard-FlashCompliant.sh └── EA-MAS-Receipts.sh /README.md: -------------------------------------------------------------------------------- 1 | Public-Scripts 2 | ============== 3 | 4 | Scripts created by Justin Rummel and are for the public, all covered by MIT license. -------------------------------------------------------------------------------- /General/Fun with MAN pages.txt: -------------------------------------------------------------------------------- 1 | Fun with MAN pages 2 | 3 | man kerberos (/fubar) 4 | man route (/BUGS) 5 | man languagesetup (just read it) 6 | man tcpdump (/sushi) 7 | man tunefs (/fish) 8 | man plutil (/obey) 9 | 10 | -------------------------------------------------------------------------------- /VMWare/README.md: -------------------------------------------------------------------------------- 1 | README for VMWare folder 2 | 3 | 1. There is a separate README for the Backup folder 4 | 2. the VMwareTools is a useful item to leave in your linux VM so when Fusion is updated, you can get the latest updated tools running in your VM (such as attaching local folders to your VM). -------------------------------------------------------------------------------- /General/com.apple.networkConnect.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | VPNShowTime 6 | 1 7 | 8 | 9 | -------------------------------------------------------------------------------- /General/PurgeRam/README.md: -------------------------------------------------------------------------------- 1 | resetRAM 2 | === 3 | 4 | The goal for this script is to run the "purge" command at 11pm everyday to flush out unused memory. You must have Xcode command line tools installed for this to work. I'm only doing a simple test to verify that the purge command is available vs. if Xcode is installed. -------------------------------------------------------------------------------- /VMWare/Backup/README.md: -------------------------------------------------------------------------------- 1 | README Notes for backupVM.sh 2 | 3 | 1. Copy backupVM.sh to /usr/local/bin 4 | 2. Copy com.justinrummel.vmware.backup.plist to /Library/LaunchAgents and be sure to set the permissions to 644 root:wheel 5 | 3. REVIEW Scripts before you run them! Such as update the destination server in backupVM.sh (the default wont work) 6 | 4. Be sure to read the requiremetns of backupVM.sh 7 | 8 | This script is best used after you have established SSH keys between your client and destination server. 9 | 10 | See the SSH-keygen-copy.sh script in our GIT repo 11 | -------------------------------------------------------------------------------- /General/PurgeRam/com.justinrummel.resetRAM.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.justinrummel.resetRAM 7 | ProgramArguments 8 | 9 | /usr/local/bin/resetRAM.sh 10 | 11 | RunAtLoad 12 | 13 | StartCalendarInterval 14 | 15 | 16 | Hour 17 | 23 18 | Minute 19 | 0 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /VMWare/Backup/com.justinrummel.vmware.backup.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.justinrummel.vmware.backup 7 | LingonWhat 8 | /usr/local/bin/backupVM.sh 9 | ProgramArguments 10 | 11 | /usr/local/bin/backupVM.sh 12 | 13 | StartCalendarInterval 14 | 15 | Hour 16 | 23 17 | Minute 18 | 0 19 | Weekday 20 | 6 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Justin Rummel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /JAMF/EA-RecoveryHD.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Version 1.0.0 - 9/23/2012 24 | ### Description 25 | # Goal is to find out if Recovery HD is available on the Boot drive (vs. an external drive). 26 | # May not really matter, but for our purpose it is best practice. 27 | 28 | ### Variables 29 | recoveryID=`diskutil list | grep "disk0" | grep "Recovery HD" | awk '{print $NF}'` 30 | 31 | ### Functions 32 | [ "${recoveryID}" != "" ] && { echo "Available"; } || { echo "Not Available"; } 33 | exit 0 34 | -------------------------------------------------------------------------------- /JAMF/adminWiFi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2014-11-24 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to force WiFi Admin settings as seen on System Preferences => Network => Wireless 32 | # see /usr/libexec/airportd -h for more info 33 | 34 | # Script Variables 35 | RequireAdminIBSS="YES" 36 | RequireAdminNetworkChange="NO" 37 | RequireAdminPowerToggle="YES" 38 | 39 | # Script Functions 40 | /usr/libexec/airportd prefs RequireAdminIBSS="${RequireAdminIBSS}" RequireAdminNetworkChange="${RequireAdminNetworkChange}" RequireAdminPowerToggle="${RequireAdminPowerToggle}" 41 | 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /JAMF/enable_firewall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2014-10-02 25 | 26 | ### Description 27 | # This is an example to always enforce the Application layer Firewall on startup 28 | 29 | # enable firewall 30 | sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1 31 | 32 | # unload alf 33 | sudo launchctl unload /System/Library/LaunchDaemons/com.apple.alf.useragent.plist 34 | sudo launchctl unload /System/Library/LaunchDaemons/com.apple.alf.agent.plist 35 | 36 | # load alf 37 | sudo launchctl load /System/Library/LaunchDaemons/com.apple.alf.agent.plist 38 | sudo launchctl load /System/Library/LaunchDaemons/com.apple.alf.useragent.plist 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /JAMF/EA-Firmware.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Version 1.0.0 - 9/23/2012 24 | 25 | ### Description 26 | # Goal is to find out if a firmware password has been set. 27 | # Must have the 'setregproptool' installed at /usr/local/bin by a separate install 28 | # for this to work as 'setregproptool' is not available by default in OSX. You can 29 | # get it from Recovery HD, or "Install OS X Mountain Lion.app" 30 | 31 | ### Variables 32 | 33 | ### Functions 34 | detect () { 35 | FPenabled=`setregproptool -c` 36 | [ ! "${FPenabled}" ] && { echo "Enabled"; } || { echo "Disabled"; } 37 | } 38 | 39 | [ -e "/usr/local/bin/setregproptool" ] && { detect; } || { echo "CLI missing"; } 40 | exit 0 41 | -------------------------------------------------------------------------------- /JAMF/setperfmode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-11-19 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to enable setprefmode to true if machine has Server.app configured. 32 | 33 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 34 | declare -x SCRIPTPATH="${0}" 35 | declare -x RUNDIRECTORY="${0%/*}" 36 | declare -x SCRIPTNAME="${0##*/}" 37 | 38 | 39 | # Script Variables 40 | 41 | # Script Functions 42 | set_setperfmode () { 43 | if serverinfo -q --configured; then setperfmode="TRUE"; else setperfmode="FALSE"; fi 44 | [[ "${setperfmode}" == "TRUE" ]] && { serverinfo --setperfmode TRUE; echo "$?"; } 45 | } 46 | 47 | set_setperfmode 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /JAMF/OSX-removeRecovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Version 1.0.0 - 9/23/2012 24 | 25 | ### Description 26 | # Goal is to remove Recovery HD just in case your imaging fleet of OS X machines has it available 27 | # This will remove the Recovery HD partition and then merge the extra space w/ the primary drive 28 | 29 | # Script Variables 30 | RecoveryHDName="Recovery HD" 31 | RecoveryHDID=`/usr/sbin/diskutil list | grep "$RecoveryHDName" | awk 'END { print $NF }'` 32 | HDName="MBA HD" 33 | MBAHD=`/usr/sbin/diskutil list | grep "$HDName" | awk 'END { print $NF }'` 34 | 35 | ### functions 36 | [[ "${RecoveryHDID}" != "" && "${MBAHD}" != "" ]] && { echo "Removing ${RecoveryHDName} from ${MBAHD}"; } || { echo "There is an error. Stopping now."; exit 1; } 37 | diskutil eraseVolume HFS+ ErasedDisk "/dev/${RecoveryHDID}" 38 | 39 | [[ "${RecoveryHDID}" != "" && "${MBAHD}" != "" ]] && { diskutil mergePartitions HFS+ "${HDName}" "${MBAHD}" "${RecoveryHDID}"; } 40 | exit 0 41 | -------------------------------------------------------------------------------- /JAMF/EA-OS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Version 1.1.0 - 2013-10-29 24 | # Version 1.1.1 - 2014-10-16 25 | 26 | ### Description 27 | # Goal is to find out what vesion of the OS is running, PLUS if the machine is a client or server. 28 | # Needed for Mt Lion as a "Server OS" is now depricated. It's just an app. 29 | 30 | ### Variables 31 | osx=`sw_vers -productVersion | awk -F "." '{print $2}'` 32 | 33 | ### Functions 34 | oldSchool () { 35 | productName=`sw_vers -productName` 36 | productVersion=`sw_vers -productVersion` 37 | buildVersion=`sw_vers -buildVersion` 38 | 39 | echo "${productName} ${productVersion} (${buildVersion})" 40 | } 41 | 42 | newSchool () { 43 | if serverinfo -q --configured; then osxs=" Server"; else osxs=""; fi 44 | 45 | productName=`sw_vers -productName` 46 | productName2="${productName}${osxs}" 47 | productVersion=`sw_vers -productVersion` 48 | buildVersion=`sw_vers -buildVersion` 49 | 50 | echo "${productName2} ${productVersion} (${buildVersion})" 51 | } 52 | 53 | [ "${osx}" -gt "7" ] && { newSchool; } || { oldSchool; } 54 | 55 | exit 0 56 | 57 | -------------------------------------------------------------------------------- /VMWare/VMwareTools_Linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 11/15/2012 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to install VMWare Tools on an Ubuntu Server. Don't forget to mount the CD first! 32 | 33 | # variables 34 | cdMNT="/mnt/cdrom/" 35 | cdDEV="/dev/cdrom/" 36 | 37 | ### Be sure to select "Install VMWare Tools" from the "Virtual Machine" dropdown menu in VMWare Fusion 38 | [ ! -d "${cdMNT}" ] && { echo "creating ${cdMNT}"; sudo mkdir "${cdMNT}"; } || { echo "${cdMNT} already exists. Moving on..."; } 39 | [ ! -d "${cdDEV}" ] && { echo "mounting ${cdDEV} to ${cdMNT}"; sudo mount "${cdDEV}" "${cdMNT}"; } 40 | 41 | vmTGZ=`find "${cdMNT}" -name "VMwareTools*"` 2>/dev/null 42 | 43 | cd /tmp 44 | if [ -e "${vmTGZ}" ]; then 45 | cp "${cdMNT}${vmTGZ}" ./ 46 | tar xzvf "${vmTGZ}" 47 | cd vmware-tools-distrib/ 48 | sudo apt-get install build-essential 49 | sudo apt-get install build-essential linux-headers-`uname -r` 50 | sudo ./vmware-install.pl --default 51 | sudo reboot 52 | else 53 | echo "Something went wrong. Stopping now." 54 | exit 1 55 | fi 56 | exit 0 57 | -------------------------------------------------------------------------------- /General/APNS-Port-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 11/15/2012 25 | 26 | # Modified by 27 | # Version 28 | 29 | #variables 30 | APNS="gateway.push.apple.com" 31 | 32 | 33 | ### APNS has several IP address. Lets find just one 34 | echo "Getting /one/ of the IP's for ${APNS}" 35 | gpacIP=`dig A "${APNS}" +short | grep -v gateway | head -n 1` 36 | [ "${gpacIP}" != "" ] && { echo "Found ${gpacIP}"; } || { echo "Uh oh... something is wrong so I'll stop."; exit 0; } 37 | 38 | ### We're really trying to find the DNS name to test 39 | echo "Getting the PTR record for ${gpacIP}" 40 | gpacTempDNS=`host "${gpacIP}" | awk '{print $NF}'` 41 | gpacTrim=`echo "${gpacTempDNS}" | tail -c -2` 42 | [ "${gpacTrim}" == "." ] && { gpacDNS=`echo "${gpacTempDNS}" | sed 's/.$//'`; } || { gpacDNS="gpacTempDNS"; } 43 | [ gpacDNS != "" ] && { echo "Using ${gpacDNS}"; } || { echo "Uh oh... something is wrong so I'll stop."; exit 0; } 44 | 45 | ### can we connect to our specific APNS server? 46 | echo "Testing ${gpacDNS} over port 2195" 47 | TEST=`openssl s_client -connect "${gpacDNS}":2195 -no_ssl3 -no_tls1 | grep CONNECTED | cut -c 1-9`; 48 | [ "${TEST}" == "CONNECTED" ] && { echo "We can connect to ${gpacDNS}!"; } || { echo "There was an error... something is blocking port 2195"; } 49 | 50 | -------------------------------------------------------------------------------- /JAMF/EA-gatekeeper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Version 1.1.0 - 2013-11-02 24 | 25 | ### Description 26 | # Goal is to find out if Gatekeeper is active. 27 | # Only available on 10.7.5+ or 10.8.0+ OS 28 | 29 | ### Variables 30 | osmajor=`sw_vers -productVersion | awk -F "." '{print $1}'` 31 | osminor=`sw_vers -productVersion | awk -F "." '{print $2}'` 32 | osrev=`sw_vers -productVersion | awk -F "." '{print $3}'` 33 | 34 | ### Functions 35 | # Checks Gatekeeper status on 10.7.x Macs 36 | function lionGatekeeper () { 37 | if [ "${osrev}" -ge "5" ]; then 38 | gatekeeper_status=`spctl --status | grep "assessments" | cut -c13-` 39 | [ "${gatekeeper_status}" == "disabled" ] && { echo "Disabled"; } || { echo "Active"; } 40 | else 41 | echo "N/A; Update to the latest version of Lion." 42 | fi 43 | } 44 | 45 | # Checks Gatekeeper status on 10.8.x Macs 46 | function mtLionGatekeeper () { 47 | gatekeeper_status=`spctl --status | grep "assessments" | cut -c13-` 48 | [ "${gatekeeper_status}" == "disabled" ] && { echo "Disabled"; } || { echo "Active"; } 49 | } 50 | 51 | [[ "${osminor}" < "7" ]] && { echo "Gatekeeper N/A for this OS"; } 52 | [[ "${osminor}" == "7" ]] && { lionGatekeeper; } 53 | [[ "${osminor}" > "7" ]] && { mtLionGatekeeper; } 54 | exit 0 55 | -------------------------------------------------------------------------------- /JAMF/FileShare_mount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2014-10-02 25 | 26 | ### Description 27 | # I'm looking for the domain_name_server section of the ipconfig command. 28 | # I assume I'm looking for the LAST IP address that is handed via your DHCP server. 29 | # This was created for JNUC 2014 Policies presentation, there are always better ways to do things 30 | # for your environment. 31 | 32 | ### Variables 33 | DNS_SERVER="10.13.12.122" 34 | FILE_SERVER="host.domain.tld" 35 | SHARE_NAME="Shared" 36 | PROTOCOL="afp" 37 | 38 | WIFI=`networksetup -listnetworkserviceorder | grep "Wi-Fi" | tail -1 | awk -F ": " '{print $NF}' | sed 's/)//g'` 39 | ETHERNET=`networksetup -listnetworkserviceorder | grep "Ethernet" | tail -1 | awk -F ": " '{print $NF}' | sed 's/)//g'` 40 | 41 | WIFI_DNS=`ipconfig getpacket "${WIFI}" | awk '/domain_name_server/ {print $NF}' | sed 's/}//g'` 42 | ETH_DNS=`ipconfig getpacket "${ETHERNET}" | awk '/domain_name_server/ {print $NF}' | sed 's/}//g'` 43 | 44 | ### Functions 45 | net_mount() { 46 | open "${PROTOCOL}://${FILE_SERVER}/${SHARE_NAME}/" 47 | } 48 | 49 | [[ "${ETH_DNS}" == "${DNS_SERVER}" ]] && { net_mount; exit 0; } || { echo "${ETH_DNS}"; } 50 | [[ "${WIFI_DNS}" == "${DNS_SERVER}" ]] && { net_mount; exit 0; } || { echo "${WIFI_DNS}"; } 51 | 52 | echo "Not on the network. I'll stop now." 53 | exit 0 54 | -------------------------------------------------------------------------------- /JAMF/EA-Flash-Version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 1/14/2013 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Find and report the current version of Flash installed 32 | 33 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 34 | declare -x SCRIPTPATH="${0}" 35 | declare -x RUNDIRECTORY="${0%%/*}" 36 | declare -x SCRIPTNAME="${0##*/}" 37 | 38 | logtag="${0##*/}" 39 | debug_log="enable" 40 | logDate=`date +"Y.m.d"` 41 | logDateTime=`date +"Y-m-d_H.M.S"` 42 | log_dir="/Library/Logs/${logtag}" 43 | LogFile="${logtag}-${logDate}.log" 44 | 45 | # Script Variables 46 | #Flash (not sure why there is a .lzma in one of my test machines, but this way I find the plugin that is installed!) 47 | fPlugin=`find /Library/Internet\ Plug-Ins -name "Flash*" -d 1 | awk -F "/" {'print $4'}` 48 | flashVendor=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/"${fPlugin}"/Contents/Info CFBundleIdentifier` 49 | flashVersion=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/"${fPlugin}"/Contents/Info CFBundleVersion` 50 | 51 | 52 | # Script Functions 53 | adobeFlash () { 54 | [ "${javaProject}" == "" ] && { echo "Adobe Flash (${flashVersion})"; } || { echo "Oracle (${javaProject} - ${javaVersion})"; } 55 | } 56 | 57 | [ "$flashVendor" == "" ] && { echo "Flash Plug-In Not Available"; exit 0; } || { adobeFlash; } 58 | 59 | 60 | exit 0; 61 | -------------------------------------------------------------------------------- /JAMF/EA-prey-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-12-12 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to report the version of Prey installed on the client. 32 | 33 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 34 | declare -x SCRIPTPATH="${0}" 35 | declare -x RUNDIRECTORY="${0%/*}" 36 | declare -x SCRIPTNAME="${0##*/}" 37 | 38 | logtag="${0##*/}" 39 | debug_log="disable" 40 | logDate=`date "+%Y-%m-%d"` 41 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 42 | log_dir="/Library/Logs/${logtag}" 43 | LogFile="${logtag}-${logDate}.log" 44 | 45 | # Script Variables 46 | 47 | # Script Functions 48 | # Output to stdout and LogFile. 49 | logThis () { 50 | logger -s -t "${logtag}" "$1" 51 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 52 | } 53 | 54 | init () { 55 | # Make our log directory 56 | [ ! -d $log_dir ] && { mkdir $log_dir; } 57 | 58 | # Now make our log file 59 | if [ -d $log_dir ]; then 60 | [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 61 | else 62 | echo "Error: Could not create log file in directory $log_dir." 63 | exit 1 64 | fi 65 | echo " " >> "${log_dir}/${LogFile}" 66 | } 67 | 68 | prey_check() { 69 | [[ -e /usr/share/prey/prey.sh ]] && { run_check; } || { echo "prey not installed"; } 70 | } 71 | 72 | run_check () { 73 | version=`/usr/share/prey/prey.sh -v` 74 | logThis "${version}" 75 | echo "${version}" 76 | } 77 | 78 | init 79 | prey_check 80 | 81 | exit 0 82 | -------------------------------------------------------------------------------- /General/PurgeRam/resetRAM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-4-16 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to 32 | 33 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 34 | declare -x SCRIPTPATH="${0}" 35 | declare -x RUNDIRECTORY="${0%/*}" 36 | declare -x SCRIPTNAME="${0##*/}" 37 | 38 | logtag="${0##*/}" 39 | debug_log="enable" 40 | logDate=`date "+%Y-%m-%d"` 41 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 42 | log_dir="/Library/Logs/${logtag}" 43 | LogFile="${logtag}-${logDate}.log" 44 | purge="/usr/bin/purge" 45 | 46 | # Script Variables 47 | 48 | # Script Functions 49 | verifyRoot () { 50 | #Make sure we are root before proceeding. 51 | [ `id -u` != 0 ] && { echo "$0: Please run this as root."; exit 0; } 52 | } 53 | 54 | # Output to stdout and LogFile. 55 | logThis () { 56 | logger -s -t "${logtag}" "$1" 57 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 58 | } 59 | 60 | init () { 61 | # Make our log directory 62 | [ ! -d $log_dir ] && { mkdir $log_dir; } 63 | 64 | # Now make our log file 65 | if [ -d $log_dir ]; then 66 | [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 67 | else 68 | echo "Error: Could not create log file in directory $log_dir." 69 | exit 1 70 | fi 71 | echo " " >> "${log_dir}/${LogFile}" 72 | } 73 | 74 | resetRAM () { 75 | [[ -e "${purge}" ]] && { "${purge}"; logThis "Purge completed successfully."; } || { logThis "${purge} cannot be found. Stopping task."; exit 1; } 76 | } 77 | 78 | verifyRoot 79 | init 80 | resetRAM 81 | 82 | exit 0 83 | -------------------------------------------------------------------------------- /JAMF/EA-JavaVendor-Version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 1/14/2013 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Find the Vendor (Apple or Oracle) for the current version of Java. 32 | # Based on Rich's post at: http://derflounder.wordpress.com/2012/10/31/casper-extension-attribute-scripts-to-report-java-browser-plug-in-info/ 33 | # and Christoph von Gabler-Sahm (linked via Rich) 34 | 35 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 36 | declare -x SCRIPTPATH="${0}" 37 | declare -x RUNDIRECTORY="${0%%/*}" 38 | declare -x SCRIPTNAME="${0##*/}" 39 | 40 | logtag="${0##*/}" 41 | debug_log="enable" 42 | logDate=`date +"Y.m.d"` 43 | logDateTime=`date +"Y-m-d_H.M.S"` 44 | log_dir="/Library/Logs/${logtag}" 45 | LogFile="${logtag}-${logDate}.log" 46 | 47 | # Script Variables 48 | javaVendor=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleIdentifier` 49 | javaVersion=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleShortVersionString` 50 | javaProject=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/version ProjectName 2>/dev/null` 51 | 52 | 53 | # Script Functions 54 | appleJava () { 55 | [ "${javaProject}" == "" ] && { echo "Apple (${javaVersion})"; } || { echo "Apple (${javaProject} - ${javaVersion})"; } 56 | } 57 | 58 | oracleJava () { 59 | [ "${javaProject}" == "" ] && { echo "Oracle (${javaVersion})"; } || { echo "Oracle (${javaProject} - ${javaVersion})"; } 60 | } 61 | 62 | [ "$javaVendor" == "" ] && { echo "No Java Plug-In Available"; exit 0;} 63 | [ "$javaVendor" == "com.apple.java.JavaAppletPlugin" ] && { appleJava;} 64 | [ "$javaVendor" == "com.oracle.java.JavaAppletPlugin" ] && { oracleJava;} 65 | 66 | exit 0; -------------------------------------------------------------------------------- /JAMF/purge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-11-17 25 | 26 | # Modified by Justin Rummel 27 | # Vesion 1.0.1 - 2014-10-16 28 | 29 | ### Description 30 | # Goal is to use the purge command to clear out unused memory. 31 | # Confession, I feel dirty doing this 32 | 33 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 34 | declare -x SCRIPTPATH="${0}" 35 | declare -x RUNDIRECTORY="${0%/*}" 36 | declare -x SCRIPTNAME="${0##*/}" 37 | 38 | logtag="${0##*/}" 39 | debug_log="disable" 40 | logDate=`date "+%Y-%m-%d"` 41 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 42 | log_dir="/Library/Logs/${logtag}" 43 | LogFile="${logtag}-${logDate}.log" 44 | 45 | # Script Variables 46 | osx=`sw_vers -productVersion | awk -F "." '{print $2}'` 47 | 48 | # Script Functions 49 | 50 | # Output to stdout and LogFile. 51 | logThis () { 52 | logger -s -t "${logtag}" "$1" 53 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 54 | } 55 | 56 | 57 | #init () { 58 | # # Make our log directory 59 | # [ ! -d $log_dir ] && { mkdir $log_dir; } 60 | # 61 | # # Now make our log file 62 | # if [ -d $log_dir ]; then 63 | # [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 64 | # else 65 | # echo "Error: Could not create log file in directory $log_dir." 66 | # exit 1 67 | # fi 68 | # echo " " >> "${log_dir}/${LogFile}" 69 | #} 70 | 71 | purgeRAM () { 72 | [ "${osx}" -gt "8" ] && { purge="/usr/sbin/purge"; } 73 | [ "${osx}" -eq "8" ] && { purge="/usr/bin/purge"; } 74 | [ "${osx}" -lt "8" ] && { logThis "Not sure if 'purge' is supported on your OS."; } 75 | 76 | /usr/bin/sudo "${purge}"; 77 | [ "$?" -ne "0" ] && { logThis "Error, purge command failed with the status: $?"; } 78 | } 79 | 80 | purgeRAM 81 | 82 | exit 0 83 | -------------------------------------------------------------------------------- /JAMF/EA-Dashboard-JavaCompliant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-08-30 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Find the Vendor (Apple or Oracle) for the current installed version of Java. 32 | # And compare to XProtect 33 | 34 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 35 | declare -x SCRIPTPATH="${0}" 36 | declare -x RUNDIRECTORY="${0%%/*}" 37 | declare -x SCRIPTNAME="${0##*/}" 38 | 39 | logtag="${0##*/}" 40 | debug_log="enable" 41 | logDate=`date +"Y.m.d"` 42 | logDateTime=`date +"Y-m-d_H.M.S"` 43 | log_dir="/Library/Logs/${logtag}" 44 | LogFile="${logtag}-${logDate}.log" 45 | 46 | 47 | # Script Variables 48 | #java 49 | javaVendor=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleIdentifier` 50 | javaVersion=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleVersion` 51 | 52 | #Xprotect 53 | sourceDir="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/" 54 | file="XProtect.plist" 55 | metaFile="XProtect.meta.plist" 56 | 57 | 58 | # Script Functions 59 | appleJava () { 60 | appleX=`/usr/libexec/PlistBuddy -c "print :PlugInBlacklist:10:com.apple.java.JavaAppletPlugin:MinimumPlugInBundleVersion" "${sourceDir}${metaFile}"` 61 | 62 | # echo "${appleX}" 63 | # echo "${javaVersion}" 64 | 65 | [[ "${appleX}" > "${javaVersion}" ]] && { echo "Outdated"; } || { echo "Compliant"; } 66 | } 67 | 68 | oracleJava () { 69 | oracleX=`/usr/libexec/PlistBuddy -c "print :PlugInBlacklist:10:com.oracle.java.JavaAppletPlugin:MinimumPlugInBundleVersion" "${sourceDir}${metaFile}"` 70 | 71 | # echo "${oracleX}" 72 | # echo "${javaVersion}" 73 | 74 | [[ "${oracleX}" > "${javaVersion}" ]] && { echo "Outdated"; } || { echo "Compliant"; } 75 | } 76 | 77 | [ "$javaVendor" == "" ] && { echo "No Java Plug-In Available"; exit 0; } 78 | [ "$javaVendor" == "com.apple.java.JavaAppletPlugin" ] && { appleJava; } 79 | [ "$javaVendor" == "com.oracle.java.JavaAppletPlugin" ] && { oracleJava; } 80 | 81 | exit 0; 82 | -------------------------------------------------------------------------------- /JAMF/jamfHelper-Notify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2014-5-19 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to notify a user that an item is available in Self Service. Upon selecting "OK", Self Service will open. 32 | # 33 | # Concept: In order to deploy the 10.9.3 Combo, you first create a policy to Cache the install, 34 | # use this script to notify users that it is available, then create a Self Service policy to install cached item. 35 | 36 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 37 | declare -x SCRIPTPATH="${0}" 38 | declare -x RUNDIRECTORY="${0%/*}" 39 | declare -x SCRIPTNAME="${0##*/}" 40 | 41 | logtag="${0##*/}" 42 | debug_log="disable" 43 | logDate=`date "+%Y-%m-%d"` 44 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 45 | log_dir="/Library/Logs/${logtag}" 46 | LogFile="${logtag}-${logDate}.log" 47 | 48 | # Script Variables 49 | jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" 50 | 51 | #### Info 52 | # Usage: jamfHelper -windowType [-windowPostion] [-title] [-heading] [-description] 53 | # [-icon] [-button1] [-button2] [-defaultButton] [-cancelButton] [-showDelayOptions] 54 | # [-alignDescription] [-alignHeading] [-alignCountdown] [-timeout] [-countdown] [-iconSize] 55 | # [-lockHUD] [-startLaunchd] [-fullScreenIcon] [-kill] 56 | 57 | # Options 58 | wtype="utility" # hud, utility 59 | title="System Notification" 60 | heading="Notification from your Friendly IT Helper" 61 | message="This is a message" 62 | iPath="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns" # Path to your icon 63 | button1="OK" 64 | button2="Cancel" 65 | defaultButton="1" 66 | cancelButton="2" 67 | 68 | # Are we testing, or is this real? 69 | [ "${4}" != "" ] && { message="${4}"; } 70 | 71 | # send the command 72 | notice=`"${jamfHelper}" -windowType "${wtype}" -title "${title}" -heading "${heading}" -description "${message}" -icon "${iPath}" -button1 "${button1}" -button2 "${button2}" -cancelButton "${cancelButton}" -defaultButton "${defaultButton}"` 73 | 74 | # if OK, open Self Service 75 | [ "${notice}" == 0 ] && { open -a "Self Service"; } 76 | exit 0; 77 | -------------------------------------------------------------------------------- /JAMF/prey-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2014-5-22 25 | 26 | # Modified by 27 | # Version 28 | 29 | 30 | ### Description 31 | # Goal is to download and install the current version of Prey and mass deploy to machines. 32 | # Must have a Pro account to get API privileges. 33 | 34 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 35 | declare -x SCRIPTPATH="${0}" 36 | declare -x RUNDIRECTORY="${0%/*}" 37 | declare -x SCRIPTNAME="${0##*/}" 38 | 39 | logtag="${0##*/}" 40 | debug_log="disable" 41 | logDate=`date "+%Y-%m-%d"` 42 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 43 | log_dir="/Library/Logs/${logtag}" 44 | LogFile="${logtag}-${logDate}.log" 45 | 46 | # Script Variables 47 | myAPI="xxxxxx" 48 | 49 | # Script Functions 50 | verifyRoot () { 51 | #Make sure we are root before proceeding. 52 | [ `id -u` != 0 ] && { echo "$0: Please run this as root."; exit 0; } 53 | } 54 | 55 | # Output to stdout and LogFile. 56 | logThis () { 57 | logger -s -t "${logtag}" "$1" 58 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 59 | } 60 | 61 | init () { 62 | # Make our log directory 63 | [ ! -d $log_dir ] && { mkdir $log_dir; } 64 | 65 | # Now make our log file 66 | if [ -d $log_dir ]; then 67 | [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 68 | else 69 | echo "Error: Could not create log file in directory $log_dir." 70 | exit 1 71 | fi 72 | echo " " >> "${log_dir}/${LogFile}" 73 | } 74 | 75 | readyGO () { 76 | # function variables 77 | currentPrey=`curl -s https://preyproject.com/releases/bash-client/current/ | grep mpkg | grep -v md5sum | awk -F "\"" '{print $2}'` 78 | preyPKG=`echo "${currentPrey}" | sed 's/\.zip//g'` 79 | 80 | # Download current version to /tmp 81 | curl https://preyproject.com/releases/bash-client/current/"${currentPrey}" -o "/tmp/${currentPrey}" 82 | 83 | # unzip 84 | unzip "/tmp/${currentPrey}" -d "/tmp/" 85 | 86 | # clear the path 87 | # rm -rf /usr/share/prey 88 | 89 | # install 90 | API_KEY=["${myAPI}"] sudo -E installer -pkg /tmp/"${preyPKG}" -target / -verbose 91 | 92 | # Testing install 93 | /usr/share/prey/prey.sh -v 94 | } 95 | 96 | verifyRoot 97 | init 98 | readyGO 99 | 100 | exit 0 101 | -------------------------------------------------------------------------------- /General/SSH-keygen-copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 11/15/2012 25 | 26 | # Modified by 27 | # Version 28 | 29 | ### Description 30 | # The purpose of this script is to generate a SSH keypair, then copy to a remote server 31 | # so you can SSH into that server without having to type in a password. 32 | 33 | 34 | ### Variables 35 | username="$1" 36 | server="$2" 37 | id_rsa="$HOME/.ssh/id_rsa" 38 | id_rsaPub="$HOME/.ssh/id_rsa.pub" 39 | 40 | intro () { 41 | echo "The purpose of this script is to generate a SSH keypair, then copy to a remote server. 42 | Use the following flags to get info 43 | -h,-help,--help Dislplay help info 44 | 45 | This script expects 46 | ${0##*/} 'username' 'Target Server FQDN' # You will be prompted for a password. 47 | " 48 | 49 | exit 0 50 | } 51 | 52 | info () { 53 | echo "This script performs the following actions: 54 | 55 | First checking to make sure that a username and FQDN has been passed as input variables. 56 | I'm not performing any sanity checkes, only verifing that they are not NULL 57 | 58 | Next we need to have an id_rsa file to copy to our remote server. If one is not available, create one. 59 | 60 | Finally we will copy the id_rsa.pub fingerprint to our remote server. A couple of things will (or could) happen: 61 | 1) you WILL be prompted for your password for the username provided on your remote server. This is OK 62 | 2) if you get a SECOND password prompt. Something is wrong. Most likely on your remote server you need 63 | to create ~/.ssh/ folder because you have never 'SSH' out of your system." 64 | 65 | exit 0 66 | } 67 | 68 | validate () { 69 | # since we are checking two variables, we need double brackets 70 | [[ "${username}" == "" || "${server}" == "" ]] && { intro; } 71 | 72 | echo "First lets verify you have an id_rsa key in ~/.ssh folder. If not, I'll create one for you." 73 | generate 74 | 75 | # validate id_rsa file exists 76 | [ -e "${id_rsa}" ] && { echo "id_rsa is available"; } || { echo "ERROR: Something went wrong. I'll stop now"; exit 1; } 77 | 78 | copyID 79 | } 80 | 81 | generate () { 82 | [ ! -e "${id_rsa}" ] && { ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa; } 83 | } 84 | 85 | copyID () { 86 | echo "Copy our id_rsa.pub file to remote server. This will prompt for your password (for the last time!)" 87 | ssh -q "${username}@${server}" "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo `cat $id_rsaPub` >> ~/.ssh/authorized_keys" 88 | # scp "${id_rsaPub}" "${username}@${server}":.ssh/authorized_keys 89 | 90 | # Security 91 | chmod 400 "${id_rsaPub}" 92 | } 93 | 94 | case "$1" in 95 | -h) 96 | info 97 | ;; 98 | 99 | -help) 100 | info 101 | ;; 102 | 103 | --help) 104 | info 105 | ;; 106 | *) 107 | validate 108 | esac -------------------------------------------------------------------------------- /JAMF/EA-Dashboard-FlashCompliant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.1 - 2014-02-05 25 | # Version 1.0.2 - 2014-12-17 26 | 27 | # Modified by Justin 28 | # Version 1.0.1 reversed logic to find if compliant vs. not compliant. 29 | # Version 1.0.2 not sure why logic is so hard. 30 | 31 | 32 | ### Description 33 | # Find the current installed version of Flash. 34 | # And compare to XProtect 35 | 36 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 37 | declare -x SCRIPTPATH="${0}" 38 | declare -x RUNDIRECTORY="${0%%/*}" 39 | declare -x SCRIPTNAME="${0##*/}" 40 | 41 | logtag="${0##*/}" 42 | debug_log="enable" 43 | logDate=`date +"Y.m.d"` 44 | logDateTime=`date +"Y-m-d_H.M.S"` 45 | log_dir="/Library/Logs/${logtag}" 46 | LogFile="${logtag}-${logDate}.log" 47 | 48 | 49 | # Script Variables 50 | #Flash (not sure why there is a .lzma in one of my test machines, but this way I find the plugin that is installed!) 51 | fPlugin=`find /Library/Internet\ Plug-Ins -name "Flash*" -d 1 | awk -F "/" {'print $4'}` 52 | flashVendor=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/"${fPlugin}"/Contents/Info CFBundleIdentifier` 53 | flashVersion=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/"${fPlugin}"/Contents/Info CFBundleVersion` 54 | 55 | #Xprotect 56 | sourceDir="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/" 57 | file="XProtect.plist" 58 | metaFile="XProtect.meta.plist" 59 | 60 | 61 | # Script Functions 62 | adobeFlash () { 63 | appleX=`/usr/libexec/PlistBuddy -c "print :PlugInBlacklist:10:com.macromedia.Flash\ Player.plugin:MinimumPlugInBundleVersion" "${sourceDir}${metaFile}"` 64 | 65 | # echo "${appleX}" 66 | # echo "${flashVersion}" 67 | 68 | Xoct1=`echo "${appleX}" | awk -F "." '{print $1}'` 69 | Xoct2=`echo "${appleX}" | awk -F "." '{print $2}'` 70 | Xoct3=`echo "${appleX}" | awk -F "." '{print $3}'` 71 | Xoct4=`echo "${appleX}" | awk -F "." '{print $4}'` 72 | 73 | oct1=`echo "${flashVersion}" | awk -F "." '{print $1}'` 74 | oct2=`echo "${flashVersion}" | awk -F "." '{print $2}'` 75 | oct3=`echo "${flashVersion}" | awk -F "." '{print $3}'` 76 | oct4=`echo "${flashVersion}" | awk -F "." '{print $4}'` 77 | 78 | # echo "$oct1 -lt $Xoct1" 79 | # echo "$oct2 -lt $Xoct2" 80 | # echo "$oct3 -lt $Xoct3" 81 | # echo "$oct4 -ge $Xoct4" 82 | 83 | [[ "${oct1}" -lt "${Xoct1}" ]] && { echo "Not Compliant"; exit 0; } 84 | [[ "${oct2}" -lt "${Xoct2}" ]] && { echo "Not Compliant"; exit 0; } 85 | [[ "${oct3}" -lt "${Xoct3}" ]] && { echo "Not Compliant"; exit 0; } 86 | [[ "${oct4}" -lt "${Xoct4}" ]] && { echo "Not Compliant"; exit 0; } || { echo "Compliant"; } 87 | } 88 | 89 | [ "$flashVendor" == "" ] && { echo "Flash Plug-In Not Available"; exit 0; } || { adobeFlash; } 90 | 91 | exit 0; 92 | -------------------------------------------------------------------------------- /JAMF/EA-MAS-Receipts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # Discovery on HOW to do this by Magervalp: http://magervalp.github.com/2013/03/19/poking-around-in-masreceipts.html 24 | 25 | # Created by Justin Rummel 26 | # Version 1.0.0 - 2013-03-19 27 | 28 | # Modified by 29 | # Version 1.0.1 2013-03-19 by Justin see commit notes. 30 | 31 | 32 | ### Description 33 | # Goal is to find out if the Apple ID that is assigned to the "/Applications/App Store.app" 34 | # matches with an Application that is installed from MAS and is available in the /Applications folder. 35 | 36 | ### Base Variables that I use for all scripts. Creates Log files and sets date/time info 37 | declare -x SCRIPTPATH="${0}" 38 | declare -x RUNDIRECTORY="${0%/*}" 39 | declare -x SCRIPTNAME="${0##*/}" 40 | 41 | logtag="${0##*/}" 42 | debug_log="enable" 43 | logDate=`date +"%Y-%m-%d"` 44 | logDateTime=`date +"%Y-%m-%d_H%:M%:%S"` 45 | log_dir="/Library/Logs/${logtag}" 46 | LogFile="${logtag}-${logDate}.log" 47 | 48 | ### Script Variables 49 | cUser=`ps -jax | grep [c]onsole | awk '{print $1}'` 50 | DSPersonID=`defaults read /Users/"${cUser}"/Library/Preferences/com.apple.storeagent DSPersonID` 51 | apps="/Applications/" 52 | receipt="/Contents/_MASReceipt/receipt" 53 | tmpPath="/tmp/MASreceipts/" 54 | idTotal=`count "${tmpPath}"*` 55 | 56 | ### Script Functions 57 | # Search the /Applications folder, find all "MAS" applications (i.e. the app has an _MASReceipt/receipt item) 58 | # then pipe out the Bundle identifier info so we can read the data with another function. 59 | appSearch () { 60 | [ ! -d "${tmpPath}" ] && { mkdir "${tmpPath}"; } 61 | for app in "${apps}"* ; do 62 | if [ -d "${app}" ]; then 63 | #echo $(basename "$app") 64 | #[ -e "${app}${receipt}" ] && { echo "${app}"; } 65 | [ -e "${app}${receipt}" ] && { payload "${app}${receipt}" "$(basename "$app")"; } 66 | fi 67 | done 68 | } 69 | 70 | payload () { 71 | openssl asn1parse -inform der -in "${1}" | grep -m 1 'OCTET STRING' | cut -d: -f4 | xxd -r -p > "${tmpPath}$2" 72 | } 73 | 74 | # Search the tmp folder of Bundle identifier info, and extract the ID that is embedded. 75 | receiptSearch () { 76 | if [ "${idTotal}" != 0 ]; then 77 | echo "" 78 | for MAS in "${tmpPath}"* ; do 79 | #echo $(basename "$MAS") 80 | [ -e "${MAS}" ] && { MSPersonID "${MAS}"; } 81 | done 82 | echo "" 83 | fi 84 | } 85 | 86 | # Report if the com.apple.storeagent matches the ID of the MAS app. 87 | MSPersonID () { 88 | PID=`printf "%d\n" 0x$(openssl asn1parse -inform der -in "${1}" | grep -A 2 ':04$' | tail -1 | cut -d: -f4 | cut -c5-)` 89 | [ "${PID}" == "${DSPersonID}" ] && { echo "$(basename "$1") matches MAS Apple ID"; } || { echo "$(basename "$1") DOES NOT Match"; } 90 | } 91 | 92 | # Just in case if the App Store is not set with an ID, validate that it is not blank. 93 | # Not sure if this is a accurate test, but till I get some feed back this is better than nothing. 94 | [ "${DSPersonID}" != "" ] && { appSearch; receiptSearch; } || { echo "com.apple.storeagent not set"; } 95 | exit 0 96 | -------------------------------------------------------------------------------- /General/Ubuntu-SSLCert-jks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 11/15/2012 25 | 26 | # Modified by 27 | # Version 28 | 29 | # Description 30 | # Create a jks keystore for SSL Certificates. Useful for Ubuntu installs of JAMF and you want to use a 3rd party certificate 31 | 32 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 33 | declare -x SCRIPTPATH="${0}" 34 | declare -x RUNDIRECTORY="${0%%/*}" 35 | declare -x SCRIPTNAME="${0##*/}" 36 | 37 | logtag="${0##*/}" 38 | debug_log="enable" 39 | logDate=`date +"%Y.%m.%d"` 40 | logDateTime=`date +"%Y-%m-%d_%H.%M.%S"` 41 | log_dir="/tmp/${logtag}" 42 | LogFile="${logtag}-${logDate}.log" 43 | 44 | # variables 45 | keyPass="changeme" 46 | interface=`ifconfig -s | grep eth | awk '{print $1}'` 47 | myIP=`ip addr show "${interface}" | grep -v inet6 | grep inet | awk '{print $2}' | awk -F "/" '{print $1}'` 48 | fqdn=`host 192.168.1.130 | awk -F " " '{print $5}' | sed 's/.$//'` 49 | 50 | # Output to stdout and LogFile. 51 | logThis () { 52 | logger -s -t "${logtag}" "$1" 53 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 54 | } 55 | 56 | init () { 57 | # Make our log directory 58 | [ ! -d $log_dir ] && { mkdir $log_dir; } 59 | 60 | # Make now make our log file 61 | if [ -d $log_dir ]; then 62 | [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 63 | else 64 | echo "Error: Could not create log file in directory $log_dir." 65 | exit 1 66 | fi 67 | echo " " >> "${log_dir}/${LogFile}" 68 | } 69 | 70 | confCheck () { 71 | [ "${keyPass}" == "changeme" ] && { echo -n "You have not changed the default password, do you want to change it? [y|n]: "; } 72 | read -n 1 validateChange 73 | echo " " 74 | [ "${validateChange}" != "y" ] && { logThis "OK, I'll use the default key password"; } || { keyNewPass; } 75 | } 76 | 77 | keyNewPass () { 78 | echo -n "Please type your new key password: " 79 | read -s newPass 80 | echo " " 81 | echo -n "Please type key password again to verify: " 82 | read -s newPass2 83 | echo " " 84 | echo " " 85 | [ "${newPass}" != "${newPass2}" ] && { logThis "Oops. You fat fingered your password. Start over."; exit 0; } 86 | [ "${newPass}" != "" ] && { logThis "New Password Accepted."; } || { logThis "You must be confused. I'll stop now before I make a mess."; exit 0; } 87 | } 88 | 89 | keyCheck () { 90 | logThis "Checking for keytool command" 91 | keyPath=`whereis keytool | awk -F " " '{print $2}'` 92 | [ "${keyPath}" == "" ] && { keyDownload; } 93 | } 94 | 95 | keyDownload () { 96 | echo -n "keytool cannot be found. Want me to install jdk and jre tools? [y|n]: " 97 | read -n 1 validateInstall 98 | echo " " 99 | echo " " 100 | [ "${validateInstall}" == "y" ] && { logThis "Running sudo apt-get for TWO installs. You will need to provide your password w/ sudo rights."; } || { logThis "OK, I'll stop now."; exit 0; } 101 | 102 | sudo apt-get install openjdk-6-jdk 103 | sudo apt-get install openjdk-6-jre-headless 104 | 105 | logThis "Validating install" 106 | keyPath2=`whereis keytool | awk -F " " '{print $2}'` 107 | [ "${keyPath2}" == "" ] && { logThis "Ok, somethings is wrong. I'll stop now before I make a mess."; exit 1; } 108 | } 109 | 110 | keyGen () { 111 | logThis "Collecting Certificate Info" 112 | echo -n -e "\tType in your FIRST name: " 113 | read fname 114 | echo -n -e "\tType in your LAST name: " 115 | read lname 116 | echo -n -e "\tType in your city: " 117 | read city 118 | echo -n -e "\tType in your state (do not abbreviate): " 119 | read state 120 | echo -n -e "\tType in your country 2 letter code (US): " 121 | read -n 2 country 122 | echo " " 123 | echo " " 124 | 125 | [ "${newPass}" != "" ] && { mypass="${newPass}"; } || { mypass="${keyPass}"; } 126 | keytool -genkey -keystore "${fqdn}".jks -alias tomcat -keyalg RSA -keysize 2048 -storepass "${mypass}" -keypass "${mypass}" -dname "CN=${fname} ${lname}, OU=${fqdn}, O=${fqdn}, L=${city}, S=${state}, C=${country}" 127 | keytool -certreq -keystore "${fqdn}".jks -alias tomcat -keyalg RSA -storepass "${mypass}" -file "${fqdn}".csr 128 | 129 | logThis "${fqdn}.jks has been created" 130 | logThis "${fqdn}.csr has been created. Send this to your 3rd party SSL Cert provider." 131 | echo " " 132 | cat "./${fqdn}.csr" 133 | echo " " 134 | logThis "When you have your .cer file, use './${logtag} import _file_.cer' to complete this script" 135 | logThis "Don't forget to import your root CA BEFORE you import your signed Cert!" 136 | logThis "keytool -import -alias root -keystore ${fqdn}.jks -trustcacerts -file /path/too/ca.pem" 137 | echo " " 138 | echo " " 139 | } 140 | 141 | importCheck () { 142 | # [ "$2" == "" ] && { echo -n "Your .cer file is missing. Do you just want to copy/paste your key? [y|n]: "; } 143 | # read -n 1 copyYesNo 144 | # echo " " 145 | # if [ "${copyYesNo}" == "y" ]; then 146 | # echo "Paste your signed cert key from your 3rd party SSL Cert provider" 147 | # read -n signedCert 148 | # echo "${signedCert}" > "${fqdn}".cer 149 | # fi 150 | certExt=`echo "$2" | rev | cut -b 1-3 | rev` 151 | 152 | logThis "Going to verify your commands." 153 | [ "${2}" == "" ] && { logThis "Your .cer file is missing. Be sure to enter a file name."; exit 1; } 154 | [ ! -e "${2}" ] && { logThis "$2 cannot be found. Be sure it is placed in the same directory as this script ${SCRIPTPATH}"; exit 1; } 155 | [ "${certExt}" != "cer" ] && { logThis "$2 file extension does not end with '.cer'. Please fix so I know you have read the directions"; exit 1; } 156 | 157 | # keyImport 158 | logThis "Ready to import ${2}!" 159 | importNOW=`keytool -import -alias tomcat -keystore "${fqdn}".jks -trustcacerts -file "${2}"` 160 | 161 | [ "${importNOW}" ] && { logThis "Importing ${2} was successful!"; } || { logThis "There was an error. Sorry. *sad trombone*"; exit 1; } 162 | } 163 | 164 | #keyImport () { 165 | # [ "${copyYesNo}" == "y" ] && { myFile="${fqdn}".cer; } || { myFile="$2"; } 166 | # keytool -import -alias tomcat -keystore "${fqdn}".jks -trustcacerts -file "${myFile}" 167 | # keytool -import -alias tomcat -keystore "${fqdn}".jks -trustcacerts -file "${2}" 168 | #} 169 | 170 | case "$1" in 171 | import) 172 | importCheck "$1" "$2" 173 | ;; 174 | generate) 175 | init 176 | confCheck 177 | keyCheck 178 | keyGen 179 | ;; 180 | *) 181 | echo "To use this script, start with './${logtag} generate' to create your csr and jks keystore." 182 | exit 0 183 | esac -------------------------------------------------------------------------------- /VMWare/ubuntuSetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2013-3-28 25 | 26 | # Modified by Justin Rummel 27 | # Version 1.1.0 - 2015-01-21 28 | 29 | ### Description 30 | # Goal is to have a script that performs the basic setup needs for a brand new Ubuntu Server. 31 | 32 | ### Assumptions 33 | # - You are installing the server from Ubuntu's setup assistant, not using VMware's "easy" 34 | # setup assistant. The reason for this is Ubuntu will ask you for a custom hostname. 35 | # - There is no encryption on the volume 36 | # - The Partitioning method is the default "use entire disk w/ LVM" 37 | 38 | # Base Variables that I use for all scripts. Creates Log files and sets date/time info 39 | declare -x SCRIPTPATH="${0}" 40 | declare -x RUNDIRECTORY="${0%/*}" 41 | declare -x SCRIPTNAME="${0##*/}" 42 | 43 | logtag="${0##*/}" 44 | debug_log="disable" 45 | logDate=`date "+%Y-%m-%d"` 46 | logDateTime=`date "+%Y-%m-%d_%H:%M:%S"` 47 | log_dir="/var/log/${logtag}" 48 | LogFile="${logtag}-${logDate}.log" 49 | 50 | # Script Variables 51 | 52 | # Script Functions 53 | verifyRoot () { 54 | #Make sure we are root before proceeding. 55 | [ `id -u` != 0 ] && { echo "$0: Please run this as root."; exit 0; } 56 | } 57 | 58 | logThis () { 59 | # Output to stdout and LogFile. 60 | logger -s -t "${logtag}" "$1" 61 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${LogFile}"; } 62 | } 63 | 64 | init () { 65 | # Make our log directory 66 | [ ! -d $log_dir ] && { mkdir $log_dir; } 67 | 68 | # Now make our log file 69 | if [ -d $log_dir ]; then 70 | [ ! -e "${log_dir}/${LogFile}" ] && { touch $log_dir/${LogFile}; logThis "Log file ${LogFile} created"; logThis "Date: ${logDateTime}"; } 71 | else 72 | echo "Error: Could not create log file in directory $log_dir." 73 | exit 1 74 | fi 75 | echo " " >> "${log_dir}/${LogFile}" 76 | } 77 | 78 | update() { 79 | echo -n "Do you want run 'apt-get update'? [y|n]:" 80 | read -n 1 replySTATIC 81 | echo " " 82 | if [ "${replySTATIC}" == "y" ]; then 83 | logThis "Running apt-get update" 84 | getUpdates=$(sudo /usr/bin/apt-get -qy update > /dev/null) 85 | [ $? != 0 ] && { logThis "apt-get update had an error. Stopping now!"; exit 1; } || { logThis "apt-get update completed successfully."; } 86 | fi 87 | } 88 | 89 | upgrade() { 90 | echo -n "Do you want run 'apt-get dist-upgrade'? [y|n]:" 91 | read -n 1 replySTATIC 92 | echo " " 93 | if [ "${replySTATIC}" == "y" ]; then 94 | logThis "Running apt-get dist-upgrade (this may take some time. Patience.)" 95 | getUpgrades=$(sudo /usr/bin/apt-get -qy dist-upgrade > /dev/null) 96 | [ $? != 0 ] && { logThis "apt-get dist-upgrade had an error. Stopping now!"; exit 1; } || { logThis "apt-get dist-upgrade completed successfully."; } 97 | fi 98 | } 99 | 100 | sshServer() { 101 | sshCheck=$(netstat -natp | grep [s]shd | grep LISTEN | grep -v tcp6) 102 | [ $? != 0 ] && { logThis "openssh-server is NOT installed."; installOpenssh; } || { logThis "openssh-server is running."; } 103 | } 104 | 105 | installOpenssh() { 106 | logThis "Installing openssh-server." 107 | installSSH=$(sudo /usr/bin/apt-get install openssh-server -qy) 108 | [ $? != 0 ] && { logThis "apt-get install openssh-server had an error. Stopping now!"; exit 1; } || { logThis "apt-get install openssh-server completed successfully."; } 109 | } 110 | 111 | curlCLI() { 112 | curlCheck=$(which curl) 113 | [ $? != 0 ] && { logThis "curl is NOT installed."; installCurl; } || { logThis "curl is available."; } 114 | } 115 | 116 | installCurl() { 117 | logThis "Installing curl." 118 | installSSH=$(sudo /usr/bin/apt-get install curl -qy) 119 | [ $? != 0 ] && { logThis "apt-get install curl had an error. Stopping now!"; exit 1; } || { logThis "apt-get install curl completed successfully."; } 120 | } 121 | 122 | setNetwork() { 123 | echo -n "Do you want to set a static IP? [y|n]:" 124 | read -n 1 replySTATIC 125 | echo " " 126 | [ "${replySTATIC}" != "y" ] && { logThis "Keeping DHCP settings."; findName; } || { static; } 127 | } 128 | 129 | static() { 130 | echo -n "Type the IP address for this server: " 131 | read IP 132 | logThis "Setting IP for ${IP}" 133 | echo " " 134 | 135 | echo -n "Type the subnet mask for this server: " 136 | read MASK 137 | logThis "Setting subnet mask for ${MASK}" 138 | echo " " 139 | 140 | echo -n "Type the Gateway for this server: " 141 | read GATE 142 | logThis "Setting Gateway for ${GATE}" 143 | echo " " 144 | 145 | echo -n "Type your DNS servers IP address (separated by a space): " 146 | read DNS 147 | logThis "Setting DNS servers for ${DNS}" 148 | echo " " 149 | 150 | echo -n "Type the DNS Search Name: " 151 | read SEARCH 152 | logThis "Setting DNS Search Name for ${SEARCH}" 153 | echo " " 154 | 155 | echo "Final check!" 156 | echo "address ${IP}" 157 | echo "netmask ${MASK}" 158 | echo "gateway ${GATE}" 159 | echo "dns-nameservers ${DNS}" 160 | echo "dns-search ${SEARCH}" 161 | echo " " 162 | echo -n "Is this correct? ${SETSTATIC} [y|n]: " 163 | read -n 1 replySET 164 | echo " " 165 | [ "${replySET}" != "y" ] && { logThis "You got this far and want to cancel? Lets just stop and be safe."; exit 1; } || { setInterface "${IP}" "${MASK}" "${GATE}" "${DNS}" "${SEARCH}"; } 166 | } 167 | 168 | setInterface () { 169 | logThis "Setting new Static IP address, and restarting eth0" 170 | interface="/etc/network/interfaces" 171 | 172 | echo "# This file describes the network interfaces available on your system" > "${interface}" 173 | echo "# and how to activate them. For more information, see interfaces(5)." >> "${interface}" 174 | echo " " >> "${interface}" 175 | echo "# The loopback network interface" >> "${interface}" 176 | echo "auto lo" >> "${interface}" 177 | echo "iface lo inet loopback" >> "${interface}" 178 | echo " " >> "${interface}" 179 | echo "# The primary network interface" >> "${interface}" 180 | echo "auto eth0" >> "${interface}" 181 | echo "iface eth0 inet static" >> "${interface}" 182 | echo "address ${1}" >> "${interface}" 183 | echo "netmask ${2}" >> "${interface}" 184 | echo "gateway ${3}" >> "${interface}" 185 | echo "dns-nameservers ${4}" >> "${interface}" 186 | echo "dns-search ${5}" >> "${interface}" 187 | echo " " 188 | 189 | echo "Reboot Your Server now! (sudo reboot), then walk through this script again but saying no to all the items already completed." 190 | } 191 | 192 | findName () { 193 | logThis "Finding your IP Address and DNS record" 194 | ipAddress=`ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1` 195 | dnsName=`host "${ipAddress}" | awk -F " " '{print $NF}' | sed 's/\.$//'` 196 | 197 | echo -n "Your IP address is ${ipAddress} with the DNS name ${dnsName} correct? [y|n]: " 198 | read -n 1 replyIP 199 | echo " " 200 | [ "${replyIP}" != "y" ] && { logThis "You just set your IP address, and now it's wrong? Lets just stop and be safe"; exit 1; } || { setName "${dnsName}"; } 201 | } 202 | 203 | setName () { 204 | logThis "Setting your server name with the DNS record of your IP Address" 205 | hosts="/etc/hosts" 206 | hostname="/etc/hostname" 207 | 208 | host=`echo "${dnsName}" | awk -F "." '{print $1}'` 209 | echo "${host}" > "${hostname}" 210 | 211 | echo "127.0.0.1 localhost" > "${hosts}" 212 | echo "127.0.1.1 ${host} ${dnsName}" >> "${hosts}" 213 | echo " " >> "${hosts}" 214 | echo "# The following lines are desirable for IPv6 capable hosts" >> "${hosts}" 215 | echo "::1 localhost ip6-localhost ip6-loopback" >> "${hosts}" 216 | echo "ff02::1 ip6-allnodes" >> "${hosts}" 217 | echo "ff02::2 ip6-allrouters" >> "${hosts}" 218 | 219 | echo "Reboot Your Server now! (sudo reboot)" 220 | } 221 | 222 | verifyRoot 223 | #init 224 | sshServer 225 | curlCLI 226 | update 227 | upgrade 228 | setNetwork 229 | 230 | exit 0 231 | -------------------------------------------------------------------------------- /VMWare/Backup/backupVM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 2012-11-15 25 | 26 | # Modified by Justin Rummel 27 | # Version 1.1.0 - 2014-12-07 28 | 29 | ### Description 30 | # VMWare Fusion Backup 31 | #=========== 32 | # 33 | # The purpose of this script it to provide an automated system for backing up VMWare Fusion VMs that are 34 | # running on OS X. This is achiveved by: 35 | # 1) stop VMs 36 | # 1.5) create a snapshot, trim some old snapshots (if desired) 37 | # 2) tgz to /tmp 38 | # 3) scp to a remote server 39 | # 4) restart VMs 40 | # The concept for this script would be in a production environment for weekly backups 41 | # 42 | # This script is best used after you have established SSH keys between your client and destination server. 43 | # See the SSH-keygen-copy.sh script in our GIT repo 44 | # 45 | # Because we are using SSH to copy our VMs, the keytabs are stored in your user's Home folder. Therefore, 46 | # we need to copy the com.justinrummel.vmware.backup.plist should be stored in ~/Library/LaunchAgents/. 47 | # The plist is set to run on Saturdays at 11pm by default. 48 | 49 | ### Variables 50 | # Log Settings 51 | host=`hostname` 52 | debug_log="enable" 53 | logtag="backupVM" 54 | logDate=`date +"%Y.%m.%d"` 55 | logDateTime=`date +"%Y-%m-%d_%H.%M.%S"` 56 | 57 | log_dir="${HOME}/Library/Logs/${logtag}" 58 | log_runDir="/Volumes/DataHD/${logDate}/" 59 | vmLogFile="${logtag}-${logDate}.log" 60 | vmRunLog="RunningVMs-${logDate}.txt" 61 | 62 | # VM Environment 63 | vmrun="/Applications/VMware Fusion.app/Contents/Library/vmrun" 64 | vmSourcePath="/Users/Shared/VM" 65 | vmRunCount=`"${vmrun}" list | head -n 1 | awk -F ": " '{print $2}'` 66 | vmSnap="true" 67 | vmTrim="true" 68 | vmTrimCount="3" 69 | 70 | # Destination server info 71 | vmDestUser="sadmin" 72 | vmDestServer="server.domain.tld" 73 | vmDestPath="/Volumes/DataHD/VMBackups/" 74 | 75 | 76 | 77 | # Output to stdout and vmLogFile. 78 | logThis () { 79 | logger -s -t "${logtag}" "$1" 80 | [ "${debug_log}" == "enable" ] && { echo "${logDateTime}: ${1}" >> "${log_dir}/${vmLogFile}"; } 81 | } 82 | 83 | init () { 84 | # Make our log directory 85 | [ ! -d $log_dir ] && { mkdir $log_dir; } 86 | [ ! -d $log_runDir ] && { mkdir $log_runDir; } 87 | 88 | # Make now make our log file 89 | if [ -d $log_dir ]; then 90 | [ ! -e "${log_dir}/${vmLogFile}" ] && { touch $log_dir/${vmLogFile}; logThis "Log file ${vmLogFile} created"; logThis "Date: ${logDateTime}"; } 91 | else 92 | echo "Error: Could not create log file in directory $log_dir." 93 | exit 1 94 | fi 95 | echo " " >> "${log_dir}/${vmLogFile}" 96 | } 97 | 98 | ### Used for afp mounts. Now using scp 99 | #vmCheck () { 100 | # logThis "Checking to see if ${vmDestPath} is available" 101 | # [ ! -d "/Volumes${vmDestPath}" ] && { vmDestMount; } 102 | # echo " " >> "${log_dir}/${vmLogFile}" 103 | #} 104 | 105 | ### Used for afp mounts. Now using scp 106 | #vmDestMount () { 107 | # logThis "${vmDestPath} is missing, I'll mount it for you" 108 | # open "${vmDestProtocol}://${vmDestUser}:${vmDestPass}@${vmDestServer}${vmDestPath}" 109 | # echo " " >> "${log_dir}/${vmLogFile}" 110 | #} 111 | 112 | vmServerCheck () { 113 | logThis "Is ${vmDestServer} avaiable? Starting a ping session just to be sure (Not that I don't believe you)." 114 | 115 | rcount=0 116 | until ping -o -t 5 "${vmDestServer}" ; do 117 | let rcount=${rcount}+1 118 | if [ $rcount == "15" ]; then 119 | logThis "Sorry, ${vmDestServer} is not available. Stopping the backup process" 120 | exit 0 121 | fi 122 | ifconfig -a 123 | sleep 1 124 | logThis "${vmDestServer} is not yet reachable via ping, I'll try again." 125 | done 126 | } 127 | 128 | vmDriveCheck () { 129 | logThis "Do we have enough space on our boot drive?" 130 | 131 | HDDavailable=`df -H | head -n 2 | tail -n 1 | awk '{print $4}' | sed 's/G//'` 132 | VMSpace=`du -h -d 1 ${vmSourcePath} | tail -n 1 | awk '{print $1}' | sed 's/G//'` 133 | 134 | logThis "${HDDavailable} > ${VMSpace}" 135 | [[ $HDDavailable > $VMSpace ]] && { logThis "We are good to go!"; } || { logThis "Houston, we may have a problem. You have used a lot of HDD space!"; } 136 | } 137 | 138 | vmListCheck () { 139 | logThis "Checking to see if any VMs are running, and if so stop them" 140 | 141 | if [ "${vmRunCount}" != 0 ]; then 142 | logThis " Found ${vmRunCount} VMs running... lets stop them" 143 | echo " " >> "${log_dir}/${vmLogFile}" 144 | 145 | [ ! -e "${log_runDir}${vmRunLog}" ] && { logThis "${vmRunLog} log file missing, I'll create one"; touch "${log_runDir}${vmRunLog}"; } 146 | 147 | for ((i=1; i <= $vmRunCount; i++)) 148 | do 149 | # get the file name that is running and shut it down. 150 | # We'll save the names in a file to start later 151 | vmFile=`"${vmrun}" list | tail -n $i | head -n 1` 152 | vmFileName=`echo "${vmFile}" | sed 's/.*\///' | sed 's/\.vmwarevm//'` 153 | 154 | # Generating a list first, else if there are to many it may time out and not stop everything 155 | logThis " Adding ${vmFileName} to shutdown list ${vmRunLog}" 156 | echo "${vmFile}" >> "${log_runDir}/${vmRunLog}" 157 | done 158 | echo " " >> "${log_dir}/${vmLogFile}" 159 | 160 | cat "${log_runDir}/${vmRunLog}" | while read shutdownVM; 161 | do 162 | logThis "Shutting down ${shutdownVM}" 163 | "${vmrun}" -T fusion stop "${shutdownVM}" 164 | done 165 | echo " " >> "${log_dir}/${vmLogFile}" 166 | fi 167 | 168 | logThis "No VMs are currently running... lets start the backups" 169 | echo " " >> "${log_dir}/${vmLogFile}" 170 | } 171 | 172 | vmSnapshot () { 173 | logThis "We do VM Snapshots. Not sure why... it just seems like a good idea" 174 | 175 | find "${vmSourcePath}" -name "*.vmwarevm" | while read vmwarevm; 176 | do 177 | # echo "${vmwarevm[0]}" 178 | vmxFile=`echo "${vmwarevm[0]}" | sed 's/.*\///' | sed 's/\.vmwarevm//'` 179 | 180 | logThis " Snapshoting ${vmxFile}" 181 | "${vmrun}" -T fusion snapshot "${vmwarevm}" "${logtag}-${logDateTime}" 182 | 183 | if [ "${vmTrim}" == "true" ]; then 184 | logThis "Snapshot trim is enabled. Lets clear off some old data." 185 | 186 | snapCount=`"${vmrun}" listSnapshots "${vmwarevm}" | grep -c1 "${logtag}"` 187 | logThis " Found ${snapCount} snapshots on ${vmwarevm}, we keep only ${vmTrimCount}" 188 | 189 | if [ "${snapCount}" > "${vmTrimCount}" ]; then 190 | rmSnap=`"${vmrun}" listSnapshots "${vmwarevm}" | grep -m1 "${logtag}"` 191 | "${vmrun}" deletesnapshot "${vmwarevm}" "${rmSnap}" 192 | logThis " Removed snapshot ${rmSnap} from ${vmwarevm}" 193 | fi 194 | fi 195 | 196 | done 197 | echo " " >> "${log_dir}/${vmLogFile}" 198 | } 199 | 200 | vmBackup () { 201 | logThis "Will you backup my VM already!!! Ok... starting now." 202 | 203 | find "${vmSourcePath}" -name "*.vmwarevm" | while read tarVM; 204 | do 205 | # echo "${vmwarevm[0]}" 206 | vmxFile=`echo "${tarVM[0]}" | sed 's/.*\///' | sed 's/\.vmwarevm//'` 207 | 208 | if [ -e "${log_runDir}${host}-${vmxFile}-${logDate}.tgz" ]; then 209 | logThis " ${vmxFile} already exists. I'll skip this part" 210 | else 211 | logThis " Backing up $vmxFile" 212 | tar -cvzf "${log_runDir}${host}-${vmxFile}-${logDate}.tgz" "${tarVM}" 213 | fi 214 | rsync --force --ignore-errors --delete --backup --backup-dir=/"${logDate}" -az -e ssh "${log_runDir}${host}-${vmxFile}-${logDate}.tgz" "${vmDestUser}@${vmDestServer}:${vmDestPath}" 215 | done 216 | echo " " >> "${log_dir}/${vmLogFile}" 217 | } 218 | 219 | vmStart () { 220 | if [ -e "${log_runDir}/${vmRunLog}" ]; then 221 | logThis "We stopped some VMs in order to backup, lets restart them." 222 | 223 | cat "${log_runDir}/${vmRunLog}" | while read restartVM; 224 | do 225 | logThis " Starting ${restartVM}" 226 | "${vmrun}" -T fusion start "${restartVM}" 227 | done 228 | else 229 | logThis "We did not stop any VMs, so we're done" 230 | fi 231 | echo " " >> "${log_dir}/${vmLogFile}" 232 | } 233 | 234 | vmClean () { 235 | logThis "Cleaning up our mess. Removing everything in ${log_runDir}" 236 | echo " " >> "${log_dir}/${vmLogFile}" 237 | rm -rf "${log_runDir}" 238 | } 239 | 240 | init # Create our log files 241 | #vmCheck # Is AFP share available, if not mount. !!!not used anymore, rsync over ssh is better 242 | vmServerCheck # ping for reply on our destination server 243 | vmDriveCheck # HDD check. Won't actually stop the script but good to keep track 244 | vmListCheck # Are any VMs Running, stop them if yes 245 | [[ "${vmSnap}" == "true" ]] && { vmSnapshot; } # Perform a snapshot before tgz => rsync 246 | vmBackup # tgz to /tmp then rsync files 247 | vmStart # start any VMs that were stopped by vmServerCheck 248 | vmClean # remove /tmp folder that hosted our .tgz and Running log file 249 | 250 | exit 0 -------------------------------------------------------------------------------- /General/image_cleaner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2015 Justin Rummel 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/libexec export PATH 23 | 24 | # Backup, Use at your own risk, it's not our fault if you lost data 25 | 26 | # README 27 | # this script does some cleanup in preperation for building an image 28 | # best to run this from single user mode, or at least right before you shutdown (do not use in Target Disk Mode) 29 | # target disk mode functionality to be introduced later 30 | # run this as root, or with sudo rights 31 | 32 | #variables 33 | ADMIN="appleadmin" # change this to whatever your Local Admin is named and you have been using to install software 34 | TARGET_HD="/Volumes/Macintosh HD" 35 | ADMINPATH="/Users/" # path of your Local Admin (/private/var could be for hidden admins) 36 | SETUPAGAIN="disable" # Run the Setup Assistant as if it was brand new out of the box (enable or disable) 37 | ROOTD="disable" # enable if root was used for this image (enable or disable), and you want to clean it up 38 | ADMIN_CLEANUP="enable" # enable if root admin used for this image (enable or disable), and you want to clean it up 39 | SHARED="disable" # enable if you wante to remove everything from the /Users/Shared folder (enable or disable) !!!WARNING!!! see message below 40 | PRIVACY_RESET="enable" # enable if you want to reset all privacy settings on 10.8 or later 41 | DELETE_SWAPFILE="enable" # enable if you want to delete the OS swapfile 42 | DELETE_VOLINFO="enable" # enable if you want to delete the volinfo db 43 | DELETE_SLEEPIMAGE="enable" # enable if you want to delete the OS sleepimage 44 | DELETE_DS_FILES="enable" # enable if you want to globally remove all .DS_Store files on a machine 45 | RESET_BOOTCACHE="enable" # enable if you want to reset (remove) the bootcache.playlist; recreated upon system boot for boot optimization. Can vary and is hardware-dependent 46 | CLEAN_SINGLE_KEXT_CACHE="enable" # enable if you want to clean (delete) all cached kernel extensions (cached kernel code, linked kexts, and some potential kext info dictionaries) 47 | CLEAN_MULTI_KEXT_CACHE="enable" # enable if you want to clean (delete) all multi-cached kernel extensions (multiplus kernel caches and their associated userinfo dictionaries) 48 | EMPTY_BASE_TRASH="enable" # enable to empty trash at the boot level volume 49 | SELF_DESTRUCT="enable" # force script to securely remove itself (default is immediately) 50 | 51 | #set machine names back to generic 52 | #/usr/sbin/scutil --set ComputerName "OSX_Standard_Image" 53 | #/usr/sbin/scutil --set LocalHostName "osximg" 54 | 55 | #enable Setup Assistant 56 | if [ "$SETUPAGAIN" == "enable" ]; then 57 | if [ -e /private/var/db/.AppleSetupDone ]; then 58 | rm -f /private/var/db/.AppleSetupDone 59 | fi 60 | 61 | if [ -e /private/var/db/.AutoBindDone ]; then 62 | rm -f /private/var/db/.AutoBindDone 63 | fi 64 | fi 65 | 66 | #delete swapfiles (these are typically equivalent in size to the physical RAM, in GB, from the target machine) 67 | if [ "$DELETE_SWAPFILE" == "enable" ]; then 68 | rm /private/var/vm/swapfile* 69 | fi 70 | 71 | #delete sleep image for a truly "clean" system 72 | if [ "$DELETE_SLEEPIMAGE" == "enable" ]; then 73 | if [ -e /var/vm/sleepimage ]; then 74 | rm -f /var/vm/sleepimage 75 | fi 76 | fi 77 | 78 | #delete volume info DB 79 | if [ "$DELETE_VOLINFO" == "enable" ]; then 80 | if [ -e /private/var/db/volinfo.database ]; then 81 | rm -f /private/var/db/volinfo.database 82 | fi 83 | fi 84 | 85 | #delete tccutil database if asked for (check for 10.8 first) 86 | OSXREV=`sw_vers -productVersion` 87 | if [ "$OSXREV" == "enable" ]; then 88 | OSXREV=`sw_vers -productVersion` 89 | if [ ${OSXREV:3:1} == 8 ]; then 90 | tccutil reset 91 | fi 92 | fi 93 | 94 | #delete all ds_store files 95 | if [ "$DELETE_DS_FILES" == "enable" ]; then 96 | sudo find . -name *.DS_Store -type f -exec rm {} \; 97 | fi 98 | 99 | #delete the bootcache.playlist file 100 | if [ "$RESET_BOOTCACHE" == "enable" ]; then 101 | if [ -e /var/db/BootCache.playlist ]; then 102 | sudo rm /var/db/BootCache.playlist 103 | fi 104 | fi 105 | 106 | #delete kextcaches 107 | if [ "$CLEAN_SINGLE_KEXT_CACHE" == "enable" ]; then 108 | if [ -e /System/Library/Extensions.kextcache ]; then 109 | sudo rm /System/Library/Extensions.kextcache 110 | fi 111 | fi 112 | 113 | #delete multi-kextcaches 114 | if [ "$CLEAN_MULTI_KEXT_CACHE" == "enable" ]; then 115 | if [ -e /System/Library/Extensions.mkext ]; then 116 | sudo rm /System/Library/Extensions.mkext 117 | fi 118 | fi 119 | 120 | #empty system trash 121 | if [ "$EMPTY_BASE_TRASH" == "enable" ]; then 122 | sudo rm /.Trashes*; 123 | fi 124 | 125 | #cleanup local admin's home dir 126 | if [ "$ADMIN_CLEANUP" == "enable" ]; then 127 | rm -rf ${ADMINPATH}${ADMIN}/Desktop/* 128 | rm -rf ${ADMINPATH}${ADMIN}/Documents/* 129 | rm -rf ${ADMINPATH}${ADMIN}/Library/Caches/* 130 | rm -rf ${ADMINPATH}${ADMIN}/Library/Recent\ Servers/* 131 | rm -rf ${ADMINPATH}${ADMIN}/Library/Logs/* 132 | rm -rf ${ADMINPATH}${ADMIN}/Library/Keychains/* 133 | rm -rf ${ADMINPATH}${ADMIN}/Library/Preferences/ByHost/* 134 | rm -f ${ADMINPATH}${ADMIN}/Library/Preferences/com.apple.recentitems.plist 135 | rm -rf ${ADMINPATH}${ADMIN}/Movies/* 136 | rm -rf ${ADMINPATH}${ADMIN}/Music/* 137 | rm -rf ${ADMINPATH}${ADMIN}/Pictures/* 138 | rm -rf ${ADMINPATH}${ADMIN}/Public/Drop\ Box/* 139 | rm -f ${ADMINPATH}${ADMIN}/.DS_Store 140 | rm -rf ${ADMINPATH}${ADMIN}/.Trash 141 | rm -f ${ADMINPATH}${ADMIN}/.bash_history 142 | rm -rf ${ADMINPATH}${ADMIN}/.ssh 143 | fi 144 | 145 | #cleanup root's home dir 146 | if [ "$ROOTD" == "enable" ]; then 147 | rm -rf /private/var/root/Desktop/* 148 | rm -rf /private/var/root/Documents/* 149 | rm -rf /private/var/root/Downloads/* 150 | rm -rf /private/var/root/Library/Caches/* 151 | rm -rf /private/var/root/Library/Recent\ Servers/* 152 | rm -rf /private/var/root/Library/Logs/* 153 | rm -rf /private/var/root/Library/Keychains/* 154 | rm -rf /private/var/root/Library/Preferences/ByHost/* 155 | rm -f /private/var/root/Library/Preferences/com.apple.recentitems.plist 156 | rm -rf /private/var/root/Public/Drop\ Box/* 157 | rm -f /private/var/root/.DS_Store 158 | rm -rf /private/var/root/.Trash 159 | rm -f /private/var/root/.bash_history 160 | rm -rf /private/var/root/.ssh 161 | fi 162 | 163 | #clean up global caches and temp data 164 | rm -rf /Library/Caches/* 165 | rm -rf /System/Library/Caches/* 166 | rm -f /private/etc/ssh_host* 167 | if [ "$SHARED" == "enable" ]; then 168 | rm -rf /Users/Shared/* #check licenses (i.e. Adobe) and other software may store information at this location 169 | fi 170 | 171 | #clean up Managed preferences 172 | rm -rf /Library/Managed\ Preferences/* 173 | 174 | #network interfaces - this is regenerated on reboot and can differ on different hardware 175 | rm /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist 176 | 177 | #Leopard - cleanup local KDC, see http://support.apple.com/kb/TS1245 178 | rm -rf /private/var/db/.configureLocalKDC 179 | rm -rf /private/var/db/krb5kdc 180 | rm -rf /private/etc/krb5.keytab 181 | #rm -rf /Library/Keychains/System.keychain (Do not destory. Needed if SSID or 802.1x are installed) 182 | 183 | 184 | #log cleanup. We touch the log file after removing it since syslog 185 | #won't create missing logs. 186 | rm /private/var/log/alf.log 187 | touch /private/var/log/alf.log 188 | rm /private/var/log/cups/access_log 189 | touch /private/var/log/cups/access_log 190 | rm /private/var/log/cups/error_log 191 | touch /private/var/log/cups/error_log 192 | rm /private/var/log/cups/page_log 193 | touch /private/var/log/cups/page_log 194 | rm /private/var/log/daily.out 195 | rm /private/var/log/ftp.log* 196 | touch /private/var/log/ftp.log 197 | rm -rf /private/var/log/httpd/* 198 | rm /private/var/log/lastlog 199 | rm /private/var/log/lookupd.log* 200 | rm /private/var/log/lpr.log* 201 | rm /private/var/log/mail.log* 202 | touch /private/var/log/lpr.log 203 | rm /private/var/log/mail.log* 204 | touch /private/var/log/mail.log 205 | rm /private/var/log/monthly.out 206 | rm /private/var/log/run_radmind.log 207 | rm -rf /private/var/log/samba/* 208 | rm /private/var/log/secure.log 209 | touch /private/var/log/secure.log 210 | rm /private/var/log/system.log* 211 | touch /private/var/log/system.log 212 | rm /private/var/log/weekly.out 213 | rm /private/var/log/windowserver.log 214 | touch /private/var/log/windowserver.log 215 | rm /private/var/log/windowserver_last.log 216 | rm /private/var/log/wtmp.* 217 | 218 | #self-destruct -- requires 10.5 or later. This needs to be updated to address Mac OS X 11, but will work for 10.5-10.9. 219 | OSXREV=`sw_vers -productVersion` 220 | if [ "$OSXREV" == "enable" ]; then 221 | OSXREV=`sw_vers -productVersion` 222 | if [ ${OSXREV:3:1} >= 5 ]; then 223 | if [ "$SELF_DESTRUCT" == "enable" ]; then 224 | /usr/bin/srm $0 image_cleaner.sh 225 | fi 226 | fi 227 | fi 228 | -------------------------------------------------------------------------------- /General/PCPdelete.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2015 Justin Rummel 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | # Created by Justin Rummel 24 | # Version 1.0.0 - 11/15/2012 25 | 26 | # Modified by 27 | # Version 28 | 29 | # DESCRIPTION 30 | # This is not used anymore. This was to help clean out test posts to PCP running on Mac OS X 10.6 Server after integration was complete 31 | 32 | # variables for testing 33 | test="disable" # for testing purposes, use enable 34 | 35 | # functions 36 | verifyRoot () { 37 | #Make sure we are root before proceeding. 38 | [ `id -u` != 0 ] && { echo "$0: Please run this as root."; exit 0; } 39 | } 40 | 41 | showIntro () { 42 | # Test Mode disclaimer 43 | echo "\n\c" 44 | [ "${test}" == "enable" ] && { echo "########## Test Mode Enabled ##########\nAll delete commands have been beaten over the head with Chickens.\n\n"; } 45 | 46 | # variables 47 | pcpFiles=`serveradmin settings pcast:shared_filesystem | awk -F "\"" '{print $2}'` 48 | wikiFiles=`serveradmin settings teams:repositoryPath | awk -F "\"" '{print $2}'` 49 | 50 | script=`echo $0 | sed 's/.\///' | awk -F . '{print $1}'` 51 | echo "Now running $script on $HOSTNAME." 52 | 53 | # Checking to see if we are running on OS X Server 54 | OSCheck=`sw_vers -productName | awk -F " " '{print $4}'` 55 | [ ! "$OSCheck" == "Server" ] && { echo "Sorry, this is not OS X Server... no matter what you have running."; exit 1; } 56 | 57 | # Checking for pcast 58 | echo "Testing for 'pcast' service" 59 | pservice=`serveradmin status pcast | grep pcast:state | awk -F \" '{print $2}'` 60 | [ "$pservice" == "RUNNING" ] && { echo "Podcast Producer is running"; } || { echo "This script runs on your PCP server only."; exit 0; } 61 | } 62 | 63 | showOptions () { 64 | if [[ "$OSCheck" == "Server" && "$pservice" == "RUNNING" ]]; then 65 | echo "\n\c" 66 | echo "Please choose one of the following options:" 67 | echo "\t1) List Workflows" 68 | echo "\t2) List Podcasts" 69 | echo "\t3) List Wiki Posts\n" 70 | 71 | echo "Type the number you want to run, or Q to quit, followed by [ENTER]: \c" 72 | read option 73 | else 74 | echo "OSCheck: $OSCheck" 75 | echo "pservice: $pservice" 76 | fi 77 | 78 | #set -xv 79 | case $option in 80 | 1) 81 | clear 82 | workflowList 83 | ;; 84 | 2) 85 | clear 86 | podcastList 87 | ;; 88 | 3) 89 | clear 90 | wikiList 91 | ;; 92 | *) 93 | exit 1 94 | esac 95 | } 96 | 97 | workflowList () { 98 | ########## 99 | # Perform a find to get each plist file and grab the Name and UUID (which will be copy/paste to delete) 100 | ########## 101 | echo "\n\c" 102 | echo "Now listing Workflow names and UUID's\n" 103 | 104 | ########## 105 | # It would be nice to get this info from the db.sqlite3 database, however it does not store the Name of the workflow. 106 | ########## 107 | # 108 | # workflowID=`sqlite3 ${pcpFiles}/Server/db.sqlite3 "SELECT id FROM workflows"'` 109 | # workflowPATH=`sqlite3 ${pcpFiles}/Server/db.sqlite3 "SELECT uuid FROM workflows"'` 110 | # echo "\n\c" 111 | # [ "${workflows}" == "" ] && { echo "There are no Podcasts posts to delte."; exit 0; } 112 | # [ -d $pcpFiles ] && { echo "$workflows"; } 113 | 114 | find "${pcpFiles}/Server/Workflows/" -name "*.pwf" | while read info; do 115 | workName=`PlistBuddy -c "Print Name" "${info}/Contents/Info.plist"` 116 | workUUID=`PlistBuddy -c "Print UUID" "${info}/Contents/Info.plist"` 117 | printf "\"%s\" - (%s)\n" "$workName" "$workUUID" 118 | done 119 | 120 | echo "\n\c" 121 | echo "Copy/Paste an UUID to delete, or press Q to quit to the main menu, followed by [ENTER]: \c" 122 | read deleteUUID 123 | 124 | ########## 125 | # Are you sure you want to delete? 126 | ########## 127 | # Check entry 128 | [[ "$deleteUUID" == "q" || "$deleteUUID" == "Q" ]] && { clear; showOptions; } 129 | 130 | # When deleting a Podcast, read the number entered by the User 131 | if [ "$deleteUUID" ]; then 132 | deleteWorkTitle=`PlistBuddy -c "Print Name" "${pcpFiles}/Server/Workflows/${deleteUUID}.pwf/Contents/Info.plist"` 133 | echo "You picked UUID $deleteUUID - \"${deleteWorkTitle}\". Are you sure you want to delete this? [Type \"YES\"]: \c" 134 | read verifyWID 135 | fi 136 | 137 | # Verify that we REALLY want to delete the Podcast 138 | if [ "$verifyWID" == "YES" ]; then 139 | [ "$test" == "enable" ] && { echo "Chicken: skipped --deleteworkflow $deleteUUID"; } || { podcast --deleteworkflow --workflow_uuid "$deleteUUID"; } 140 | [ "$test" == "enable" ] && { echo "Chicken: skipped --disablefeed $deleteUUID"; } || { podcast --disablefeed --feed_uuid "$deleteUUID"; } 141 | [ "$test" == "enable" ] && { echo "Chicken Scratch"; } || { echo "\"$deleteWorkTitle\" has been deleted"; } 142 | showOptions 143 | else 144 | echo "Verification failed. You must type \"YES\" (without the quotes)\n\n" 145 | fi 146 | } 147 | 148 | podcastList () { 149 | ########## 150 | # Performing a SQL search to get the ID and Title. 151 | ########## 152 | podcasts=`sqlite3 "${pcpFiles}/Server/db.sqlite3" "SELECT ID, TITLE FROM episodes" | awk -F "|" '{print $1 ") " $2}'` 153 | echo "\n\c" 154 | [ "${podcasts}" == "" ] && { echo "There are no Podcasts posts to delete. Press Q to quit to the main menu followed by [ENTER]: \c"; read; clear; showOptions; } 155 | [ -d "$pcpFiles" ] && { echo "$podcasts"; } 156 | echo "\n\c" 157 | echo "Pick an ID to delete, or press Q to quit to the main menu, followed by [ENTER]: \c" 158 | read deleteID 159 | 160 | ########## 161 | # Are you sure you want to delete? 162 | ########## 163 | # Check entry 164 | [[ "$deleteID" == "q" || "$deleteID" == "Q" ]] && { clear; showOptions; } 165 | 166 | # When deleting a Podcast, read the number entered by the User 167 | if [ "$deleteID" ]; then 168 | deleteTitle=`sqlite3 "${pcpFiles}/Server/db.sqlite3" "SELECT TITLE FROM episodes WHERE ID='${deleteID}'"` 169 | echo "You picked #$deleteID - \"${deleteTitle}\". Are you sure you want to delete this? [Type \"YES\"]: \c" 170 | read verifyID 171 | fi 172 | 173 | # Verify that we REALLY want to delete the Podcast 174 | if [ "$verifyID" == "YES" ]; then 175 | # Now lets delete within the PCP Library 176 | deleteUUID=`sqlite3 "${pcpFiles}/Server/db.sqlite3" "SELECT UUID FROM episodes WHERE ID='${deleteID}'"` 177 | deleteDate=`sqlite3 "${pcpFiles}/Server/db.sqlite3" "SELECT strftime('%Y-%m-%d', created_at) FROM episodes WHERE ID='${deleteID}'"` 178 | echo "Removing: ${pcpFiles}/Content/${deleteDate}/${deleteUUID}.prb" 179 | [ "$test" == "enable" ] && { echo "Chicken: ${pcpFiles}/Content/${deleteDate}/${deleteUUID}.prb"; } || { rm -rf "${pcpFiles}/Content/${deleteDate}/${deleteUUID}.prb"; } 180 | 181 | # Update Library 182 | [ "$test" == "enable" ] && { echo "Chicken: pcastconfig --sync_library"; } || { pcastconfig --sync_library; } 183 | [ "$test" == "enable" ] && { echo "Chicken Scratch"; } || { echo "\"$deleteTitle\" has been deleted"; } 184 | showOptions 185 | else 186 | echo "Verification failed. You must type \"YES\" (without the quotes)\n\n" 187 | fi 188 | } 189 | 190 | wikiList () { 191 | # Check to see if Wiki still exists, if yes... delete 192 | # set -x 193 | # wikiGroup=`PlistBuddy ${pcpFiles}/Server/Workflows/${deleteUUID}.pwf/Contents/Resources/accounts.plist -c "Print" | grep URL | awk -F " " '{print $3}' | awk -F "/" '{print $5}'` 194 | # echo "${wikiFiles}/Groups/${wikiGroup}/weblog/" 195 | 196 | wiki=`sqlite3 "${wikiFiles}/globalIndex.db" "SELECT uid, title FROM pages WHERE disabled=0" | awk -F "/" '{print $4}' | awk -F "|" '{print $1 ") " $2}' | grep -v welcome` 197 | echo "\n\c" 198 | [ "${wiki}" == "" ] && { echo "There are no Wiki posts to delete. Press Q to quit to the main menu followed by [ENTER]: \c"; read; clear; showOptions; } 199 | echo "${wiki}" 200 | echo "\n\c" 201 | echo "Copy/Paste the five-digit hash you want to delete, or press Q to quit to the main menu followed by [ENTER]: \c" 202 | read wikiID 203 | 204 | ########## 205 | # Are you sure you want to delete? 206 | ########## 207 | # Check entry 208 | [[ "$wikiID" == "q" || "$wikiID" == "Q" ]] && { clear; showOptions; } 209 | 210 | # When deleting a Wiki Post, read the hash entered by the User. This has is the same as you seen in the URL when looking at an individual post. 211 | if [ "$wikiID" ]; then 212 | deleteWiki=`sqlite3 "${wikiFiles}/globalIndex.db" "SELECT title FROM pages WHERE uid LIKE '%${wikiID}'"` 213 | echo "You picked \"${deleteWiki}\". Are you sure you want to delete this? [Type \"YES\"]: \c" 214 | read verifyPath 215 | fi 216 | 217 | if [ "$verifyPath" == "YES" ]; then 218 | deletePath=`sqlite3 "${wikiFiles}/globalIndex.db" "SELECT path FROM pages WHERE uid LIKE '%${wikiID}'"` 219 | sqlite3 "${wikiFiles}/globalIndex.db" "UPDATE pages SET disabled=1 WHERE uid LIKE '%${wikiID}'" 220 | [ "$test" == "enable" ] && { echo "Chicken: ${deletePath}"; } || { rm -rf "${deletePath}"; } 221 | [ "$test" == "enable" ] && { echo "Chicken Scratch"; } || { echo "\"$deleteWiki\" has been deleted"; } 222 | showOptions 223 | else 224 | echo "Verification failed. You must type \"YES\" (without the quotes)\n\n" 225 | fi 226 | } 227 | 228 | readme () { 229 | echo " 230 | PCPdelete.sh README 231 | README Last Updated: 2/13/2011 232 | 233 | Description 234 | Individuals who perform integrations of Podcast Producer (PCP) or who are administrators of their PCP environments and begin testing workflows find themselves with a server that contains media files which are no longer suited for a production environment. Integrators/SysAdmins also know that the current tools for removing Podcasts are limited to a minus button within Wiki/Blog (which does not remove the actual PNG/MOV files, nor removes them from the PCP Library). In order to fully delete Podcasts, PCPdelete was created. 235 | 236 | Solution 237 | PCPdelete provides a Command line interface that allows you to delete from three different selections: 238 | 239 | 1) List Workflows 240 | 2) List Podcasts 241 | 3) List Wiki Posts 242 | 243 | How To 244 | 1. Workflows 245 | Function: This section will list all the available workflows within your PCP environment. The script looks inside your {PCPLibrary}/Server/Workflows/ and finds all the "pwf" files, then print's their Names and UUIDs. Copy/Paste the UUID and the script performs "podcast --deleteworkflow --workflow_uuid" and "podcast --disablefeed --feed_uuid" to ensure the Workflow has been deleted and all the associated RSS feeds are updated. 246 | 247 | Logic: Now normally I would like to pull information from a database, however, the db.sqlite3 for workflows does not provide the name... only the ID, UUID, and Bundle Path (among other items). Future release would be nice to get the correct BASH syntax and perform a PlistBuddy on the bundle_path field. 248 | 249 | 2. Podcasts 250 | Function: Even though this is listed for Podcasts, it only effects the PCP Library, not the actual Wiki/Blog page that your users see. This is needed because if anyone actually dug into the PCP Library, they would be able to find all the test posts (or posts that were deleted for one reason or another). The unfortunate thing is I cannot find any link between Wiki/Blog and the PCP Library within the OS or any SQLite3 databases. 251 | 252 | 3. Wiki Posts 253 | Function: The Wiki section of this script is needed because the minus button within the Wiki/Blog URL only deletes the page, not the media files (PNG/MOV). There are a lot of sqlite3 commands against your Collaboration/globalIndex.db database, but in short it performs an UPDATE command that disables the post, then deletes all the files of that page. 254 | " 255 | exit 0 256 | } 257 | 258 | [ "$1" == "help" ] && { readme; } 259 | 260 | verifyRoot 261 | showIntro 262 | showOptions 263 | 264 | exit 0 265 | --------------------------------------------------------------------------------