반응형
#!/bin/bash

read -p "Proxy On(1)? Off(2)? " ProxyOnOff

ProxyServerSetting() {
    networksetup -setwebproxy Wi-Fi ${1} ${2}
    networksetup -setwebproxystate Wi-Fi on
    networksetup -setsecurewebproxy Wi-Fi ${1} ${2}
    networksetup -setsecurewebproxystate Wi-Fi on
}

printProxyState() {
    echo -e "\x1b[31m[ web proxy state ]\x1b[0m"
    networksetup -getwebproxy Wi-Fi | head -3
    echo -e "\n\x1b[31m[ web secure proxy state ]\x1b[0m"
    networksetup -getsecurewebproxy Wi-Fi | head -3
}

if [[ ${ProxyOnOff} -eq 1 ]]
then
    read -p "ProxyServer Default(1 or Enter) or Change(2)? " ProxyServer
    if [[ ${ProxyServer} -eq 1 ]]||[[ ${ProxyServer} = "" ]]
    then
        ProxyServer="localhost"
        read -p "ProxyPort Default(1 or Enter) or Change(2)?" ProxyPort
        if [[ ${ProxyPort} -eq 1 ]]||[[ ${ProxyPort} = "" ]]
        then
            ProxyPort=8080
            ProxyServerSetting ${ProxyServer} ${ProxyPort}
            printProxyState
        elif [[ ${ProxyPort} -eq 2 ]]
        then
            read -p "ProxyPort? " ProxyPort
            ProxyServerSetting ${ProxyServer} ${ProxyPort}
            printProxyState
        fi
    elif [[ ${ProxyServer} -eq 2 ]]
    then
        read -p "ProxyServer? " ProxyServer
        read -p "ProxyPort Default(1 or Enter) or Change(2)?" ProxyPort
        if [[ ${ProxyPort} -eq 1 ]]||[[ ${ProxyPort} = "" ]]
        then
            ProxyPort=8080
            ProxyServerSetting ${ProxyServer} ${ProxyPort}
            printProxyState
        elif [[ ${ProxyPort} -eq 2 ]]
        then
            read -p "ProxyPort? " ProxyPort
            ProxyServerSetting ${ProxyServer} ${ProxyPort}
            printProxyState
        fi
    fi
elif [[ ${ProxyOnOff} -eq 2 ]]
then
    networksetup -setwebproxystate Wi-Fi off
    networksetup -setsecurewebproxystate Wi-Fi off
    printProxyState
fi

 

◼︎Proxy On

 

◼︎Proxy Off

 

반응형

+ Recent posts