github.com/stevenmatthewt/agent@v3.5.4+incompatible/packaging/linux/scripts/before-remove.sh (about) 1 # Check if upstart exists 2 command -v initctl > /dev/null 3 BK_UPSTART_EXISTS=$? 4 5 # Check if upstart is version 0.6.5 as seen on Amazon linux, RHEL6 & CentOS-6 6 BK_UPSTART_TOO_OLD=0 7 if [ $BK_UPSTART_EXISTS -eq 0 ]; then 8 BK_UPSTART_VERSION="$(initctl --version | awk 'BEGIN{FS="[ ()]"} NR==1{print $4}')" 9 if [ "$BK_UPSTART_VERSION" = "0.6.5" ]; then 10 BK_UPSTART_TOO_OLD=1 11 fi 12 fi 13 14 if command -v systemctl > /dev/null; then 15 echo "Stopping buildkite-agent systemd service" 16 17 systemctl --no-reload disable buildkite-agent || : 18 systemctl stop buildkite-agent || : 19 20 systemctl --no-reload disable "buildkite-agent@*" || : 21 systemctl stop "buildkite-agent@*" || : 22 elif [ $BK_UPSTART_EXISTS -eq 0 ] && [ $BK_UPSTART_TOO_OLD -eq 0 ]; then 23 echo "Stopping buildkite-agent upstart service" 24 25 service buildkite-agent stop || : 26 elif [ -d /etc/init.d ]; then 27 echo "Stopping buildkite-agent init.d script" 28 29 /etc/init.d/buildkite-agent stop || : 30 command -v chkconfig > /dev/null && chkconfig --del buildkite-agent || : 31 fi