From dbc413595aab927dbcaa4b1e5a4b94bd38f43911 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Fri, 30 Sep 2011 20:21:15 +0200 Subject: [PATCH] First commit --- README.md | 5 +++++ assassinate | 32 ++++++++++++++++++++++++++++++++ man/man1/assassinate.1.gz | Bin 0 -> 242 bytes 3 files changed, 37 insertions(+) create mode 100644 README.md create mode 100755 assassinate create mode 100644 man/man1/assassinate.1.gz 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 0000000000000000000000000000000000000000..bbdf8b660b026122b2f7a41f30c64f0c36d60f51 GIT binary patch literal 242 zcmVVRLh7Zees~E-?UAPd#sgKn&gQS6EExa&Ya|skA*6 zq!ywa88Tj?D_8-Hu&KnqFCiVMWDn2p!?vz6@XSkL?wv=p<6wWl*GFR&9*y(4C5M?{c>#VB#>Y?7MYuhkRel<6e&+PBkLKa~#(w&2-im>f)JdCLw9!%?`Z?R#SScvhtu# szVE^EK#W2#FGzo+gsHAC2Jx5bfvo8v@;Lt7r&`$+A#qD07bTNkN^Mx literal 0 HcmV?d00001