Initial commit
This commit is contained in:
commit
f39b0fbcd8
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.log
|
||||||
|
*.swp
|
||||||
|
*conf/*.conf
|
285
snippets/base_script.sh
Executable file
285
snippets/base_script.sh
Executable file
@ -0,0 +1,285 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_name="$(basename $(realpath $0))"
|
||||||
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
|
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||||
|
|
||||||
|
LOCK_DIR="/tmp/$(basename $0).$$.LOCK"
|
||||||
|
log_file="${LOCK_DIR}/${script_name%%.*}.log"
|
||||||
|
|
||||||
|
backup_date="$(date +%Y-%m-%d-%H%M)"
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Base Function(s)
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
|
||||||
|
|
||||||
|
[[ -n "$1" ]] && error "$1"
|
||||||
|
|
||||||
|
|
||||||
|
[[ $terminal ]] && echo -e "
|
||||||
|
\033[1mUsage:\033[m
|
||||||
|
|
||||||
|
$(basename $0) [OPTION [OPTION ..
|
||||||
|
|
||||||
|
\033[1mDescription\033[m
|
||||||
|
|
||||||
|
<Some Description>
|
||||||
|
|
||||||
|
\033[1mOptions\033[m
|
||||||
|
|
||||||
|
<List Options>
|
||||||
|
|
||||||
|
\033[1mExample:\033[m
|
||||||
|
|
||||||
|
<description example>
|
||||||
|
|
||||||
|
$(basename $0) .. <comand example>
|
||||||
|
|
||||||
|
<description another example>
|
||||||
|
|
||||||
|
$(basename $0) .. <command another example>
|
||||||
|
|
||||||
|
"
|
||||||
|
|
||||||
|
clean_up 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_up() {
|
||||||
|
|
||||||
|
# Perform program exit housekeeping
|
||||||
|
rm -rf "$LOCK_DIR"
|
||||||
|
blank_line
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echononl(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo X\\c > /tmp/shprompt$$
|
||||||
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
echo -e -n " $*\\c" 1>&2
|
||||||
|
else
|
||||||
|
echo -e -n " $*" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fatal(){
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[31m\033[1mFatal\033[m ] $*"
|
||||||
|
else
|
||||||
|
echo -e " [ Fatal ] $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " \033[1mScript terminated\033[m.."
|
||||||
|
else
|
||||||
|
echo -e " Script terminated.."
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
rm -rf $LOCK_DIR
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
error (){
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[31m\033[1mError\033[m ] $*"
|
||||||
|
else
|
||||||
|
echo " [ Error ] $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
warn (){
|
||||||
|
if $LOGGING || $terminal ; then
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[33m\033[1mWarn\033[m ] $*"
|
||||||
|
else
|
||||||
|
echo " [ Warn ] $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
info (){
|
||||||
|
if $LOGGING || $terminal ; then
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[32m\033[1mInfo\033[m ] $*"
|
||||||
|
else
|
||||||
|
echo " [ Info ] $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ok (){
|
||||||
|
if $LOGGING || $terminal ; then
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[32m\033[1mOk\033[m ] $*"
|
||||||
|
else
|
||||||
|
echo " [ Ok ] $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_done() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[32mdone\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_ok() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[32mok\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_failed(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_skipped() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
local var="$*"
|
||||||
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||||
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||||
|
echo -n "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
blank_line() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Jobhandling
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
|
||||||
|
# -
|
||||||
|
trap clean_up SIGHUP SIGINT SIGTERM
|
||||||
|
|
||||||
|
# - Create lock directory '$LOCK_DIR"
|
||||||
|
#
|
||||||
|
mkdir "$LOCK_DIR"
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Headline
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[1m----------\033[m"
|
||||||
|
echo -e "\033[32m\033[1mRunning script \033[m\033[1m$script_name\033[32m .. \033[m"
|
||||||
|
echo -e "\033[1m----------\033[m"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Some checks ..
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
# - Running in a terminal?
|
||||||
|
# -
|
||||||
|
if [[ -t 1 ]] ; then
|
||||||
|
terminal=true
|
||||||
|
else
|
||||||
|
terminal=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# - Print help?
|
||||||
|
# -
|
||||||
|
if [[ "$(trim $*)" = "-h" ]] || [[ "$(trim $*)" = "--help" ]] ; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$(which basename)" ]]; then
|
||||||
|
fatal 'It seems "basename" is not installed, but needed!'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$(which realpath)" ]]; then
|
||||||
|
fatal 'It seems "realpath" is not installed, but needed!'
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ==========
|
||||||
|
# - Begin Main Script
|
||||||
|
# ==========
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Read Configurations from $conf_file
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
|
||||||
|
# - Give your default values here
|
||||||
|
# -
|
||||||
|
LOGGING=false
|
||||||
|
|
||||||
|
if [[ -f "$conf_file" ]]; then
|
||||||
|
source "$conf_file"
|
||||||
|
else
|
||||||
|
warn "No configuration file '$conf_file' present.\n
|
||||||
|
Loading default values.."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Some pre-script tasks ..
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[1mDoing some pre-script tasks ..\033[m"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echononl "All is fine"
|
||||||
|
echo_ok
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Main part of script
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[1mMain part of script ..\033[m"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Some post-script tasks ..
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[1mDoing some post-script tasks ..\033[m"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean_up 0
|
32
snippets/cidr2mask.sh
Executable file
32
snippets/cidr2mask.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# - Convert CIDR to netmask
|
||||||
|
# -
|
||||||
|
cidr2mask() {
|
||||||
|
local i mask=""
|
||||||
|
local full_octets=$(($1/8))
|
||||||
|
local partial_octet=$(($1%8))
|
||||||
|
|
||||||
|
for ((i=0;i<4;i+=1)); do
|
||||||
|
if [ $i -lt $full_octets ]; then
|
||||||
|
mask+=255
|
||||||
|
elif [ $i -eq $full_octets ]; then
|
||||||
|
mask+=$((256 - 2**(8-$partial_octet)))
|
||||||
|
else
|
||||||
|
mask+=0
|
||||||
|
fi
|
||||||
|
test $i -lt 3 && mask+=.
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $mask
|
||||||
|
}
|
||||||
|
|
||||||
|
cidr=$1
|
||||||
|
mask=$(cidr2mask $cidr)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "cidr: $cidr - mask: $mask"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
17
snippets/conf/base_script.conf.sample
Normal file
17
snippets/conf/base_script.conf.sample
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# ==========
|
||||||
|
# - Configuration file for script base_script.sh
|
||||||
|
# ==========
|
||||||
|
|
||||||
|
# - LOGGING
|
||||||
|
# -
|
||||||
|
# - Enables/Disables script output. Setting this value to 'true' is
|
||||||
|
# - only useful if NOT running in a terminal (i.e. as cronjob).
|
||||||
|
# -
|
||||||
|
# - If script is running in a terminal, script output is enabled and
|
||||||
|
# - cannot be disabled.
|
||||||
|
# -
|
||||||
|
# - Running this script in a
|
||||||
|
# -
|
||||||
|
# - Default value: false
|
||||||
|
# -
|
||||||
|
#LOGGING=false
|
11
snippets/declare_i.sh
Executable file
11
snippets/declare_i.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
declare -i num=1
|
||||||
|
|
||||||
|
while [ $num -lt 128 ] ; do
|
||||||
|
ping -c 5 195.135.133.$num > /dev/null 2>&1;
|
||||||
|
if [ "$?" == 0 ]; then
|
||||||
|
echo 195.135.133.$num;
|
||||||
|
fi;
|
||||||
|
let num=$num+1
|
||||||
|
done
|
106
snippets/detect_os.sh
Executable file
106
snippets/detect_os.sh
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
detect_os_1 () {
|
||||||
|
|
||||||
|
if $(which lsb_release > /dev/null 2>&1) ; then
|
||||||
|
|
||||||
|
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
|
||||||
|
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
|
||||||
|
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
|
||||||
|
|
||||||
|
if [[ "$os_dist" = "debian" ]]; then
|
||||||
|
if $(echo "$os_version" | grep -q '\.') ; then
|
||||||
|
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif [[ -e "/etc/os-release" ]]; then
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
|
||||||
|
os_dist=$ID
|
||||||
|
os_version=${VERSION_ID}
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove whitespace from os_dist and os_version
|
||||||
|
os_dist="${os_dist// /}"
|
||||||
|
os_version="${os_version// /}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_os_2 ()
|
||||||
|
{
|
||||||
|
if [[ ( -z "${os}" ) && ( -z "${os_dist}" ) ]]; then
|
||||||
|
# some systems dont have lsb-release yet have the lsb_release binary and
|
||||||
|
# vice-versa
|
||||||
|
if [ -e /etc/lsb-release ]; then
|
||||||
|
. /etc/lsb-release
|
||||||
|
|
||||||
|
if [ "${ID}" = "raspbian" ]; then
|
||||||
|
os=${ID}
|
||||||
|
os_dist=`cut --delimiter='.' -f1 /etc/debian_version`
|
||||||
|
else
|
||||||
|
os=${DISTRIB_ID}
|
||||||
|
os_dist=${DISTRIB_CODENAME}
|
||||||
|
|
||||||
|
if [ -z "$os_dist" ]; then
|
||||||
|
os_dist=${DISTRIB_RELEASE}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif [ `which lsb_release 2>/dev/null` ]; then
|
||||||
|
os_dist=`lsb_release -c | cut -f2`
|
||||||
|
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
|
||||||
|
|
||||||
|
elif [ -e /etc/debian_version ]; then
|
||||||
|
# some Debians have jessie/sid in their /etc/debian_version
|
||||||
|
# while others have '6.0.7'
|
||||||
|
os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
|
||||||
|
if grep -q '/' /etc/debian_version; then
|
||||||
|
os_dist=`cut --delimiter='/' -f1 /etc/debian_version`
|
||||||
|
else
|
||||||
|
os_dist=`cut --delimiter='.' -f1 /etc/debian_version`
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
unknown_os
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$os_dist" ]; then
|
||||||
|
unknown_os
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove whitespace from OS and os_dist name
|
||||||
|
os="${os// /}"
|
||||||
|
os_dist="${os_dist// /}"
|
||||||
|
|
||||||
|
echo "Detected operating system as $os/$os_dist."
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_os_1
|
||||||
|
|
||||||
|
echo -e "\nOutput from function 'detect_os_1'"
|
||||||
|
echo "=================================="
|
||||||
|
|
||||||
|
echo "Distribution: ${os_dist}"
|
||||||
|
echo "Version: ${os_version}"
|
||||||
|
if [[ -n "$os_codename" ]]; then
|
||||||
|
echo "Codename: ${os_codename}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
os_dist=""
|
||||||
|
os_version=""
|
||||||
|
os_codename=""
|
||||||
|
|
||||||
|
echo -e "\nOutput from function 'detect_os_2'"
|
||||||
|
echo "=================================="
|
||||||
|
detect_os_2
|
||||||
|
|
||||||
|
echo "OS: $os"
|
||||||
|
echo "Dist: $os_dist"
|
||||||
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
exit
|
22
snippets/files/ban_ipv4.list
Normal file
22
snippets/files/ban_ipv4.list
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# - IPv4 addresses listet here will be completly banned by the firewall
|
||||||
|
# -
|
||||||
|
# - - Line beginning with '#' will be ignored.
|
||||||
|
# - - Blank lines will be ignored
|
||||||
|
# - - Only the first entry (until space sign or end of line) of each line will be considered.
|
||||||
|
# -
|
||||||
|
# - Valid values are:
|
||||||
|
# - complete IPv4 adresses like 1.2.3.4 (will be converted to 1.2.3.0/32)
|
||||||
|
# - partial IPv4 addresses like 1.2.3 (will be converted to 1.2.3.0/24)
|
||||||
|
# - network/nn CIDR notation like 1.2.3.0/27
|
||||||
|
# - network/netmask notaions like 1.2.3.0/255.255.255.0
|
||||||
|
# - network/partial_netmask like 1.2.3.4/255
|
||||||
|
# -
|
||||||
|
# - Note:
|
||||||
|
# - - wrong addresses like 1.2.3.256 or 1.2.3.4/33 will be ignored
|
||||||
|
# -
|
||||||
|
# - Example:
|
||||||
|
# - 79.171.81.0/24
|
||||||
|
# - 79.171.81.0/255.255.255.0
|
||||||
|
# - 79.171.81.0/255.255.255
|
||||||
|
# - 79.171.81
|
||||||
|
|
463
snippets/files/password.list
Normal file
463
snippets/files/password.list
Normal file
@ -0,0 +1,463 @@
|
|||||||
|
############################################################
|
||||||
|
# absent-friends.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# mail36.net #
|
||||||
|
############################################################
|
||||||
|
trotzig@mail36.net:wendland1
|
||||||
|
armin@mail36.net:Me8tallica
|
||||||
|
silke@mail36.net:24011979
|
||||||
|
sindikat@mail36.net:passwd314
|
||||||
|
michel@mail36.net:cikedece
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# access.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# agora-info.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# alte-socken.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# ansoko.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# antifa.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# antifa-kok.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# antifa-versand.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# anti-hartz-buendnis-nrw.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# antimilitarismustag.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# antimilitaristisch-unterwegs.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# anyplacebeforenow.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# archiv-kiel.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# autoorganisation.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# az-wuppertal.de #
|
||||||
|
############################################################
|
||||||
|
uschi-anschlag@az-wuppertal.de:sommer13
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# bamm.de #
|
||||||
|
############################################################
|
||||||
|
gerit@bamm.de:icke01
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# bdsberlin.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# bds-kampagne.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# beatleprint.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# bildungskritik.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# cilip.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# cinetrain.indyvideo.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# codecoop.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# datarecollective.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# desertoere.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# die-linkspartei.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# dosto.de #
|
||||||
|
############################################################
|
||||||
|
ahi@dosto.de:muhkuh2k
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# einstellung.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# freedom-for-thomas.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# fsi-geschichte.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# funk-the-system.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# g20-doku.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# g8andwar.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# gaypunk.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# geloebnix.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# gemeinsam-gegen-nazis.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# gipfelsoli.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# hamburgerwetter.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# hamburg.geloebnix.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# hh.geloebnix.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# hotmehl.com #
|
||||||
|
############################################################
|
||||||
|
oasch@hotmehl.com:oasch
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# iaadh.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# kamalatta.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# kill-hup.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# koelner-sozialforum.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# kpd-rz.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# krank-feiern.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# kreta-film.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# libertad.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# netzwerk-asyl.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# nolager.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# norden-gegen-g8.info #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# nsc.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# oh21.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# ohne-uns.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# opferperspektive.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# opfer-rechter-gewalt.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# ostpack.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# palaestina-solidaritaet.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# publicsolidarity.de #
|
||||||
|
############################################################
|
||||||
|
redaktion@publicsolidarity.de:prospekt17
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# redecontraviolencia.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# redfrentetransgenicos.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# rndm.biz #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# rojava-solidaritaet.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# schoenerfriedrichshain.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# schokoholic.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# s-e-d.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# so36.com #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# so36.de #
|
||||||
|
############################################################
|
||||||
|
fatma@so36.de:gayhanebleibt
|
||||||
|
crise@so36.de:kiez666
|
||||||
|
criselend@so36.de:roller36
|
||||||
|
monique@so36.de:Jule123
|
||||||
|
monique@so36.de:valentin1
|
||||||
|
stern89@so36.de:zk24.8r
|
||||||
|
post@so36.de:wurst42
|
||||||
|
chris@so36.de:akiraxs
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# so36.net #
|
||||||
|
############################################################
|
||||||
|
ckubu@so36.net:EadGl15E.%
|
||||||
|
leia@so36.net:f1n4lly
|
||||||
|
tobi@so36.net:blamblam67
|
||||||
|
tom@so36.net:THomas10
|
||||||
|
tom@so36.net:adelskrone
|
||||||
|
tom@so36.net:tompunk
|
||||||
|
acab@so36.net:irhab.6
|
||||||
|
acab@so36.net:zickezacke
|
||||||
|
schandmaul@so36.net:napalm
|
||||||
|
svenja@so36.net:fruhansen
|
||||||
|
svenja@so36.net:kaefer48
|
||||||
|
peace@so36.net:romuzuxe
|
||||||
|
peace@so36.net:scheisse
|
||||||
|
susi@so36.net:R2D2-f
|
||||||
|
ilker@so36.net:test123
|
||||||
|
idfx@so36.net:dlgesmsl.01
|
||||||
|
vitaminepille@so36.net:lecker6
|
||||||
|
defa-blendr@so36.net:azocomyw
|
||||||
|
christopher@so36.net:daredevil
|
||||||
|
altdel@so36.net:Knutson
|
||||||
|
altdel@so36.net:Knutson-01
|
||||||
|
altdel@so36.net:spitzwitz
|
||||||
|
daniel@so36.net:roFl0815
|
||||||
|
anke@so36.net:0119289011
|
||||||
|
andi@so36.net:malou
|
||||||
|
mio@so36.net:blonde redhead
|
||||||
|
mir@so36.net:somos
|
||||||
|
sanne@so36.net:xobolude
|
||||||
|
maria.schulz@so36.net:U120108681
|
||||||
|
mario@so36.net:holsten_
|
||||||
|
markus@so36.net:engagierthoch3
|
||||||
|
joe@so36.net:music
|
||||||
|
jonas@so36.net:hinzkunz
|
||||||
|
janmaat@so36.net:bumerang
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# so36net.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# so36.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# socialforum-berlin.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# sozialforum-berlin.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# speakerinnen.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# stop-torture.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# talk36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# uffmucken-schoeneweide.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# una-pt.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# verdammtlangquer.org #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# web.so36.net #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# womensrightsproject.de #
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# wuppertal-dichtmachen.de #
|
||||||
|
############################################################
|
||||||
|
|
22
snippets/get_next_uid_gid_pair.sh
Executable file
22
snippets/get_next_uid_gid_pair.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
min_uid=1000
|
||||||
|
|
||||||
|
declare -i _id=$(expr $min_uid - 1)
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
((_id++))
|
||||||
|
$(id $_id > /dev/null 2>&1) && continue
|
||||||
|
$(cat /etc/group | cut -d ':' -f3 | grep -q $_id 2> /dev/null) && continue
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo " Next free uid/gid pair:"
|
||||||
|
echo
|
||||||
|
echo -e " uid: \033[1m$_id\033[m"
|
||||||
|
echo -e " gid: \033[1m$_id\033[m"
|
||||||
|
echo
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
22
snippets/get_top_level_parent_pid.sh
Executable file
22
snippets/get_top_level_parent_pid.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function top_level_parent_pid {
|
||||||
|
# Look up the parent of the given PID.
|
||||||
|
pid=${1:-$$}
|
||||||
|
stat=($(</proc/${pid}/stat))
|
||||||
|
ppid=${stat[3]}
|
||||||
|
|
||||||
|
# /sbin/init always has a PID of 1, so if you reach that, the current PID is
|
||||||
|
# the top-level parent. Otherwise, keep looking.
|
||||||
|
if [[ ${ppid} -eq 1 ]] ; then
|
||||||
|
echo ${pid}
|
||||||
|
else
|
||||||
|
top_level_parent_pid ${ppid}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo "Top Level Parent Pid: $(top_level_parent_pid)"
|
||||||
|
echo "Top Level Command: $(ps -o cmd= $(top_level_parent_pid))"
|
||||||
|
|
||||||
|
exit 0
|
49
snippets/isValidDate.sh
Executable file
49
snippets/isValidDate.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
isDateInvalid()
|
||||||
|
{
|
||||||
|
DATE="${1}"
|
||||||
|
|
||||||
|
# Autorized separator char ['space', '/', '.', '_', '-']
|
||||||
|
SEPAR="([ \/._-])?"
|
||||||
|
|
||||||
|
# Date format day[01..31], month[01,03,05,07,08,10,12], year[1900..2099]
|
||||||
|
DATE_1="((([123][0]|[012][1-9])|3[1])${SEPAR}(0[13578]|1[02])${SEPAR}(19|20)[0-9][0-9])"
|
||||||
|
|
||||||
|
# Date format day[01..30], month[04,06,09,11], year[1900..2099]
|
||||||
|
DATE_2="(([123][0]|[012][1-9])${SEPAR}(0[469]|11)${SEPAR}(19|20)[0-9][0-9])"
|
||||||
|
|
||||||
|
# Date format day[01..28], month[02], year[1900..2099]
|
||||||
|
DATE_3="(([12][0]|[01][1-9]|2[1-8])${SEPAR}02${SEPAR}(19|20)[0-9][0-9])"
|
||||||
|
|
||||||
|
# Date format day[29], month[02], year[1904..2096]
|
||||||
|
DATE_4="(29${SEPAR}02${SEPAR}(19|20(0[48]|[2468][048]|[13579][26])))"
|
||||||
|
|
||||||
|
# Date 29.02.2000
|
||||||
|
DATE_5="(29${SEPAR}02${SEPAR}2000)"
|
||||||
|
|
||||||
|
# Match the date in the Regex
|
||||||
|
|
||||||
|
#if ! [[ "${DATE}" =~ ^(${DATE_1}|${DATE_2}|${DATE_3}|${DATE_4})$ ]]
|
||||||
|
#then
|
||||||
|
# echo -e "ERROR - '${DATE}' invalid!"
|
||||||
|
#else
|
||||||
|
# echo "${DATE} is valid"
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if [[ "${DATE}" =~ ^(${DATE_1}|${DATE_2}|${DATE_3}|${DATE_4}|${DATE_5})$ ]] ; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
if isDateInvalid "${1}" ; then
|
||||||
|
echo "inavalid Date: ${1}"
|
||||||
|
else
|
||||||
|
echo "${1} is valid."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
exit 0
|
30
snippets/isValisDate_cal.sh
Executable file
30
snippets/isValisDate_cal.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
DATE=$1
|
||||||
|
declare -i day
|
||||||
|
|
||||||
|
if [[ ${#DATE} -ne 10 ]] ; then
|
||||||
|
echo ""
|
||||||
|
echo "Invalid Date: $DATE"
|
||||||
|
echo ""
|
||||||
|
echo -e "Usage: \033[1m$(basename $0) YYYYMMDD\033[m"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval $(echo $DATE | sed 's/^\(....\)\(..\)\(..\)/year=\1 month=\2 day=\3/')
|
||||||
|
|
||||||
|
cal $month $year 2> /dev/null | grep -w $day > /dev/null
|
||||||
|
if [[ $? -eq 0 ]] ; then
|
||||||
|
echo ""
|
||||||
|
echo "Valid Date: $DATE"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "Invalid Date: $DATE"
|
||||||
|
echo ""
|
||||||
|
echo "Usage: $(basename $0) YYYYMMDD"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
19
snippets/is_chrooted.sh
Executable file
19
snippets/is_chrooted.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# - Test if script is running in a chrooted environment
|
||||||
|
# -
|
||||||
|
# - !! Script MUST run with root privileges!!
|
||||||
|
# -
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo -e "\n\tThis script must be run as root.\n" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$(stat -c %d:%i /)" = "$(stat -c %d:%i /proc/1/root/.)" ]]; then
|
||||||
|
echo -e "\n\tRunning NOT in a chrooted environment.\n"
|
||||||
|
else
|
||||||
|
echo -e "\n\tRunning in a chrooted environment.\n"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
57
snippets/is_number.sh
Executable file
57
snippets/is_number.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
is_number() {
|
||||||
|
|
||||||
|
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||||
|
|
||||||
|
# - also possible
|
||||||
|
# -
|
||||||
|
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||||
|
#return $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||||
|
}
|
||||||
|
|
||||||
|
is_int() {
|
||||||
|
return $(test "$@" -eq "$@" > /dev/null 2>&1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_int=-5
|
||||||
|
_number=5
|
||||||
|
_no_number=5a
|
||||||
|
|
||||||
|
echo -e "\nTest of valid number (positiv integer)"
|
||||||
|
if is_number $_number ; then
|
||||||
|
echo -e "\t$_number is a number"
|
||||||
|
else
|
||||||
|
echo -e "\t$_number is NOT a number"
|
||||||
|
fi
|
||||||
|
if is_number $_int ; then
|
||||||
|
echo -e "\t$_int is a number"
|
||||||
|
else
|
||||||
|
echo -e "\t$_int is NOT a number"
|
||||||
|
fi
|
||||||
|
if is_number $_no_number ; then
|
||||||
|
echo -e "\t$_no_number is a number"
|
||||||
|
else
|
||||||
|
echo -e "\t$_no_number is NOT a number"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\nTest of valid integer"
|
||||||
|
if is_int $_number ; then
|
||||||
|
echo -e "\t$_number is a valid integer"
|
||||||
|
else
|
||||||
|
echo -e "\t$_number is NOT a valid integer"
|
||||||
|
fi
|
||||||
|
if is_int $_int ; then
|
||||||
|
echo -e "\t$_int is a valid integer"
|
||||||
|
else
|
||||||
|
echo -e "\t$_int is NOT a valid integer"
|
||||||
|
fi
|
||||||
|
if is_int $_no_number ; then
|
||||||
|
echo -e "\t$_no_number is a valid integer"
|
||||||
|
else
|
||||||
|
echo -e "\t$_no_number is NOT a valid integer"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
exit 0
|
37
snippets/is_valid_ipv4.sh
Executable file
37
snippets/is_valid_ipv4.sh
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
## - Test of valid IPv4 Address
|
||||||
|
## -
|
||||||
|
## - Returns 0 if valid, > 0 otherwise
|
||||||
|
## -
|
||||||
|
is_valid_ipv4() {
|
||||||
|
local -a octets=( ${1//\./ } )
|
||||||
|
local RETURNVALUE=0
|
||||||
|
|
||||||
|
# return an error if the IP doesn't have exactly 4 octets
|
||||||
|
[[ ${#octets[@]} -ne 4 ]] && return 1
|
||||||
|
|
||||||
|
for octet in ${octets[@]}
|
||||||
|
do
|
||||||
|
if [[ ${octet} =~ ^[0-9]{1,3}$ ]]
|
||||||
|
then # shift number by 8 bits, anything larger than 255 will be > 0
|
||||||
|
((RETURNVALUE += octet>>8 ))
|
||||||
|
else # octet wasn't numeric, return error
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return ${RETURNVALUE}
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "X$@" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mNo argumnet given!\033[m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_valid_ipv4 $@ ; then
|
||||||
|
echo -e "\n\t\033[32m\033[1m$@ is a valid IPv4 Address\033[m\n"
|
||||||
|
else
|
||||||
|
echo -e "\n\t\033[31m\033[1m$@ is NOT a valid IPv4 Address\033[m\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
34
snippets/mask2cidr.sh
Executable file
34
snippets/mask2cidr.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Function calculates number of bit in a netmask
|
||||||
|
#
|
||||||
|
mask2cidr() {
|
||||||
|
nbits=0
|
||||||
|
IFS=.
|
||||||
|
for dec in $1 ; do
|
||||||
|
case $dec in
|
||||||
|
255) let nbits+=8;;
|
||||||
|
254) let nbits+=7;;
|
||||||
|
252) let nbits+=6;;
|
||||||
|
248) let nbits+=5;;
|
||||||
|
240) let nbits+=4;;
|
||||||
|
224) let nbits+=3;;
|
||||||
|
192) let nbits+=2;;
|
||||||
|
128) let nbits+=1;;
|
||||||
|
0);;
|
||||||
|
*) echo "Error: $dec is not recognised"; exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "$nbits"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mask=$1
|
||||||
|
cidr=$(mask2cidr $mask)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "cidr: $cidr - mask: $mask"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
28
snippets/netmask2cidr.sh
Executable file
28
snippets/netmask2cidr.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
netmask2cidr() {
|
||||||
|
case $1 in
|
||||||
|
0x*)
|
||||||
|
local hex=${1#0x*} quad=
|
||||||
|
while [ -n "${hex}" ]; do
|
||||||
|
local lastbut2=${hex#??*}
|
||||||
|
quad=${quad}${quad:+.}0x${hex%${lastbut2}*}
|
||||||
|
hex=${lastbut2}
|
||||||
|
done
|
||||||
|
set -- ${quad}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local i= len=
|
||||||
|
local IFS=.
|
||||||
|
for i in $1; do
|
||||||
|
while [ ${i} != "0" ]; do
|
||||||
|
len=$((${len} + ${i} % 2))
|
||||||
|
i=$((${i} >> 1))
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${len}"
|
||||||
|
}
|
||||||
|
|
||||||
|
netmask2cidr $1
|
31
snippets/qsort.sh
Executable file
31
snippets/qsort.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# quicksorts positional arguments
|
||||||
|
# return is in array qsort_ret
|
||||||
|
qsort() {
|
||||||
|
local pivot i smaller=() larger=()
|
||||||
|
qsort_ret=()
|
||||||
|
(($#==0)) && return 0
|
||||||
|
pivot=$1
|
||||||
|
shift
|
||||||
|
for i; do
|
||||||
|
if [[ $i < $pivot ]]; then
|
||||||
|
smaller+=( "$i" )
|
||||||
|
else
|
||||||
|
larger+=( "$i" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
qsort "${smaller[@]}"
|
||||||
|
smaller=( "${qsort_ret[@]}" )
|
||||||
|
qsort "${larger[@]}"
|
||||||
|
larger=( "${qsort_ret[@]}" )
|
||||||
|
qsort_ret=( "${smaller[@]}" "$pivot" "${larger[@]}" )
|
||||||
|
}
|
||||||
|
|
||||||
|
array=(a c b "f f" 3 5)
|
||||||
|
|
||||||
|
qsort "${array[@]}"
|
||||||
|
|
||||||
|
declare -p qsort_ret
|
||||||
|
|
||||||
|
exit 0
|
31
snippets/read_first_char_of_file.sh
Executable file
31
snippets/read_first_char_of_file.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# - Read first charactor of a file:
|
||||||
|
# -
|
||||||
|
# - head -c1 <path-to-file>
|
||||||
|
|
||||||
|
deb_major_version=""
|
||||||
|
|
||||||
|
is_number() {
|
||||||
|
|
||||||
|
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||||
|
|
||||||
|
# - also possible
|
||||||
|
# -
|
||||||
|
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||||
|
#return $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -f "/etc/debian_version" ]]; then
|
||||||
|
|
||||||
|
deb_major_version=$(head -c1 /etc/debian_version)
|
||||||
|
if is_number $deb_major_version ; then
|
||||||
|
echo -e "\n\tDebian Major Version: $deb_major_version\n"
|
||||||
|
else
|
||||||
|
echo -e "\n\tNo numeric Version given. Debian Version: $(head -1 /etc/debian_version)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "\nFile '/etc/debian_version' not found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
158
snippets/read_ipv4_from_file.sh
Executable file
158
snippets/read_ipv4_from_file.sh
Executable file
@ -0,0 +1,158 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
ipv4_list_file="files/ban_ipv4.list"
|
||||||
|
|
||||||
|
if [[ ! -f "$ipv4_list_file" ]] ; then
|
||||||
|
echo ""
|
||||||
|
echo " File '$ipv4_list_file' not found'"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -a octets
|
||||||
|
declare -i index
|
||||||
|
|
||||||
|
while IFS='' read -r _line || [[ -n $_line ]] ; do
|
||||||
|
|
||||||
|
is_valid_ipv4=true
|
||||||
|
is_valid_mask=true
|
||||||
|
ipv4=""
|
||||||
|
mask=""
|
||||||
|
|
||||||
|
# Ignore comment lines
|
||||||
|
#
|
||||||
|
[[ $_line =~ ^[[:space:]]{0,}# ]] && continue
|
||||||
|
|
||||||
|
# Ignore blank lines
|
||||||
|
#
|
||||||
|
[[ $_line =~ ^[[:space:]]*$ ]] && continue
|
||||||
|
|
||||||
|
# Remove leading whitespace characters
|
||||||
|
#
|
||||||
|
_line="${_line#"${_line%%[![:space:]]*}"}"
|
||||||
|
|
||||||
|
|
||||||
|
# Catch IPv4 Address
|
||||||
|
#
|
||||||
|
given_ipv4="$(echo $_line | cut -d ' ' -f1)"
|
||||||
|
|
||||||
|
|
||||||
|
# Splitt Ipv4 address from possible given CIDR number
|
||||||
|
#
|
||||||
|
IFS='/' read -ra _addr <<< "$given_ipv4"
|
||||||
|
_ipv4="${_addr[0]}"
|
||||||
|
|
||||||
|
if [[ -n "${_addr[1]}" ]] ; then
|
||||||
|
_mask="${_addr[1]}"
|
||||||
|
test_netmask=false
|
||||||
|
|
||||||
|
# Is 'mask' a valid CIDR number? If not, test agains a valid netmask
|
||||||
|
#
|
||||||
|
if $(test -z "${_mask##*[!0-9]*}" > /dev/null 2>&1) ; then
|
||||||
|
|
||||||
|
# Its not a vaild mask number, but naybe a valit netmask.
|
||||||
|
#
|
||||||
|
test_netmask=true
|
||||||
|
else
|
||||||
|
if [[ $_mask -gt 32 ]]; then
|
||||||
|
|
||||||
|
# Its not a vaild cidr number, but naybe a valit netmask.
|
||||||
|
#
|
||||||
|
test_netmask=true
|
||||||
|
else
|
||||||
|
|
||||||
|
# OK, we have a vaild cidr number between '0' and '32'
|
||||||
|
#
|
||||||
|
mask=$_mask
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test if given '_mask' is a valid netmask.
|
||||||
|
#
|
||||||
|
if $test_netmask ; then
|
||||||
|
octets=( ${_mask//\./ } )
|
||||||
|
|
||||||
|
# Complete netmask if necessary
|
||||||
|
#
|
||||||
|
while [[ ${#octets[@]} -lt 4 ]]; do
|
||||||
|
octets+=(0)
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ ${#octets[@]} -gt 4 ]] && is_valid_mask=false
|
||||||
|
|
||||||
|
index=0
|
||||||
|
for octet in ${octets[@]} ; do
|
||||||
|
if [[ ${octet} =~ ^[0-9]{1,3}$ ]] ; then
|
||||||
|
if [[ $octet -gt 255 ]] ; then
|
||||||
|
is_valid_mask=false
|
||||||
|
fi
|
||||||
|
if [[ $index -gt 0 ]] ; then
|
||||||
|
mask="${mask}.${octet}"
|
||||||
|
else
|
||||||
|
mask="${octet}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
is_valid_mask=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
((index++))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
adjust_mask=false
|
||||||
|
else
|
||||||
|
mask=32
|
||||||
|
adjust_mask=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Splitt given address into their octets
|
||||||
|
#
|
||||||
|
octets=( ${_ipv4//\./ } )
|
||||||
|
|
||||||
|
# Complete IPv4 address if necessary
|
||||||
|
#
|
||||||
|
while [[ ${#octets[@]} -lt 4 ]]; do
|
||||||
|
octets+=(0)
|
||||||
|
|
||||||
|
# Only adjust CIDR number if not given
|
||||||
|
#
|
||||||
|
if $adjust_mask ; then
|
||||||
|
mask="$(expr $mask - 8)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Pre-check if given IPv4 Address seems to be a valid address
|
||||||
|
#
|
||||||
|
[[ ${#octets[@]} -gt 4 ]] && is_valid_ipv4=false
|
||||||
|
|
||||||
|
# Check if given IPv4 Address is a valid address
|
||||||
|
#
|
||||||
|
if $is_valid_ipv4 ; then
|
||||||
|
index=0
|
||||||
|
for octet in ${octets[@]} ; do
|
||||||
|
if [[ ${octet} =~ ^[0-9]{1,3}$ ]] ; then
|
||||||
|
if [[ $octet -gt 255 ]] ; then
|
||||||
|
is_valid_ipv4=false
|
||||||
|
fi
|
||||||
|
if [[ $index -gt 0 ]] ; then
|
||||||
|
ipv4="${ipv4}.${octet}"
|
||||||
|
else
|
||||||
|
ipv4="${octet}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
is_valid_ipv4=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
((index++))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $is_valid_ipv4 && $is_valid_mask; then
|
||||||
|
echo " ${ipv4}/${mask}"
|
||||||
|
else
|
||||||
|
echo " '$given_ipv4' isn't a valid IPv4 address"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done < ban_ipv4.list
|
97
snippets/read_yaml.sh
Executable file
97
snippets/read_yaml.sh
Executable file
@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# - See: https://gist.github.com/epiloque/8cf512c6d64641bde388
|
||||||
|
# -
|
||||||
|
# - Changes from the original (see above url:
|
||||||
|
# - if the yaml file contains carriage returns, the processing will fail.
|
||||||
|
# - In this case, I made a fix on this line (currently line 14)
|
||||||
|
# -
|
||||||
|
# - fs="$(echo @|tr @ '\034')"
|
||||||
|
# -
|
||||||
|
# - so it became
|
||||||
|
# - fs="$(echo @|tr @ '\034'|tr -d '\015')"
|
||||||
|
# -
|
||||||
|
# - NOTE!
|
||||||
|
# - The indent of the yaml configuration file is "2"
|
||||||
|
# -
|
||||||
|
# - If you want your indentation to be 4 spaces instead of 2 change this line:
|
||||||
|
# - indent = length($1)/2;
|
||||||
|
# - to be this:
|
||||||
|
# - indent = length($1)/4;
|
||||||
|
# -
|
||||||
|
|
||||||
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
|
# - This file will be created. (see below..)
|
||||||
|
# -
|
||||||
|
example_yaml_config_file="${working_dir}/files/example_yaml_config.yml"
|
||||||
|
|
||||||
|
parse_yaml() {
|
||||||
|
local prefix=$2
|
||||||
|
local s
|
||||||
|
local w
|
||||||
|
local fs
|
||||||
|
s='[[:space:]]*'
|
||||||
|
w='[a-zA-Z0-9_]*'
|
||||||
|
#fs="$(echo @|tr @ '\034')"
|
||||||
|
fs="$(echo @|tr @ '\034'|tr -d '\015')"
|
||||||
|
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
|
||||||
|
-e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" |
|
||||||
|
awk -F"$fs" '{
|
||||||
|
indent = length($1)/2;
|
||||||
|
vname[indent] = $2;
|
||||||
|
for (i in vname) {if (i > indent) {delete vname[i]}}
|
||||||
|
if (length($3) > 0) {
|
||||||
|
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
|
||||||
|
printf("%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, $3);
|
||||||
|
}
|
||||||
|
}' | sed 's/_=/+=/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
cat <<EOF > "$example_yaml_config_file"
|
||||||
|
development:
|
||||||
|
adapter: mysql2
|
||||||
|
encoding: utf8
|
||||||
|
database: my_database
|
||||||
|
username: root
|
||||||
|
password:
|
||||||
|
apt:
|
||||||
|
- somepackage
|
||||||
|
- anotherpackage
|
||||||
|
EOF
|
||||||
|
|
||||||
|
eval $(parse_yaml "$example_yaml_config_file" "optional_prefix_")
|
||||||
|
#parse_yaml $example_yaml_config_file "optional_prefix"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------"
|
||||||
|
echo "- Read yaml configuration file"
|
||||||
|
echo "-------------------"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "$example_yaml_config_file:"
|
||||||
|
cat $example_yaml_config_file
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\nUsing with optional prefix 'optional_prefix_'"
|
||||||
|
echo "============================================="
|
||||||
|
echo -e "\t\033[32meval \$(parse_yaml \"$example_yaml_config_file\" "optional_prefix_")\033[m"
|
||||||
|
echo ""
|
||||||
|
echo -e "\t\${optional_prefix_development_adapter}: ${optional_prefix_development_adapter}"
|
||||||
|
echo -e "\t\${optional_prefix_development_apt[@]}: ${optional_prefix_development_apt[@]}"
|
||||||
|
|
||||||
|
|
||||||
|
eval $(parse_yaml "$example_yaml_config_file" )
|
||||||
|
#parse_yaml $example_yaml_config_file "optional_prefix"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\nUsing without optional prefix "
|
||||||
|
echo "=============================="
|
||||||
|
echo -e "\t\033[32meval \$(parse_yaml \"$example_yaml_config_file\" )\033[m"
|
||||||
|
echo ""
|
||||||
|
echo -e "\t\${development_adapter}: ${development_adapter}"
|
||||||
|
echo -e "\t\${development_apt[@]}: ${development_apt[@]}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
rm "$example_yaml_config_file"
|
||||||
|
exit 0
|
21
snippets/sort_array.sh
Executable file
21
snippets/sort_array.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
array=("a c" b f "Change" "3 5")
|
||||||
|
IFS=$'\n' sorted=($(sort <<<"${array[*]}"))
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "Print out array elemnts (for loop)"
|
||||||
|
echo "=================================="
|
||||||
|
for val in ${sorted[@]} ; do
|
||||||
|
echo -e "\t$val"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "Print out array elemnts (printf)"
|
||||||
|
echo "================================"
|
||||||
|
printf "\t%s\n" "${sorted[@]}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
exit
|
41
snippets/test_mail_paswd.sh
Executable file
41
snippets/test_mail_paswd.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_dir="$(dirname $(realpath $0))"
|
||||||
|
passwd_file="${script_dir}/files/password.list"
|
||||||
|
|
||||||
|
if [[ ! -f "$passwd_file" ]] ; then
|
||||||
|
echo ""
|
||||||
|
echo -e " [ \033[31m\033[1mFatal\033[m ] File '$passwd_file' not found!"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#imap_server="imap.so36.net"
|
||||||
|
imap_server="localhost"
|
||||||
|
|
||||||
|
if [[ $imap_server =~ ^127\.0\.0\.1 ]] || [[ $imap_server =~ ^localhost ]]; then
|
||||||
|
imap_protocol="imap"
|
||||||
|
else
|
||||||
|
imap_protocol="imaps"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
set +H
|
||||||
|
while IFS=':' read -r email passwd || [[ -n $email ]] ; do
|
||||||
|
|
||||||
|
[[ $email =~ ^\s*$ ]] && continue
|
||||||
|
[[ $email =~ ^\s*# ]] && continue
|
||||||
|
|
||||||
|
echo -en " Test given password for email \033[1m$email\\033[m .."
|
||||||
|
curl --url "${imap_protocol}://${imap_server}" --user "${email}:${passwd}" > /dev/null 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo -e "\033[1G [ \033[31m\033[1mWarning\033[m ]: Password for \033[1m$email\033[m is unsafe!"
|
||||||
|
else
|
||||||
|
echo -e "\033[1G [ \033[32mOk\033[m ]: Password for '$email' does not match password list."
|
||||||
|
fi
|
||||||
|
|
||||||
|
done < "$passwd_file"
|
||||||
|
set -H
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
exit 0
|
60
snippets/tolower.sh
Executable file
60
snippets/tolower.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
string="Hallo Welt!"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "string: $string"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - Bash 4
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "Bash 4"
|
||||||
|
echo " \${string,,}"
|
||||||
|
echo ""
|
||||||
|
echo "string: ${string,,}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - tr
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "tr"
|
||||||
|
echo " echo \"\$string\" | tr '[:upper:]' '[:lower:]'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - awk
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "awk"
|
||||||
|
echo " echo \"\$string\" | awk '{print tolower(\$0)}'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | awk '{print tolower($0)}')"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - sed
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "sed"
|
||||||
|
echo " echo \"\$string\" | sed -e 's/\(.*\)/\L\1/'"
|
||||||
|
echo ""
|
||||||
|
echo " sed -e 's/\(.*\)/\L\1/' <<< \"\$string\""
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | sed -e 's/\(.*\)/\L\1/')"
|
||||||
|
echo "string: $(sed -e 's/\(.*\)/\L\1/' <<< "$string")"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - Perl
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "Perl"
|
||||||
|
echo " echo \"\$string\" | perl -ne 'print lc'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | perl -ne 'print lc')"
|
||||||
|
echo ""
|
60
snippets/toupper.sh
Executable file
60
snippets/toupper.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
string="Hallo Welt!"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "string: $string"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - Bash 4
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "Bash 4"
|
||||||
|
echo " \${string^^}"
|
||||||
|
echo ""
|
||||||
|
echo "string: ${string^^}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - tr
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "tr"
|
||||||
|
echo " echo \"\$string\" | tr '[:lower:]' '[:upper:]'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | tr '[:lower:]' '[:upper:]')"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - awk
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "awk"
|
||||||
|
echo " echo \"\$string\" | awk '{print toupper(\$0)}'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | awk '{print toupper($0)}')"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - sed
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "sed"
|
||||||
|
echo " echo \"\$string\" | sed -e 's/\(.*\)/\U\1/'"
|
||||||
|
echo ""
|
||||||
|
echo " sed -e 's/\(.*\)/\U\1/' <<< \"\$string\""
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | sed -e 's/\(.*\)/\U\1/')"
|
||||||
|
echo "string: $(sed -e 's/\(.*\)/\U\1/' <<< "$string")"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# - Perl
|
||||||
|
# -
|
||||||
|
echo "______"
|
||||||
|
echo "Perl"
|
||||||
|
echo " echo \"\$string\" | perl -ne 'print uc'"
|
||||||
|
echo ""
|
||||||
|
echo "string: $(echo "$string" | perl -ne 'print uc')"
|
||||||
|
echo ""
|
19
snippets/trim.sh
Executable file
19
snippets/trim.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
local var="$*"
|
||||||
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||||
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||||
|
echo -n "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
var=" - Hallo Welt - "
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo " |${var}|"
|
||||||
|
|
||||||
|
var="$(trim $var)"
|
||||||
|
echo " |${var}|"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user