1
Fork 0

firefox: proxy auto-config

This commit is contained in:
Alan Faubert 2019-07-23 22:36:17 -04:00
parent 71686bef84
commit 385f9580d4
3 changed files with 11 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/firefox/proxies
/firefox/*.proxy
/gcloud
/git/.git-credentials
/git/github_token

View File

@ -4,6 +4,7 @@ My config files for various things. Use `config.sh` to automate the setup of sev
Things that are not checked in but which should live in this directory:
- `firefox/proxies/`
- `gcloud/`
- `git/.git-credentials`
- `git/github_token`

View File

@ -1,6 +1,7 @@
#!/bin/bash
ROOT="$(dirname "$(readlink -e "$0")")"
ROOTWIN="$(wslpath -w "$ROOT")"
ROOTWINSLASH="$(wslpath -m "$ROOT")"
while :; do
ACTION="$(whiptail --menu '' 22 60 15 \
bash- 'Bash' bash-2path ' Set up 2path.sh script' bash-completion ' Set up ~/.bash_completion.d/' bash-git ' Set up Git status in prompt string' \
@ -15,7 +16,7 @@ while :; do
apt- 'apt' apt-refresh ' update/upgrade/autoremove/autoclean' apt-fakeroot ' Install and use fakeroot-tcp' apt-jq ' Install jq' apt-make ' Install make' \
docker- 'Docker' docker-cli ' Install CLI' docker-relay ' Install relay (WSL)' \
wsl- 'WSL' wsl-win ' Create ~/win symlink to %USERPROFILE%' wsl-hosts ' Create /etc/hosts symlink to system' \
firefox- 'Firefox' firefox-win ' Create profile user.js files (Windows)' \
firefox- 'Firefox' firefox-proxy-win ' Create snippets for proxy configs (Windows)' firefox-win ' Create profile user.js files (Windows)' \
win- 'Windows' win-scancode-map ' Swap caps lock and context key' \
--notags --default-item "$ACTION" 3>&2 2>&1 1>&3-)"
case "$ACTION" in
@ -159,12 +160,17 @@ while :; do
sudo rm -rf /etc/hosts &&
sudo ln -s /c/Windows/System32/drivers/etc/hosts /etc/hosts
;;
firefox-proxy-win)
rm -f "$ROOT"/firefox/*.proxy
mapfile -t PROXIES < <(ls "$ROOT"/firefox/proxies -p | grep -v /)
for PROXY in ${PROXIES[@]}; do echo 'user_pref("network.proxy.autoconfig_url", "'file:///"$ROOTWINSLASH"/firefox/proxies/"$PROXY"$'");\nuser_pref("network.proxy.type", 2);' > "$ROOT"/firefox/$PROXY.proxy; done
;;
firefox-win)
PROFILE_DIR="$(wslpath "$(cmd.exe /c echo %APPDATA%\\Mozilla\\Firefox\\Profiles | tr -d '\r')")"
mapfile -t PROFILES < <(ls "$PROFILE_DIR")
PROFILES_ARGS=()
for ((i=0; i < ${#PROFILES[@]}; i++)); do PROFILES_ARGS[2*i]="${PROFILES[$i]}"; PROFILES_ARGS[2*i+1]="${PROFILES[$i]}"; done
mapfile -t TEMPLATES < <(ls "$ROOT"/firefox)
mapfile -t TEMPLATES < <(ls -p "$ROOT"/firefox | grep -v /)
TEMPLATES_ARGS=()
for ((i=0; i < ${#TEMPLATES[@]}; i++)); do TEMPLATES_ARGS[2*i]="${TEMPLATES[$i]}"; TEMPLATES_ARGS[2*i+1]="${TEMPLATES[$i]}"; done
while :; do