Просмотр исходного кода

Merge pull request #16 from lesteff/patch-1

automatic OS recognisation
Jon Schipp 9 лет назад
Родитель
Сommit
a4d10b2956
1 измененных файлов с 13 добавлено и 2 удалено
  1. 13 2
      check_service.sh

+ 13 - 2
check_service.sh

@@ -50,11 +50,22 @@ fi
 
 os_check() {
 if [ "$OS" == null ]; then
-echo "Use \`\`-o'' and specify the OS as an argument"
-exit 3
+	unamestr=$(uname)
+        if [[ $unamestr == 'Linux' ]]; then
+                OS='linux'
+        elif [[ $unamestr == 'FreeBSD' ]]; then
+               OS='freebsd'
+        elif [[ $unamestr == 'Darwin' ]]; then
+               OS='osx'	       
+        else
+                echo "OS not recognized, Use \`-o\` and specify the OS as an argument"
+                exit 3
+        fi
 fi
 }
 
+
+
 determine_service_tool() {
 if [[ $OS == linux ]]; then
         if command -v systemctl >/dev/null 2>&1; then