summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-12-19 00:20:18 +0100
committermakefu <github@syntax-fehler.de>2013-12-19 00:20:18 +0100
commit950f3944d5ccf9fbe4fa72382d0a97cc1f7daa0a (patch)
tree8d3ac180f72603e5b683eff551f97cd51d7dc49a
parent0094250e65132614f3fbd9554d58c2f6220021b9 (diff)
ship/lib: core - os_detection is cooler now
-rw-r--r--ship/lib/core15
1 files changed, 8 insertions, 7 deletions
diff --git a/ship/lib/core b/ship/lib/core
index 6252481f..0c321525 100644
--- a/ship/lib/core
+++ b/ship/lib/core
@@ -8,13 +8,14 @@ die() {
error 'Bailing out.'
exit 1
}
-exists(){ type "$1" >/dev/null 2>/dev/null; }
+exists(){
+ type "$1" >/dev/null 2>/dev/null;
+}
+
is_root(){
test $(id -u) -eq 0
-}
-internet(){
- ping -w 1 google.de >/dev/null 2>&1
}
+
defer(){
#close enough
trapstr="$1;${trapstr:-exit}"
@@ -56,13 +57,12 @@ line_to_dot(){
while read line; do printf .; done;
}
-get_os()
-{
+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
+ elif test -e /etc/preferred-apps/google.xml; then
echo 'android'
elif test -e /etc/openwrt_release; then
echo 'openwrt'
@@ -73,6 +73,7 @@ get_os()
echo 'linux'
fi
}
+
# user management
has_user(){
egrep "^$1:" /etc/passwd >/dev/null