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

21
Admin/Makefile Normal file
View 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
View 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
View File

@@ -0,0 +1,4 @@
#!/bin/bash
exim -bp | exiqgrep -i | xargs exim -Mrm

3
Admin/clean-exim-input Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
ls /var/spool/exim/input | cut -c1-16 | xargs exim -Mrm

4
Admin/close-guest Executable file
View 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
View File

@@ -0,0 +1,4 @@
#!/bin/bash
rmmod snd_hda_intel
modprobe snd_hda_intel
alsactl init

4
Admin/log-guest Executable file
View 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
View 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
View 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
View 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 " "