update server bash function

reference: https://gist.github.com/JeffreyWay/1525217