48 lines
1.0 KiB
Bash
Executable File
48 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Bash Functions sourced by .bashrc / .sshrc
|
|
#
|
|
|
|
# Get SSL Certificate information
|
|
# Based on https://serverfault.com/questions/661978/displaying-a-remote-ssl-certificate-details-using-cli-tools
|
|
function getCertInfo() {
|
|
local myServer=${1:?a Servername is required}
|
|
local myPort=${2:-443}
|
|
|
|
echo | openssl s_client -showcerts -servername "$myServer" -connect "$myServer":"$myPort" 2>/dev/null | openssl x509 -inform pem -noout -text
|
|
}
|
|
|
|
#
|
|
# Some functions (some by c't magazine)
|
|
#
|
|
|
|
# change directory and list
|
|
cdl() {
|
|
if cd "$@"; then
|
|
ls
|
|
fi
|
|
}
|
|
|
|
backup() {
|
|
# local @files = "$@"
|
|
for f in "$@"
|
|
do
|
|
if [ -d "$f" ]; then
|
|
cp -p -r "$f" "$f".backup-"$(date +%Y-%m-%d_%H_%M_%S)"
|
|
else
|
|
cp -p "$f" "$f".backup-"$(date +%Y-%m-%d_%H_%M_%S)"
|
|
fi
|
|
done
|
|
}
|
|
|
|
extract() {
|
|
case $1 in
|
|
*.tar.bz2) tar xvjf "$1";;
|
|
*.tar.gz|*.tgz) tar xvfz "$1";;
|
|
*.zip) unzip "$1";;
|
|
*) echo "Not supported: $1";;
|
|
esac
|
|
}
|
|
|
|
PATH=$PATH:$HOME/bin
|