Forráskód Böngészése

inst : check if all right at the end of script

Jovian (Darkside) 6 éve
szülő
commit
40c0d048ea
1 módosított fájl, 31 hozzáadás és 1 törlés
  1. 31 1
      inst

+ 31 - 1
inst

@@ -1,5 +1,5 @@
 #!/bin/bash
-#stat --format '%G' inst 
+
 # Functions
 function inst_out
 {
@@ -11,6 +11,11 @@ function inst_fatal
 	inst_out "FATAL : $1"
 }
 
+function inst_fail
+{
+	inst_fatal 'installation has failed'
+}
+
 # Welcome
 inst_out 'Script begins'
 
@@ -101,7 +106,32 @@ then
 fi
 
 # Check if all right
+output="$target$script"
+owner_user=`stat --format '%U' $output`
+owner_group=`stat --format '%G' $output`
 
+if [ ! -e $output ]
+then
+	inst_fatal "$output does not exist"
+	inst_fail
+	exit 1
+elif [ $owner_user != $user ]
+then
+	inst_fatal "$output owner user is not $user but $owner_user"
+	inst_fail
+	exit 1
+elif [ $owner_group != $user ]
+then
+	inst_fatal "$output group is not $user but $owner_group"
+	inst_fail
+	exit 1
+elif [ ! -x $output ]
+then
+	inst_fatal "$output is not executable"
+	inst_out "fix : sudo chmod u+x $output"
+	inst_fail
+	exit 1
+fi
 
 # End
 inst_out 'Script finished'