Installation updates and scripts

This commit is contained in:
2022-11-20 20:47:27 -06:00
parent e74a77387f
commit 0cee9eac39
118 changed files with 366 additions and 3975 deletions

View File

@@ -1,4 +1,4 @@
LIST=bell bigorlittle compare-directories compress-all diff-args expand-all failcount logged-shell standardize-folder sysinfo whatismyip worktrack
LIST=bell bigorlittle compare-directories compress-all diff-args expand-all failcount home-git logged-shell src-maintenance sslinfo standardize-folder sysinfo whatismyip worktrack
LOCATION=${pkgdir}/usr/local/bin
PERMISSION=0755
compile:

114
UserScripts/home-git Executable file
View File

@@ -0,0 +1,114 @@
#!/bin/bash
# File: home-git
#
# Description: This file allows scripted support for user support repositories in a Git instance.
# https://aninix.net/AniNIX/Wiki/src/branch/main/Articles/User_Support_Repositories.md
#
# Package: AniNIX/ShadowArch
# Copyright: WTFPL
#
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
function InitializeGitIgnore() {
### Seed the .gitignore
cat > ~/.gitignore <<EOM
# Ignore normal files
*
!/.bash_profile
!/.bashrc
!/bin**
!/.git[a-z]*
!/.githooks**
!/.gpg-id
!/.gnupg**
/.gnupg/.#*
/.gnupg/*.lock
/.gnupg/random_seed
!/password-store**
/password-store/*.password
/password-store/*.lock
!/.profile
!/.rclone.conf
!/.src-maintenance.conf
!/.ssh**
!/.tmux.conf
!/.vimrc
!/.weechat
!/.weechat/**
!/.wpa_supplicant**
!/.config/
/.config/*
!/.config/systemd**
/.config/systemd/user/default.target.wants**
/.config/systemd/user/timers.target.wants**
/.config/systemd/user/multi-user.target.wants**
!/.config/xfce4/
!/.config/xfce4/xfconf/
!/.config/xfce4/xfconf/xfce-perchannel-xml**
!/ssh
/.weechat/weechat.log
/.weechat/logs
.weechat/script/plugins.xml.gz
EOM
}
function InitializeHome() {
### Initialize a clone
# param target: the repo URL
target="$1"
if [ "$PWD" != "$HOME" ]; then
read -p "You are not currently in your home directory -- are you sure you want to use this folder? [y/n]" answer
if [ "$answer" != 'y' ]; then
exit 0;
fi
fi
git init .
git config remote.origin.url "$target"
InitializeGitIgnore
git add -A
git status
echo
echo 'If this status looks right, run `git commit && git push`.'
exit 0
}
function CloneToHome() {
### Reset home from a clone
# param target: the repo URL
target="$1"
git clone --bare "$target" .git
git config --local --bool core.bare false
git reset --hard
exit 0
}
function Usage() {
### Usage
# param retcode: return code
retcode="$1"
echo "Usage: $0 -h"
echo " $0 -c \$targeturl # Clone home from URL"
echo " $0 -i \$targeturl # Initialize home to send to URL"
echo " $0 -I # Reinitialize the .gitignore and show staged delta"
exit "$retcode"
}
### Main
if [ "$(basename $0)" == "home-git" ]; then
# Parse options
while getopts 'c:hi:Iv' OPTION; do
case "$OPTION" in
c) CloneToHome "${OPTARG}" ;;
h) echo "Control home via user support repositories."; Usage 0 ;;
i) InitializeHome "${OPTARG}" ;;
I) InitializeGitIgnore; git add -A; git status ;;
v) set -x ;;
esac
done
# Catchall
Usage 1
fi

70
UserScripts/src-maintenance Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# File: src-maintenance
#
# Description: This file simplifies managing $HOME/src
#
# Package: DarkFeather/HomeDir
# Copyright: WTFPL
# # Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
source /opt/aninix/Uniglot/Bash/header
conffile="$HOME/.$(basename "$0").conf"
unset noconfirm
mkdir -p $HOME/src
function usage() {
### Write the usage
### param retcode: the return code
retcode="$1"
echo "Usage: $0 # List the state of clones by default"
echo " $0 -h # Helptext"
echo " $0 -c # Clone everything in the conf file."
echo " $0 -r # Remove the spurious clones"
echo " $0 -w # Helptext"
echo "Add -v to increase verbosity."
echo "Add -y to skip confirmations."
exit $retcode
}
function cloneList() {
### git-clone all the tracked repos.
cat "$conffile" | while read line; do
dir="$(echo "$line" | cut -f 1 -d ' ')"
gitrepo="$(echo "$line" | cut -f 2 -d ' ')"
cd $HOME
mkdir -p "$(dirname "$dir")"
if [ ! -d "$dir" ]; then
git clone "$gitrepo" "$dir"
else
cd "$dir"
git pull;
fi
done
}
function writeOutList() {
### Write out the list of clones
cd $HOME
for clone in `find . -type d -name .git | sed 's/\.git$//'`; do
cd "$clone"
printf "$(echo "$clone" | sed 's#^\.\/##' | sed 's/\/$//') "
git config remote.origin.url
cd $HOME
done | sort | uniq | egrep -iv 'aninix|gitea@localhost|/srv/foundation|homedir' > "$conffile"
exit $?
}
### Main
if [[ "$(basename "$0")" == "src-maintenance" ]]; then
while getopts 'chrwv' OPTION; do
case "$OPTION" in
c) cloneList; ;;
h) echo This tool simplifies clone maintenance; usage 0 ;;
w) writeOutList ;;
v) set -x ;;
y) noconfirm=1 ;;
*) usage 1 ;;
esac
done
fi

93
UserScripts/sslinfo Executable file
View File

@@ -0,0 +1,93 @@
#!/bin/bash
# File: sslinfo
#
# Description: This file takes an SSL file and prints
# useful human-readable information about it.
#
# Package: AniNIX/ShadowArch
# Copyright: WTFPL
#
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
# Sanity checks
set -Eeo pipefail
# Default variables
port=443
option="-text"
unset dump
unset host
unset modulus
unset machinereadable
unset showserial
regex='Subject:|Subject Alt|Issuer:|Not |DNS:|IP Addr|Signature Algorithm'
# Show Usage
function Usage() {
echo "Usage: $0 [ -p port ] [ -r regex | -a | -s ] -t TARGET"
echo " $0 -V"
echo " $0 -h"
echo
echo "Adding -m will make it machine readable, and -v will increase verbosity."
echo "The -a will show all output."
echo "The -s will show the serial for the certificate."
echo "The -h will show helptext."
echo "The -V option will show version"
echo "TARGET can be a hostname, request, or certificate."
}
# Translate output into CSV format.
function machineReadable() {
egrep 'After|DNS|Subject:' | sed 's/^\s\+//' | sed 's/Not After : //' | sed 's/Subject: //' | sed 's/DNS://g' | tr '\n' ','
echo
}
# Parse user options
while getopts 'aDhmMp:r:st:vV' OPTION; do
case "$OPTION" in
a) regex="*" ;;
D) dump=1 ;;
h) echo Display useful information in a concise format about an SSL object.; Usage; exit 0 ;;
m) machinereadable=1 ;;
M) modulus=1 ; option="-modulus" ;;
p) port="${OPTARG}" ;;
r) regex="${OPTARG}" ;;
s) showserial=1 ; option="-serial" ;;
t) host="${OPTARG}" ;;
v) set -x ;;
V) Version ;;
*) Usage; exit 1 ;;
esac
done
# Make sure some argument is set.
if [ -z "$host" ] ; then
echo Need a target.
Usage
exit 1;
fi
# Pass it all through OpenSSL
# 1. Get the object
(if [ -f "$host" ]; then
if [ `grep -c REQUEST "$host"` -gt 1 ]; then
openssl req -noout -in "$host" $option
elif [ `grep -c RSA\ PRIVATE\ KEY "$host"` -gt 1 ]; then
openssl rsa -noout -in "$host" $option
elif [ `grep -c CERTIFICATE "$host"` -gt 1 ]; then
openssl x509 -noout -in "$host" $option
fi
else
echo | openssl s_client -connect "$host":"$port" 2>&1 | if [ -z "$dump" ]; then openssl x509 -noout $option; fi
fi) \
| (if [ -n "$modulus" ]; then
cat;
elif [ -n "$showserial" ]; then
sed 's/^serial=//'
elif [ -n "$dump" ]; then # 2. Parse the object.
grep -A 99 BEGIN\ CERTIFICATE
else
egrep -i "$regex"
fi) \
| (if [ -z "$machinereadable" ]; then cat; else machineReadable; fi)