diff options
author | tv <tv@nomic.retiolum> | 2013-11-06 20:45:39 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-11-06 20:45:39 +0100 |
commit | d9b56ed3a1e1bb8a585c26301a979f1f2993a0eb (patch) | |
tree | c2661ccba67f1beaba1c47bf021db7a9401fffc9 /ship/lib/core | |
parent | 01cac2ee2e6f6394e6bd33cb63bec1103a727d11 (diff) | |
parent | 1c815ad777fadd5cfa6f54b20d4a0f02206fe7b7 (diff) |
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'ship/lib/core')
-rw-r--r-- | ship/lib/core | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ship/lib/core b/ship/lib/core index fb346f88..3a6b33ff 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -6,6 +6,17 @@ exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 } + +esudo(){ + # becomes root with sudo powers + # unless nosudo env is set + if test "${nosudo-false}" != true || is_root; then + echo "we're going sudo..." >&2 + exec sudo -E "$0" "$@" + exit 23 # go to hell + fi +} + get_hostname(){ # finds the current hostname # if ENV HOSTN is set echo $HOSTN @@ -30,3 +41,22 @@ get_hostname(){ line_to_dot(){ while read line; do printf .; done; } + + +get_os() +{ + # TODO: find all the release files + #if grep -q 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then + if grep -q 'Linux' /etc/lsb-release 2>/dev/null || grep -q 'Linux' /etc/issue 2>/dev/null; then + echo 'linux' + elif exists getprop ; then + echo 'android' + elif test -e /etc/openwrt_release; then + echo 'openwrt' + elif uname -s | grep -qi 'darwin'; then + echo 'osx' + else + warn "Cannot determine your operating system, falling back to Linux" + echo 'linux' + fi +} |