melawy-site/push.sh

34 lines
534 B
Bash
Raw Normal View History

2023-10-31 14:50:36 +05:00
#!/bin/bash
2024-01-05 21:56:30 +05:00
cd $(dirname $0)
2023-12-12 11:52:13 +05:00
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
2023-12-12 11:56:55 +05:00
git='work'
2023-12-12 11:52:13 +05:00
fi
else
ping -c 1 192.168.1.250
if [[ $? == 0 ]]; then
ip=$ip2
2023-12-12 11:56:55 +05:00
git='origin'
2023-12-12 11:52:13 +05:00
fi
fi
2024-02-09 13:47:16 +05:00
git add . && git commit -m "Update"
git push $git
2023-10-31 14:50:36 +05:00
2023-12-12 11:52:13 +05:00
ssh ${ip} -f '~/update-site.sh'
status=$?
2023-12-09 02:41:32 +05:00
2023-10-31 14:50:36 +05:00
echo "Ready"
2023-12-12 11:52:13 +05:00
if [ "$status" == 0 ]; then
sleep 5
kill $(ps x | grep konsole | grep $0 | awk '{print $1}')
fi