Adding Admin and Shared scripts
This commit is contained in:
parent
5ea18518ef
commit
ce8320ce2e
21
Admin/Makefile
Normal file
21
Admin/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
LIST=arch-update clean-exim clean-exim-input close-guest fix-sound log-guest open-guest restart-service silent-guardian
|
||||
LOCATION=/root/bin
|
||||
PERMISSION=0700
|
||||
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.
|
33
Admin/arch-update
Executable file
33
Admin/arch-update
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
export LOGFILE="/var/log/sysupdate.log"
|
||||
date > $LOGFILE
|
||||
|
||||
# Update
|
||||
echo == Updating Arch Packages == >> $LOGFILE
|
||||
pacman -Syu --noconfirm 2>&1 >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
|
||||
# Get AUR list of update candidates
|
||||
echo == AUR Candidate List == >> $LOGFILE
|
||||
cower -u >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
|
||||
# Clean cache
|
||||
echo == Cleaning Cache == >> $LOGFILE
|
||||
paccache -r >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
|
||||
# Generate list of installed packages
|
||||
echo == Generated installed-packages list == >> $LOGFILE
|
||||
pacman --color never -Qem > /var/log/installed-packages.txt
|
||||
pacman --color never -Qen >> /var/log/installed-packages.txt
|
||||
|
||||
# Generate list of orphaned packages
|
||||
echo == Generated orphaned-packages list == >> $LOGFILE
|
||||
pacman -Qdtq > /var/log/orphaned-packages.txt
|
||||
echo >> $LOGFILE
|
||||
date >> $LOGFILE
|
||||
printf '\n\n' >> $LOGFILE
|
||||
|
||||
cat $LOGFILE | mail -s "AniNIX::$(hostname) update log" sh1k0b4@gmail.com
|
4
Admin/clean-exim
Executable file
4
Admin/clean-exim
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
exim -bp | exiqgrep -i | xargs exim -Mrm
|
||||
|
3
Admin/clean-exim-input
Executable file
3
Admin/clean-exim-input
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
ls /var/spool/exim/input | cut -c1-16 | xargs exim -Mrm
|
4
Admin/close-guest
Executable file
4
Admin/close-guest
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
usermod -G guest guest
|
||||
chsh -s /usr/local/bin/noshell guest
|
||||
passwd guest
|
4
Admin/fix-sound
Executable file
4
Admin/fix-sound
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
rmmod snd_hda_intel
|
||||
modprobe snd_hda_intel
|
||||
alsactl init
|
4
Admin/log-guest
Executable file
4
Admin/log-guest
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
chsh -s /usr/local/bin/logged-shell guest
|
||||
usermod -a -G ssh_allow_grp guest
|
||||
passwd guest
|
4
Admin/open-guest
Executable file
4
Admin/open-guest
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
chsh -s /bin/bash guest
|
||||
usermod -a -G ssh_allow_grp guest
|
||||
passwd guest
|
7
Admin/restart-service
Executable file
7
Admin/restart-service
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
if [ "$1" == "" ]; then echo Need a service name ; exit; fi
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart $1
|
||||
sleep 3
|
||||
systemctl status -l $1
|
49
Admin/silent-guardian
Executable file
49
Admin/silent-guardian
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -f /usr/local/src/SharedLibraries/Bash/header ]; then
|
||||
echo This script requires the SharedLibraries package.
|
||||
exit 1;
|
||||
fi
|
||||
source /usr/local/src/SharedLibraries/Bash/header
|
||||
export logfile="/var/log/silent-guardian.log"
|
||||
|
||||
|
||||
logstatement "Started $(date)"
|
||||
|
||||
# Fix the Webserver permissions
|
||||
chown -R cxford:http /srv/http/*
|
||||
find /srv/http/* -type f -exec chmod 0640 {} \;
|
||||
find /srv/http/* -type d -exec chmod 0750 {} \;
|
||||
|
||||
# Fix the media permissions
|
||||
chown -R cxford:http /srv/yggdrasil
|
||||
find /srv/yggdrasil/ -type f -exec chmod 0440 {} \;
|
||||
find /srv/yggdrasil/ -type d -exec chmod 0550 {} \;
|
||||
chmod -R u+w /srv/yggdrasil/new_acquisition
|
||||
|
||||
# fix the WolfPack results location
|
||||
find /srv/WolfPackResults -type d -exec chmod 0755 {} \;
|
||||
find /srv/WolfPackResults -type f -exec chmod 0644 {} \;
|
||||
|
||||
# Seal the special directories.
|
||||
for i in $(ls -a /srv/yggdrasil/Digital_Library/ | egrep '^\.[a-zA-Z0-9]+$'); do
|
||||
chown cxford:cxford -R $i;
|
||||
find $i -type f -exec chmod 0400 {} \;
|
||||
find $i -type d -exec chmod 0500 {} \;
|
||||
done
|
||||
|
||||
# Guard root
|
||||
chmod 0700 /root
|
||||
chown -R root:root /root
|
||||
find /root -type d -exec chmod 0700 {} \;
|
||||
|
||||
# Guard home directories
|
||||
chmod 0750 /home/*
|
||||
chmod 0700 /home/.root-only/
|
||||
|
||||
# Guard API's
|
||||
chmod 0750 /usr/local/bin/api-keys
|
||||
chown root:api /usr/local/bin/api-keys
|
||||
|
||||
logstatement "Ended $(date)"
|
||||
logstatement " "
|
22
Shared/Makefile
Normal file
22
Shared/Makefile
Normal 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
2
Shared/bell
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo -ne '\007'
|
3
Shared/bigorlittle
Executable file
3
Shared/bigorlittle
Executable 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
3
Shared/compare-directories
Executable 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
12
Shared/compress-all
Executable 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
6
Shared/diff-args
Executable 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
8
Shared/expand-all
Executable 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
7
Shared/logged-shell
Executable 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
11
Shared/standardize-folder
Executable 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
4
Shared/whatismyip
Executable 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 '/')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user