Skip to content

Instantly share code, notes, and snippets.

@monksy
Last active February 22, 2016 15:15
Show Gist options
  • Select an option

  • Save monksy/c288d3a9f8d14dddd65b to your computer and use it in GitHub Desktop.

Select an option

Save monksy/c288d3a9f8d14dddd65b to your computer and use it in GitHub Desktop.
This gist is responsible for upgrading a system service (systemd) and going into the folder by it's specified user and performing a git pull. After the pull occures bring the service back up.
#! /bin/sh
if [ $# -lt 3 ]; then
echo "No arguments supplied."
echo " Example: upgradeFoldByBash: [Service name] [service account] [folder]"
exit 1
fi
echo "Stopping the $1 Service"
systemctl stop $1
echo "Performing the update."
cd "$3"
sudo -u "$2" git pull
echo "Restarting the $1 Service"
systemctl start $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment