This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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="" |
NewerOlder