Last active
August 29, 2015 14:16
-
-
Save FeroVolar/1e65c526d46df0d81eab to your computer and use it in GitHub Desktop.
Remote shell commands execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ssh remoteserver.com 'bash -s' < commands.sh | |
# | |
## commands.sh example | |
sudo su | |
cd /web/remoteserver.com/ | |
git remote update | |
LOCAL=$(git rev-parse @) | |
REMOTE=$(git rev-parse @{u}) | |
BASE=$(git merge-base @ @{u}) | |
if [ $LOCAL = $REMOTE ]; then | |
echo "Up-to-date - ok" | |
elif [ $LOCAL = $BASE ]; then | |
echo "Need to pull..." | |
git pull | |
/etc/init.d/ghost restart | |
elif [ $REMOTE = $BASE ]; then | |
echo "Need to push on server." | |
else | |
echo "Diverged" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment