Adding Admin and Shared scripts

This commit is contained in:
DarkFeather
2016-11-09 22:25:00 -06:00
parent 5ea18518ef
commit ce8320ce2e
20 changed files with 211 additions and 0 deletions

22
Shared/Makefile Normal file
View File

@@ -0,0 +1,22 @@
LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip
LOCATION=/usr/local/bin
PERMISSION=0755
compile:
@echo Nothing to compile.
install: compile
for i in ${LIST}; do cp ./$$i ${LOCATION}
make checkperm
reverse:
for i in ${LIST}; do cp ${LOCATION}/$$i .; done
test: ${LIST}
for i in ${LIST}; do [ "$$(grep -c '#/bin/bash' $$i)" -ne 1 ]; done
checkperm:
for i in ${LIST}; do chown root:root ${LOCATION}/$$i; chmod ${PERMISSION} ${LOCATION}/$$i; done
clean:
@echo Nothing to do.

2
Shared/bell Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
echo -ne '\007'

3
Shared/bigorlittle Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
if [ $(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6) ]; then echo "Little endian"; else echo "Big endian"; fi

3
Shared/compare-directories Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
if [ "$1" == "" -or "$2" == "" ]; then echo Need to supply two directories as arguments.; exit; fi;
diff -rcw "$1" "$2" | grep ^Only

12
Shared/compress-all Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
export IFS="
"
for i in $(find "$PWD" -type d); do
cd "$i";
for j in $(find . -maxdepth 1 -type f); do
echo $i/$j
gzip "$j";
done
done

6
Shared/diff-args Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
if [ "$1" != "$2" ]; then
echo "These are different.";
else
echo "These are the same.";
fi

8
Shared/expand-all Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
for i in $(find "$PWD" -type d); do
cd $i;
for j in $(find . -maxdepth 1 -type f); do
gunzip $j;
done
done

7
Shared/logged-shell Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
export SHELL=/bin/bash
export LOGFILE="/var/log/guest_log/$(/usr/bin/whoami)-$(date +%F-%R).log"
env > $LOGFILE
exec /bin/sh -c "script -a -q -f $LOGFILE"
#/bin/bash -c "echo /usr/bin/logged-shell"
exit

11
Shared/standardize-folder Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
export IFS="
"
export prefix="$(echo $PWD | rev | cut -f 1 -d '/' | rev)"
firstext="$(ls | head -n 1 | rev | cut -f 1 -d \. | rev)"
export count=1;
for i in $(ls -tr *."$firstext" | grep -v "$prefix"); do
mv "$i" "$prefix $count.$firstext"
export count=$(($count+1))
done

4
Shared/whatismyip Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
echo Cloaked as $(/usr/bin/lynx --dump whatismyipaddress.com | grep '/ip/' | head -n 1 | cut -f 5 -d '/')