commit dbc413595aab927dbcaa4b1e5a4b94bd38f43911 Author: Yann Esposito (Yogsototh) Date: Fri Sep 30 20:21:15 2011 +0200 First commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e55156a --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Assassinate + +A shell utility used to kill all processes of some user. +Warn you if you try to kill some special user (init or root). + diff --git a/assassinate b/assassinate new file mode 100755 index 0000000..36f64d0 --- /dev/null +++ b/assassinate @@ -0,0 +1,32 @@ +#!/usr/bin/env zsh +# kill all other processes + +function logexit { + print -P -- "$*" >&2 + exit 1 +} + +(($#<1)) && logexit "Usage: ${0:t} user" + +victim="$1" + +function stopquestion() { + print -n -- "$* (y/n): " + read answer + case $answer in + y|Y) print -- "OK you've been warned!";; + *) exit 0 ;; + esac +} + +case $victim in + $USER) stopquestion "Are you sure to kill you own processes?";; + init|root) stopquestion "Are you sure to kill all '$victim' processes?";; +} +exit 0 + +processlist=( $(ps aux | awk '{print $1" "$2}' | egrep '(krystelle|bastien|anna|jc)' | awk '{print $2}') ) + +(($#processlist == 0)) && logexit "No process for user $victim" + +sudo kill -9 $processlist diff --git a/man/man1/assassinate.1.gz b/man/man1/assassinate.1.gz new file mode 100644 index 0000000..bbdf8b6 Binary files /dev/null and b/man/man1/assassinate.1.gz differ