summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-11-06 20:24:54 +0100
committerlassulus <lassulus@googlemail.com>2013-11-06 20:24:54 +0100
commit1c815ad777fadd5cfa6f54b20d4a0f02206fe7b7 (patch)
tree80f41f6150b1f5f6622b446723b26e1dd1446876
parentaec1b767fd0223029332b14e5834c555efc345ff (diff)
parenta413089b542f7504fdf0bab1ef9b1fa5e7b26c32 (diff)
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r--ship/lib/core30
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
+}