diff options
author | tv <tv@nomic.retiolum> | 2013-11-12 15:33:49 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-11-12 15:33:49 +0100 |
commit | 021dd964ba41665562430e87f75ed53380459a68 (patch) | |
tree | 55f88e2391539b40afc2c952a66dcb2c43f2db30 /ship/lib/core | |
parent | a6012ff33c05593f4c73b7de55ce09915b6327f9 (diff) | |
parent | 8b60dff25e85921fe533f621a1b5d0f8149bf38f (diff) |
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'ship/lib/core')
-rw-r--r-- | ship/lib/core | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ship/lib/core b/ship/lib/core index 3a6b33ff..1ef1fbf9 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -2,15 +2,22 @@ msg() { printf "$@\n" >&2 ;} info() { msg "** $@" ;} error() { msg "!! $@" ;} +die() { error "$@" ;exit 1;} exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 +} + +defer(){ + #close enough + trapstr="$1;${trapstr:-exit}" + trap "$trapstr" INT TERM EXIT KILL } esudo(){ # becomes root with sudo powers # unless nosudo env is set - if test "${nosudo-false}" != true || is_root; then + if test "${nosudo-false}" != true && ! is_root; then echo "we're going sudo..." >&2 exec sudo -E "$0" "$@" exit 23 # go to hell |