This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect output to printlog function to have printlog generate logger output and stdout | |
# Finish script with finalizelog to append cat of TEMP_LOG to LOG_FILE and remove TEMP_LOG | |
# Example Usage: | |
# printf "Current working directory: %s" "$(pwd)" | printlog | |
# ... | |
# finalizelog; exit 0 | |
export LOG_FILE="" | |
export TEMP_LOG="/private/tmp/$(basename ${LOG_FILE})" | |
export LOG_TAG="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iterate through users and perform some tasks. | |
# Variables and functions that need to be accesible in subshells must be exported (duh). | |
# Enclose arguments in single-quotes to preserve bash internal variables, etc. | |
# Example Usage: | |
# userIteration 'remove "$HOME/Library/Containers/com.microsoft.Excel"' | |
userIteration() { | |
for ITERATED_USER in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do | |
su $ITERATED_USER -c "$*" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rsync a file, check that backup was successful, and send a message to the printlog function | |
# Printlog function is available at https://gist.github.com/bwmorales/86a1a8c4ec51c9e2ffba1499a2c211e0 | |
# Example Usage: | |
# backup $HOME/Documents/myfile.txt | |
export TODAY=$(date +"%Y-%m-%d") | |
backup() { | |
if [[ -e "${1}" ]]; then | |
rsync -aE "${1}" "${1}.${TODAY}.bak" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################################################### | |
# Copyright 2017 Benjamin Moralez # | |
# # | |
# Licensed under the Apache License, Version 2.0 (the "License"); # | |
# you may not use this file except in compliance with the License. # | |
# You may obtain a copy of the License at # | |
# # | |
# http://www.apache.org/licenses/LICENSE-2.0 # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER_FILES=( | |
'~/Library/Caches/Google/Chrome' | |
'/Library/Application Support/Google/Chrome/Default/Application Cache' | |
'Library/Application Support/Google/Chrome/Default/Cookies' | |
' ' | |
) | |
SYSTEM_FILES=( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Remove Microsoft Office 2016 from macOS | |
# Store file in a place that is readable by all users | |
export LOG_FILE="/Library/Logs/Microsoft/uninstall.log" | |
export TODAY=$(date +"%Y-%m-%d") | |
export RED='\033[0;31m' | |
export GREEN='\033[0;32m' | |
export YELLOW='\033[0;33m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/say "This test worked." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE: ./rmSMB_Illegals.sh path | |
# Find searches through each file on a filesystem and passes the filenames to a | |
# function that tests for the presence of illegal characters and remediates. | |
# Bad characters are either removed or replaced with a ``-''. | |
# This has been tested on APFS on macOS 10.13.5. It'd be pretty safe to run this | |
# on a mounted volume, but it'd be nicer to test on Synology Linux and have it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/sbin/route get 1.1.1.1 | /usr/bin/grep 'interface: ' | /usr/bin/sed 's/.*interface: //' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example given with Wireshark. Script tests ping times for Wireshark's mirrors and selects the fastest. | |
MIRRORS=( | |
'1.as.dl.wireshark.org' | |
'1.eu.dl.wireshark.org' | |
'1.na.dl.wireshark.org' | |
'2.na.dl.wireshark.org' | |
# 'www.wireshark.org' |
OlderNewer