Skip to content

Instantly share code, notes, and snippets.

@Sanne
Created October 3, 2023 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sanne/7abc84cee6c7391efcbe6ba4f42c6aed to your computer and use it in GitHub Desktop.
Save Sanne/7abc84cee6c7391efcbe6ba4f42c6aed to your computer and use it in GitHub Desktop.
Networkmanager listeners to reconfigure my local Maven proxies
#!/bin/sh
# Store as /etc/NetworkManager/dispatcher.d/10-script.sh
# make the script executable & owned by root. (protect it too!)
# Will trigger on up/down events of the selected network
HOME_CONNECTION_ID="TanaUB6"
LOG=/home/sanne/.m2/track-wifi-status-change
# echo "################" >> $LOG
# env >> $LOG
# echo "env HOME_CONNECTION_ID:" >> $LOG
# echo CONNECTION_ID >> $LOG
if [ "$CONNECTION_ID" = "$HOME_CONNECTION_ID" ]; then
case $NM_DISPATCHER_ACTION in
up)
# echo "## identified up event" >> $LOG
cp /home/sanne/.m2/home-settings.xml /home/sanne/.m2/settings.xml
;;
down)
# echo "## identified down event" >> $LOG
rm /home/sanne/.m2/settings.xml
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment