match on 64*bit and 32*bit
[webi-installers/.git] / _webi / template.sh
index 1f231976a345d56a212d2b089d65dd55c59e03ad..bb4b24e1ba751c2b0293cddd4cd6e4bdda19bdc4 100644 (file)
@@ -235,6 +235,26 @@ webi_post_install() {
     webi_path_add "$(dirname "$pkg_dst_cmd")"
 }
 
+_webi_enable_exec() {
+    if [ -n "$(command -v spctl)" ]; then
+        echo "Checking permission to execute '$pkg_cmd_name' on macOS 11+"
+        set +e
+        is_allowed="$(spctl -a "$pkg_src_cmd" 2>&1 | grep valid)"
+        set -e
+        if [ -z "$is_allowed" ]; then
+            echo ""
+            echo "##########################################"
+            echo "#  IMPORTANT: Permission Grant Required  #"
+            echo "##########################################"
+            echo ""
+            echo "Requesting permission to execute '$pkg_cmd_name' on macOS 10.14+"
+            echo ""
+            sleep 3
+            spctl --add "$pkg_src_cmd"
+        fi
+    fi
+}
+
 # a friendly message when all is well, showing the final install path in $HOME/.local
 _webi_done_message() {
     echo "Installed $(_webi_canonical_name) as $pkg_dst_cmd"
@@ -292,6 +312,7 @@ if [ -n "$(command -v pkg_get_current_version)" ]; then
     pushd "$WEBI_TMP" 2>&1 >/dev/null
         [ -n "$(command -v pkg_post_install)" ] && pkg_post_install || webi_post_install
     popd 2>&1 >/dev/null
+    _webi_enable_exec
 
     pushd "$WEBI_TMP" 2>&1 >/dev/null
         [ -n "$(command -v pkg_done_message)" ] && pkg_done_message || _webi_done_message