#!/bin/bash cd $(dirname $0) ip1="10.120.152.1" ip2="192.168.1.250" ip r | grep 10.120.152.1 if [[ $? == 0 ]]; then ping -c 1 10.120.152.1 if [[ $? == 0 ]]; then ip=$ip1 git='work' fi else ping -c 1 192.168.1.250 if [[ $? == 0 ]]; then ip=$ip2 git='origin' fi fi if [ -f ".git/index.lock" ]; then rm ".git/index.lock" fi git add . git commit -m "Update" git push $git ssh ${ip} -f '~/update-lerafoxqueen.sh' status=$? echo "Finish!"