ShadowArch fixes

This commit is contained in:
DarkFeather 2017-06-23 13:56:31 -05:00
parent 429b7e7b0c
commit 78de31f832
8 changed files with 126 additions and 29 deletions

View File

@ -1,4 +1,4 @@
LIST=arch-update clean-exim clean-exim-input close-guest fix-sound log-guest open-guest restart-service silent-guardian proxy simple-web
LIST=arch-update clean-exim clean-exim-input close-guest fix-sound log-guest open-guest restart-service silent-guardian revproxy simple-web
LOCATION=/root/bin
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
PERMISSION=0700
@ -7,6 +7,7 @@ compile:
install: compile
mkdir -p ${LOCATION};
mkdir -p /var/log/aninix/
for i in ${LIST}; do cp ./$$i ${LOCATION}; done
make checkperm
@ -23,4 +24,5 @@ clean:
@echo Nothing to do.
diff:
for i in ${LIST}; do diff ./${i} ${LOCATION}/${i}; done
count=0; for i in ${LIST}; do echo $$i; diff ./$$i ${LOCATION}/$$i; if [ $$? -ne 0 ]; then count=$$(( $$count + 1 )); fi; echo; done; echo Found $$count files to be different.

View File

@ -1,29 +1,83 @@
#!/bin/bash
export LOGFILE="/var/log/sysupdate.log"
date > $LOGFILE
export logfile="/var/log/sysupdate.log"
export tmpfile=/tmp/shadowarch-cowerfile
unset apply
while getopts "al:h" OPTION
do
case $OPTION in
a) export apply="true"; ;;
c) export logfile=${OPTARG}; ;;
*) printf "ShadowArch Update Checker\n-a Apply changes\n-l Logfile\n-h Show this helptext\n"; exit 1;;
esac;
done
date > $logfile
# Update
echo == Updating Arch Packages == >> $LOGFILE
# pacman -Syu --noconfirm 2>&1 >> $LOGFILE # I've been having troubles with this causing crashes while online.
checkupdates >> $LOGFILE
echo >> $LOGFILE
echo == Updating Arch Packages == | tee -a $logfile
if [ ! -z "$apply" ]; then
pacman -Syu 2>&1 | tee -a $logfile # I've been having troubles with this causing crashes while online.
# Hook for MediaWiki
if [ `grep $(date +$F) /var/log/pacman.log | grep -c mediawiki` -eq 1 ]; then
php /usr/share/webapps/mediawiki/maintenance/update.php | tee -a $logfile
fi
# Hook for Grimoire
if [ `grep $(date +$F) /var/log/pacman.log | grep -c 'upgraded postgresql '` -eq 1 ]; then
echo "Updating PostGreSQL databases" | tee -a $logfile
#Clear old backups.
rm -Rf /var/lib/postgres/olddata
#Stop the service and save old database version.
if [ -f /usr/lib/systemd/system/grimoire.service ]; then systemctl stop grimoire; else systemctl stop postgresql.service; fi
su -l postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'
# Init new database and upgrade.
su -l postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data' | tee -a $logfile
upstr=`grep "$(date +%F)" /var/log/pacman.log | grep 'upgraded postgresql '`
oldver=`echo $upstr | rev | cut -f 2 -d '>' | cut -f 1 -d '(' | rev | sed s/\ -//`
newver=`echo $upstr | rev | cut -f 1 -d '>' | cut -f 2 -d ')' | rev`
# Upgrade the database.
su -l postgres -c "pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-$oldver/bin/ -B /usr/bin/" | tee -a $logfile
# Create dump file for restores.
/opt/pgsql-$oldver/bin/pg_ctl -D /var/lib/postgres/olddata/ start
/opt/pgsql-$oldver/bin/pg_dumpall >> /var/lib/postgres/olddata/dump.psql
/opt/pgsql-$oldver/bin/pg_ctl -D /var/lib/postgres/olddata/ stop
# Restart the service.
if [ -f /usr/lib/systemd/system/grimoire.service ]; then systemctl start grimoire; else systemctl start postgresql.service; fi
echo "Updated PostGreSQL databases" | tee -a $logfile
fi
else
checkupdates | tee -a $logfile
fi
echo | tee -a $logfile
# Get AUR list of update candidates
echo == AUR Candidate List == >> $LOGFILE
cower -u >> $LOGFILE
echo >> $LOGFILE
echo == AUR Candidate List == | tee -a $logfile
if [ ! -z "$apply" ]; then
cower -u | cut -f 2 -d ' ' &> $tmpfile
echo Edit the package list.
read
${EDITOR} ${tmpfile}
chmod 0755 $tmpfile;
printf "What deprivileged user do you want to use? "
read deprivuser;
sudo -u "$deprivuser" /bin/bash -c "for i in `cat $tmpfile`; do cd /usr/local/src/"$i"; git pull; makepkg -sri; done"
(echo Updated the following AUR packages:; cat $tmpfile) | tee -a $logfile
rm $tmpfile;
else
cower -u | tee -a $logfile
fi
echo | tee -a $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
echo == Generated installed-packages list == | tee -a $logfile
pacman -Qqe | egrep '^[a-z]' | sed 's#local/##' > /var/log/installed-packages.txt
# Generate list of orphaned packages
echo == Generated orphaned-packages list == >> $LOGFILE
echo == Generated orphaned-packages list == | tee -a $logfile
pacman -Qdtq > /var/log/orphaned-packages.txt
echo >> $LOGFILE
date >> $LOGFILE
printf '\n\n' >> $LOGFILE
echo | tee -a $logfile
date | tee -a $logfile
printf '\n\n' | tee -a $logfile
cat $LOGFILE | mail -s "AniNIX::$(hostname) Update Candidates" sh1k0b4@gmail.com
if [ -z "$apply" ]; then cat $logfile | mail -s "AniNIX::$(hostname) Update Candidates" sh1k0b4@gmail.com; fi

View File

@ -1,2 +1,2 @@
#!/bin/bash
python3 -m http.server 8000
python -m http.server 8000

View File

@ -1,16 +1,19 @@
HTTPROOT = /srv/http/aninix.net
HTTPUSER = http
SYNCLIST = /etc/vimrc /etc/bash.bashrc /etc/skel /etc/tmux.conf
SYNCLIST = /etc/vimrc /etc/bash.bashrc /etc/skel /etc/tmux.conf /etc/profile
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
compile:
[ -f ./shadowarch ]
compile: ./shadowarch
@echo Nothing to compile
install: compile
cp ./vimrc /etc/vimrc
cp bash.bashrc /etc/bash.bashrc
rsync -avz -r skel/ /etc/skel
cp tmux.conf /etc/tmux.conf
cp ./profile /etc/profile
# This is a nicety.
if [ -f /root/shadowarch* ]; then sed -i 's/`uname -o`/ShadowArch/g' /etc/bash.bashrc; fi
repository: shadowarch
cp ./shadowarch ${HTTPROOT}
@ -29,6 +32,7 @@ test:
reverse: ${HTTPROOT}/shadowarch ${SYNCLIST}
cat ${HTTPROOT}/shadowarch > ./shadowarch
for i in ${SYNCLIST}; do rsync -avz ${SYNCLIST} .; done
sed -i 's/ShadowArch/`uname -o`/' ./bash.bashrc
clean:
@echo Nothing to do.

View File

@ -5,7 +5,7 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
PS1='\[\033[00;31m\][ AniNIX::\h(\[\033[01;32m\]ShadowArch\[\033[00;31m\]) \[\033[00;36m\]\u \[\033[01;37m\]\d \t \[\033[00;35m\]\w\[\033[00;31m\] ] \n|\[\033[m\]> '
PS1='\[\033[00;31m\][ AniNIX::\h(\[\033[01;32m\]`uname -o`\[\033[00;31m\]) \[\033[00;36m\]\u \[\033[01;37m\]\d \t \[\033[00;35m\]\w\[\033[00;31m\] ] \n|\[\033[m\]> '
PS2='> '
PS3='> '
PS4='+ '
@ -50,7 +50,7 @@ if [ "$TERM" != "screen" ] && [ -z "$DESKTOP_SESSION" ]; then
elif [ `tmux list-sessions | grep created | wc -l` -eq 1 ] && [ `tmux list-sessions | grep attached | wc -l` -eq 0 ]; then
exec tmux a -d -t `tmux list-sessions | grep created | cut -f 1 -d ':'`
fi
alias tat="tmux a -d -t"
alias tat="exec tmux a -d -t"
elif [ -x "$(which screen 2>/dev/null)" ] && [ "$TERM" != "screen" ]; then
if [ `screen -list | grep -c 'Detached'` -eq 1 ]; then
exec screen -r

32
ShadowArch/profile Normal file
View File

@ -0,0 +1,32 @@
# /etc/profile
#Set our umask
umask 022
# Set our default path
PATH="/usr/bin/:/usr/local/sbin:/usr/local/bin:~/bin"
export PATH
IFS="
"
export IFS
# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP
# Man is much better than us at figuring this out
unset MANPATH

View File

@ -125,7 +125,7 @@ fi
# * make for source packages
# * tor for anonymity
header Installing ArchLinux to device\(s\) on /mnt
export pkglist="base base-devel parted net-tools bind-tools git openssh make lynx irssi vim wget tor torsocks grub os-prober rsync openntpd"
export pkglist="base base-devel parted net-tools bind-tools git openssh make lynx irssi vim wget tor torsocks grub os-prober rsync openntpd tmux"
if [ "$gui" -eq 1 ]; then
export pkglist="$pkglist"" xorg-server xfce4 seamonkey conky tigervnc"
fi
@ -159,6 +159,9 @@ arch-chroot /mnt locale-gen
ln -s /usr/share/zoneinfo/America/Chicago /mnt/etc/localtime
arch-chroot /mnt hwclock --systohc --utc
# Leave a trace of the install.
cp /root/shadowarch /mnt/root/shadowarch.installer."$(date +%F-%R)"
header Setup bootloader
if [ "$nodiskbuild" -eq 0 ]; then
export rootuuid="$(blkid "$disk""$rootpart" | cut -f 2 -d '"')"
@ -190,8 +193,10 @@ arch-chroot /mnt systemctl enable netctl
arch-chroot /mnt netctl enable $interface
# Vim cleanup for SSH
mkdir -p /mnt/usr/share/vim/vimfiles/plugin
printf 'set mouse-=a\n' > /mnt/usr/share/vim/vimfiles/plugin/shadowarch.vim
mkdir -p /usr/share/vim/vimfiles/plugin
printf 'set mouse-=a\n' > /usr/share/vim/vimfiles/plugin/shadowarch.vim
ln -sf /etc/skel/.bashrc /mnt/root/.bashrc
# Clone ConfigPackags from AniNIX::Foundation
arch-chroot /mnt git -C /usr/local/src/ clone https://aninix.net/foundation/ConfigPackages
@ -221,7 +226,6 @@ arch-chroot /mnt chown -R depriv:depriv /usr/local/src/
# Set SSH host keys
arch-chroot /mnt ssh-keygen -A
cp /root/shadowarch /mnt/root/shadowarch.installer."$(date +%F-%R)"
if [ "$gui" -eq 1 ]; then
echo "Remember to install your graphics drivers!

View File

@ -4,3 +4,4 @@ bind-key -T prefix X confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind-key -T prefix x new-window cryptoworkbench
bind-key -T prefix b new-window lynx https://aninix.net/
bind-key -T prefix s set status
bind-key -T prefix S setw synchronize-panes