Skip to content

Instantly share code, notes, and snippets.

@rashkur
Last active November 26, 2015 11:11
Show Gist options
  • Save rashkur/5e958547f5f1e56c2c03 to your computer and use it in GitHub Desktop.
Save rashkur/5e958547f5f1e56c2c03 to your computer and use it in GitHub Desktop.
update remote nginx configs from gitlab hook
...
if repo_path.include? "YOUR_REPO.git"
system('/some/path/update-front.sh')
end
...
...
rem_user ALL = NOPASSWD: /etc/init.d/openresty reload
#!/bin/bash
HOME_DIR="/some/path"
CMD_LINE="cd /etc/nginx && git pull && sudo /etc/init.d/openresty reload"
SERVER_LIST=(front1.example.com front2.example.com front3.example.com front4.example.com)
REMOTE_USER="rem_user"
KEY_FILE="$HOME_DIR/id_rsa"
echo "Got new commit at $(TZ='Europe/Kiev' date +'%Y/%d/%m %H:%M:%S')" >> $HOME_DIR/update_front.log
for SERVER in "${SERVER_LIST[@]}" ; do ssh -o StrictHostKeyChecking=no -i "$KEY_FILE" -t -t "$REMOTE_USER"@"$SERVER" "$CMD_LINE" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment