aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--README4
-rwxr-xr-xbin/chmod-x.sh30
3 files changed, 35 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 9be6e01..2956183 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@
install:
install -d $(DESTDIR)/usr/bin
+ install bin/chmod-x.sh $(DESTDIR)/usr/bin/
install bin/tmux-session.sh $(DESTDIR)/usr/bin/
install bin/wg-activate.sh $(DESTDIR)/usr/bin/
diff --git a/README b/README
index c5d348e..855d1cb 100644
--- a/README
+++ b/README
@@ -4,6 +4,10 @@ A collection of shell scripts.
== Scripts
+*chmod-x.sh*::
+Script to recursively scan directory and remove executable-bit from file that
+may not an executable.
+
*tmux-session.sh*::
Script to open new tmux session with start directory based on configuration in
`~/.tmux.session`.
diff --git a/bin/chmod-x.sh b/bin/chmod-x.sh
new file mode 100755
index 0000000..fe8ae9a
--- /dev/null
+++ b/bin/chmod-x.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+## SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info>
+## SPDX-License-Identifier: GPL-3.0-or-later
+
+## Script to recursively scan directory and remove executable-bit from file
+## that may not an executable.
+##
+## Usage
+##
+## $ chmod-x.sh dir
+
+DIR=$1
+
+if [[ -z "$DIR" ]]; then
+ echo "$0 <directory>"
+ exit 1
+fi
+
+IFS=:
+MAYBE_BIN="ELF 32-bit | shell script | executable";
+
+echo "Checking in directory: $DIR"
+
+for file in $(find $DIR -type f -perm /111 -printf "%p$IFS")
+do
+ if ! file $file | grep -q -E "$MAYBE_BIN"; then
+ echo "$file"
+ chmod -x $file
+ fi
+done