summaryrefslogtreecommitdiff
path: root/zshfunc/buildd-stop
blob: c4ced456168bcc549ec658c5a137483317bdcc78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
buildd-stop() {
	local need_sudo

	if [ -r ~buildd ] && [ -r ~buildd/build ] ; then
		need_sudo=""
	else
		need_sudo="sudo"
	fi

	if $need_sudo test -e ~buildd/NO-DAEMON-PLEASE; then
		echo "no-daemon-please already exists:"
		$need_sudo ls -l ~buildd/NO-DAEMON-PLEASE
		if $need_sudo test -e ~buildd/build/buildd.pid ; then
			echo "buildd still running?"
		else
			echo "pidfile of buildd doesn't exist.  Good.  Assuming it doesn't run."
		fi
		ps xauf | grep 'build[d]'
	else
		echo "Touching ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE"
		sudo -u buildd touch ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE &&
		sudo chgrp -v adm ~buildd/NO-DAEMON-PLEASE &&
		echo "Sending HUP to buildd"
		sudo -u buildd kill -HUP `sudo cat ~buildd/build/buildd.pid`
	fi
}