Browse Source

fix error 30.05.23

root 1 year ago
parent
commit
d8dd847c5e
1 changed files with 21 additions and 3 deletions
  1. 21 3
      src/module-reg4uefi

+ 21 - 3
src/module-reg4uefi

@@ -36,8 +36,8 @@ function checkDep() {
36 36
 
37 37
 #--@F active module from UEFI
38 38
 function regMod() {
39
-if mokutil --import $path_script/MOK.der;  then
40
-    sudo openssl req -new -x509 -newkey rsa:2048 -keyout $pash_script/MOK.priv -outform DER -out $pash_script/MOK.der -nodes -days 36500 -subj "/CN=YOUR_NAME/"
39
+if [[ ! -f $path_script/MOK.der ]]; then
40
+  if mokutil --import $path_script/MOK.der;  then
41 41
     eval mod_ls="(" $(find /lib/modules/$(uname -r) -type f -name "$opt".ko -printf '%f\n') ")";
42 42
     if [[ "$(echo -e ${#mod_ls[@]})" != "0" ]]; then
43 43
     for ((i_md = 0; i_md != ${#mod_ls[@]}; i_md++)); do
@@ -45,12 +45,30 @@ if mokutil --import $path_script/MOK.der;  then
45 45
         /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
46 46
     	                        $path_script/MOK.priv \
47 47
     	                        $path_script/MOK.der "${mod_ls[$i_md]}"
48
-	done
48
+	    done
49 49
     else
50 50
 		echo "Not found module.."
51 51
     fi
52
+  else
53
+    echo "not import MOK.der"
54
+  fi
52 55
 else
56
+  sudo openssl req -new -x509 -newkey rsa:2048 -keyout $path_script/MOK.priv -outform DER -out $path_script/MOK.der -nodes -days 36500 -subj "/CN=YOUR_NAME/"
57
+    if mokutil --import $path_script/MOK.der;  then
58
+      eval mod_ls="(" $(find /lib/modules/$(uname -r) -type f -name "$opt".ko -printf '%f\n') ")";
59
+        if [[ "$(echo -e ${#mod_ls[@]})" != "0" ]]; then
60
+          for ((i_md = 0; i_md != ${#mod_ls[@]}; i_md++)); do
61
+            echo "Signing ${mod_ls[$i_md]}"
62
+            /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
63
+    	                        $path_script/MOK.priv \
64
+    	                        $path_script/MOK.der "${mod_ls[$i_md]}"
65
+	        done
66
+        else
67
+		      echo "Not found module.."
68
+        fi
69
+    else
53 70
     echo "not import MOK.der"
71
+    fi
54 72
 fi
55 73
 }
56 74