check bin dir and fixed test option
[makesimple.git] / makesimple.sh
index 5d542b2..282739c 100755 (executable)
@@ -29,6 +29,7 @@ if [ "$id" != "root" -a "$prjname" = "install" ]; then
    exit 1
 fi
 TMPLPATH=/var/lib/makesimple
+BINPATH=/usr/local/bin
 SRCFILE=$TMPLPATH/file_src.c
 HFILE=$TMPLPATH/file_inc.h
 MAKFILE=$TMPLPATH/makefile
@@ -41,12 +42,15 @@ if [ "$prjname" = "install" ]; then
   echo "Continue (y/n)"
   read a
   if [ "$a" = "y" -o "$a" = "Y" ]; then
-    if [ ! -x "$TMPLPATH" ]; then
+    if [ ! -d "$TMPLPATH" ]; then
        mkdir "$TMPLPATH" || exit 5
     fi
-    rm -f "$TMPLPATH"/* || exit 6
-    cp * "$TMPLPATH" || exit 7
-    cp ./makesimple.sh /usr/local/bin || exit 8
+    if [ ! -d "$BINPATH" ]; then
+       mkdir "$BINPATH" || exit 6
+    fi
+    rm -f "$TMPLPATH"/* || exit 7
+    cp * "$TMPLPATH" || exit 8
+    cp ./makesimple.sh "$BINPATH" || exit 9
     echo "Installation OK"
   fi
   exit 0