Last active
November 18, 2021 15:45
-
-
Save donalod/ecba980a8cadb58659afbf25703718b0 to your computer and use it in GitHub Desktop.
pansift_demo_throttle.sh
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 | |
# This relies on the throttle.applescript | |
# https://gist.github.com/donalod/7c0a63df318aff3739e72f7ad9ec3854 | |
# Run it via crontab BUT YOU MUST ALLOW CRON IN "SECURITY & PRIVACY / ACCESSIBILITY" | |
# * */2 * * * /Users/administrator/pansift_demo_throttle.sh >/tmp/stdout.log 2>/tmp/stderr.log | |
timestamp=$(date "+%Y%m%dT%H%M%S%z") | |
echo "Starting at $timestamp" | |
# Initial wait for randomness | |
echo "Turning off Network Link Conditioner in case it was left on :)" | |
mode=OFF osascript throttle.applescript | |
declare -a profiles=("Pansift_Demo_300_30_1" "Pansift_Demo_200_20_2" "Pansift_Demo_100_10_3") | |
index="$(($RANDOM % 2))" | |
echo "Choosing profile position $index" | |
selected_profile="${profiles[$index]}" | |
echo "Selecting profile $selected_profile" | |
initial_wait="$((1 + $RANDOM % 10))" | |
echo "Sleeping for $initial_wait seconds..." | |
sleep $initial_wait | |
echo "Enabling Pansift_Demo Network Link Conditioner profile" | |
mode="$selected_profile" osascript throttle.applescript | |
run_for="$((1 + $RANDOM % 10))" | |
echo "Running for $run_for seconds..." | |
sleep $run_for | |
echo "Disabling Pansift_Demo Network Link Conditioner profile" | |
mode=OFF osascript throttle.applescript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment