Skip to content

Instantly share code, notes, and snippets.

@andymac4182
Last active June 3, 2018 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andymac4182/52b61711473da47e0aa46e178691db92 to your computer and use it in GitHub Desktop.
Save andymac4182/52b61711473da47e0aa46e178691db92 to your computer and use it in GitHub Desktop.
#!/bin/bash
packageId=$( get_octopusvariable "Octopus.Action.Package.PackageId" )
echo Package Id is $packageId
chmod +x $packageId
if [ -e /lib/systemd/system/$packageId.service ]
then
echo stopping service
sudo systemctl stop $packageId.service
fi
echo installing service
sed -i "s/SERVICENAME/$packageId/g" Template.service
echo '============================================'
echo '==============Service File=================='
echo '============================================'
cat Template.service
echo
echo '============================================'
sudo cp -v Template.service /lib/systemd/system/$packageId.service
sudo chmod 644 /lib/systemd/system/$packageId.service
sudo systemctl daemon-reload
sudo systemctl enable $packageId.service
echo starting service
sudo systemctl start $packageId.service
sleep 2
sudo journalctl -u $packageId.service -n 10
systemctl is-active --quiet $packageId
if [ $? -eq 0 ]
then
echo Service started successfully
else
echo Issue starting service
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment