Skip to content

Instantly share code, notes, and snippets.

@tsprlng
Created June 13, 2016 11:12
Show Gist options
  • Save tsprlng/0b4b0865f4c9e7de372f3f29fb2b1a0a to your computer and use it in GitHub Desktop.
Save tsprlng/0b4b0865f4c9e7de372f3f29fb2b1a0a to your computer and use it in GitHub Desktop.
¿Sufficiently? paranoid deploy script
# Allow the 'deployer' key to run only the redeploy script; pass the given arguments (i.e. service name) to the script
# e.g. $ ssh deployer@server restartable-thing
#
command="/home/deployer/redeploy.sh $SSH_ORIGINAL_COMMAND",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa «public-key» deployer@ci-server
#!/bin/bash
if [ $(/usr/bin/whoami) == 'deployer' ]; then
# auto-escalate -- run this same script as root
exec /usr/bin/sudo $0 $1
fi
if [ $1 == 'restartable-thing' ]; then
# run restart script with empty environment
/usr/bin/env -i /usr/sbin/service restartable-thing restart
else
echo 'What are you talking about?'
exit 4
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment