Last active
November 9, 2025 14:50
-
-
Save aarblaster/903f0cd330c0edd4916b1976d37abb2d to your computer and use it in GitHub Desktop.
A zsh script to reset troublesome ports on MacOS.
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
| # etc_reset.zsh | |
| # Version: 4.0 | |
| # | |
| # A script for resetting all ports and protocols for ETC software. | |
| # Designed particularly for use with ETC Concert. | |
| # | |
| # Created by Anthony Arblaster on 18 February 2025. | |
| # | |
| # Copyright Anthony Arblaster 2025. | |
| # – Web: https://codebyanthony.com | |
| # – Mastodon: https://mastodonapp.uk/@aarblaster | |
| # – GitHub: https://github.com/aarblaster | |
| # | |
| # Licenced with MIT Licence. | |
| #!/bin/zsh | |
| # Run reset on common ETC used ports. | |
| function etc_reset() { | |
| autoload -U colors && colors # All the colours | |
| # Helper: live progress while waiting for SLPD to stop | |
| wait_for_slpd_stop() { | |
| local max_wait=10 # seconds | |
| local interval=0.2 | |
| local elapsed=0 | |
| local bar_length=20 | |
| printf "Waiting for SLPD to stop: " | |
| while pgrep -x "slpd" >/dev/null && (( $(echo "$elapsed < $max_wait" | bc -l) )); do | |
| local progress=$((elapsed * bar_length / max_wait)) | |
| local filled=$(printf "%0.s#" $(seq 1 $progress)) | |
| local empty=$(printf "%0.s-" $(seq 1 $((bar_length - progress)))) | |
| printf "\rWaiting for SLPD to stop: [%s%s]" "$filled" "$empty" | |
| sleep $interval | |
| elapsed=$(echo "$elapsed + $interval" | bc) | |
| done | |
| echo "" | |
| } | |
| # Helper: live progress while waiting for SLPD to start | |
| wait_for_slpd_start() { | |
| local max_wait=10 | |
| local interval=0.2 | |
| local elapsed=0 | |
| local bar_length=20 | |
| printf "Waiting for SLPD to start: " | |
| while ! pgrep -x "slpd" >/dev/null && (( $(echo "$elapsed < $max_wait" | bc -l) )); do | |
| local progress=$((elapsed * bar_length / max_wait)) | |
| local filled=$(printf "%0.s#" $(seq 1 $progress)) | |
| local empty=$(printf "%0.s-" $(seq 1 $((bar_length - progress)))) | |
| printf "\rWaiting for SLPD to start: [%s%s]" "$filled" "$empty" | |
| sleep $interval | |
| elapsed=$(echo "$elapsed + $interval" | bc) | |
| done | |
| echo "" | |
| } | |
| echo "$fg_bold[blue]Checking SLPD status... $reset_color" | |
| if pgrep -x "slpd" >/dev/null; then | |
| echo "SLPD is running. Stopping it..." | |
| /usr/local/bin/stopslpd | |
| # Wait until it really stops (or timeout) | |
| wait_for_slpd_stop | |
| if pgrep -x "slpd" >/dev/null; then | |
| echo "$fg_bold[red]Error: SLPD is still running. Try again. $reset_color" | |
| return 1 | |
| else | |
| echo "SLPD stopped successfully." | |
| fi | |
| else | |
| echo "SLPD was not running." | |
| fi | |
| echo "$fg_bold[blue]Starting SLPD...$reset_color" | |
| /usr/local/bin/slpd &>/dev/null & | |
| wait_for_slpd_start | |
| if pgrep -x "slpd" >/dev/null; then | |
| echo "$fg_bold[green]SLPD started.$reset_color" | |
| else | |
| echo "$fg_bold[red]Error: Failed to start SLPD.$reset_color" | |
| return 1 | |
| fi | |
| } | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the original script that is used in Terminal to reset ETC services and ports if you are having problems. This is in my original post here.
Feel free to use or mod. Or if you'd rather a little application you can go here.