This commit is contained in:
2024-10-13 23:27:09 +02:00
commit 30627b25b3
48 changed files with 1919 additions and 0 deletions

826
1 Minitools/bashrc Normal file
View File

@@ -0,0 +1,826 @@
#VERSION 58
#DATUM 05.02.2019
# source <(curl https://andre:mesh-assort2@config.andregeissler.de/bashrc1)
# curl https://andre:mesh-assort2@config.andregeissler.de/bashrc1 > ~/.bashrc
# apt-get install iproute2 dnsutils curl
# source <(curl https://andre:mesh-assort2@config.andregeissler.de/bashrc1)
alias ll='ls -haltr'
alias ppm="sudo perl -MCPAN -e 'shell'"
alias upall='apt-get update -y ; apt-get upgrade -y --allow-unauthenticated ; apt-get autoremove -y'
alias nst='netstat -an | grep -i listen'
alias iptables_s='iptables -nvL'
alias sud='sudo -E -H bash'
alias snmp3A='snmpwalk -v3 -a SHA -A K01v1kk0! -u fote98 -l authnopriv $1 $2'
alias snmp3AP='snmpwalk -v3 -a SHA -A K01v1kk0! -x AES -X K01v1kk0 -u fote98 -l authpriv $1 $2'
alias snmp3a='snmpwalk -v3 -a SHA -A AuthPass01 -u SNMPUser -l authnopriv $1 $2'
alias snmp3ap='snmpwalk -v3 -a SHA -A AuthPass01 -x AES -X PrivPass01 -u SNMPUser -l authpriv $1 $2'
alias grepv='grep -v grep | grep'
alias update_bashrc='curl -s -H "Cache-Control: no-cache" https://andre:mesh-assort2@config.andregeissler.de/bashrc1 > ~/.bashrc'
alias assh='ssh -X -l andre $1'
alias cssh='ssh -X -l conetadm $1'
alias rssh='ssh -X -l rancid $1'
alias r11='rssh 10.101.0.11'
alias ovn='sudo openvpn --script-security 2 --config /home/andre/Nextcloud/client.ovpn'
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
export SSHK="ssh-dss AAAAB3NzaC1kc3MAAACBAMNkMHw/xuJcU3Vhg7qHynpwMFo4Lx6D/0OA1dkhLiENtW4GZTjKT2Vt+kmt9t2tpNUrZnFVPbVbTKDDkFCrc9tXM74SkE9xBxssZ4fUyQVmWMzIkMcgw6cqgNODwJOmtFdxg7KNCi5Xi2YGol8yexxzcKNd4uv3KxeyjdOsc2wZAAAAFQDiWmZgli+aNmpYDWn43KRNyK4qSQAAAIEAiBz9Jj2TfRqAQRTEUahUkSRVU9gms1g9MWmGArIH51fi71raZc7iApybSSEgV93VySaRZ+jq7W4j23JNF9WHDQn1oqPAqw+3pNtgdeQb7i4Ic7oEJ6gYxrXuvhweiJKceC9o84yv41bLSw5QELIQ9tr/JKaa7/lHDVYgWiPhWeEAAACBAK0b5iNzqitsSs3+H/QkOPYrdSNPb68wbImxD+Zber7nHYMjxpwxCAORarxNL6Gfaxz0Ghs/T0IhO9cQ9inY8QWe9kS3ZVxfuZrTvR0ZVnstePo1AsQ6cPCJ9BUVsIGfOF8PNwXf16EUDaulTjBm1DHiLuNdcVU81MfZg914/z67 andre@debian"
export SSHKE="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVlToAoVM6DH3UU/duHc31IknfvFoOsV7DPEh+xnP2XY70l70I+RNiXEWYJ6wgBmlml2txhNG9BPLmZLN/8sfR0W7nM+1nc+Qx0FQcj/3mEWQhhAXcRwbBucCGlbIr4viBnSVYPN6JI4yS5VG4xQXGjD2ZyA9/v8ubx+Cv7lQyG66XcE8nUzENyUP4ntcvdou9O7mRStAzihJo/I7P+PnvMokz2kiP+pehll7zO/b5gliEzhQq/Bsavj5FlQwMhOmZXxR9rafJ08R1SAAE2U2Gus6nmD+iR0rqv8/ugHCKkMCX+DFxJP6iTRbuStl8WZf8utxym83YnM3wqGeeUdMP andre@debian"
export GPGKEY=13FAA6FC
export EDITOR=vi
# export PERL_MB_OPT="--install_base \"/home/andre/perl5\""
# export PERL_MM_OPT="INSTALL_BASE=/home/andre/perl5"
export PERL_MM_USE_DEFAULT=1
export PATH=$PATH:.:~:/install/:/opt/Oracle_Java/jre1.7.0_79/bin:/home/andre/scripts/:
export SSH_PERS_ENV_FILES=".bashrc"
export PROMPT_DIRTRIM=2
color_prompt=yes
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \n\[\033[01;33m\]\t \[\033[01;34m\]\$\[\033[00m\] '
export HISTCONTROL="ignorespace"
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%F %T "
shopt -s histappend
shopt -s cmdhist
shopt -s dotglob
shopt -s expand_aliases
arg_help() {
echo "Aliases
ll ppm sb upall nst iptables_s sud snmp3A snmp3AP snmp3a snmp3ap grepv update_bashrc
assh cssh rssh
Funktionen
arg_help sshcl(clogin) sshh(hop) sshl(local) sshll(list local) asdm asdmns svncom screen_h sudo_h iptables_h
init.d_h install_ssh_key delete_files_older update_ssh_personal_environment
ssh_personal_config install_ssh_personal_config logrotate cping eping mount_all rdp
setjava setjava6|7|8 sysinfo
"
}
C_BLACK="\e[38;5;0m"
C_RED="\e[38;5;1m"
C_GREEN="\e[38;5;2m"
C_YELLOW="\e[38;5;3m"
C_BLUE="\e[38;5;4m"
C_PURPLE="\e[38;5;5m"
C_CYAN="\e[38;5;6m"
C_LIGHTGRAY="\e[38;5;7m"
C_GRAY="\e[38;5;8m"
C_PEACH="\e[38;5;9m"
C_LIGHTGREEN="\e[38;5;10m"
C_LIGHTYELLOW="\e[38;5;11m"
C_LIGHTBLUE="\e[38;5;12m"
C_PINK="\e[38;5;13m"
C_LIGHTCYAN="\e[38;5;14m"
C_WHITE="\e[38;5;15m"
C_NO="\e[0;00m"
BG_BLACK="\e[48;5;0m"
BG_RED="\e[48;5;1m"
BG_GREEN="\e[48;5;2m"
BG_YELLOW="\e[48;5;3m"
BG_BLUE="\e[48;5;4m"
BG_PURPLE="\e[48;5;5m"
BG_CYAN="\e[48;5;6m"
BG_LIGHTGRAY="\e[48;5;7m"
BG_GRAY="\e[48;5;8m"
BG_PEACH="\e[48;5;9m"
BG_LIGHTGREEN="\e[48;5;10m"
BG_LIGHTYELLOW="\e[48;5;11m"
BG_LIGHTBLUE="\e[48;5;12m"
BG_PINK="\e[48;5;13m"
BG_LIGHTCYAN="\e[48;5;14m"
BG_WHITE="\e[48;5;15m"
BG_NO="\e[0;00m"
sysinfo() {
if [ "$USER" != "root" ]; then
echo -e $C_RED$BG_WHITE"Not root"$C_NO
return
fi
export LANG=us_US
echo -e $C_LIGHTGREEN"Release"$C_NO
echo -en $C_CYAN" Distributor "$C_NO; lsb_release -ad 2>&1 | grep -v modules | grep "Distributor" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i' 2>&1
echo -en $C_CYAN" Description "$C_NO; lsb_release -ad 2>&1 | grep -v modules | grep "Description" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i' 2>&1
echo -en $C_CYAN" Release "$C_NO; lsb_release -ad 2>&1 | grep -v modules | grep "Release" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i' 2>&1
echo -en $C_CYAN" Codename "$C_NO; lsb_release -ad 2>&1 | grep -v modules | grep "Codename" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i' 2>&1
echo ""
echo -e $C_LIGHTGREEN"CPU Info"$C_NO
echo -en $C_CYAN" Architecture "$C_NO; lscpu | grep "Architecture:" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i'
echo -en $C_CYAN" CPUs "$C_NO; lscpu | grep -v NUMA | grep "CPU(s):" | awk -F: '{print $2}' | sed 's/[0-9]*$//i'
echo -en $C_CYAN" Threads "$C_NO; lscpu | grep "Thread(s)" | awk -F: '{print $2}' | sed 's/[0-9]$//i'
echo -en $C_CYAN" Cores "$C_NO; lscpu | grep "Core(s)" | awk -F: '{print $2}' | sed 's/[0-9]$//i'
echo -en $C_CYAN" Model "$C_NO; lscpu | grep "Model name:" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i'
MIN=$(lscpu | grep "CPU min")
MAX=$(lscpu | grep "CPU max")
MHZ=$(lscpu | grep "CPU MHz")
echo -en $C_CYAN" CPU Speed (min/max/now) "$C_NO; echo "$MIN/$MAX/$MHZ"
echo -en $C_CYAN" Bogo "$C_NO; lscpu | grep "Bogo" | awk -F: '{print $2}' | sed 's/[^A-Za-z0-9]//i'
echo ""
echo -e $C_LIGHTGREEN"System Info"$C_NO
dmidecode | grep Base -A 10 | grep Manufact
dmidecode | grep Base -A 10 | grep Product
dmidecode | grep Base -A 10 | grep Version
dmidecode | grep Base -A 10 | grep Serial
echo ""
echo -e $C_LIGHTGREEN"Memory Info"$C_NO
echo -n "total "; free -m | grep Mem | awk '{ print $2 }'
echo -n "used "; free -m | grep Mem | awk '{ print $3 }'
echo -n "free "; free -m | grep Mem | awk '{ print $4 }'
echo -n "shared "; free -m | grep Mem | awk '{ print $5 }'
echo -n "buff/cache "; free -m | grep Mem | awk '{ print $6 }'
echo -n "avail "; free -m | grep Mem | awk '{ print $7 }'
echo ""
echo -e $C_LIGHTGREEN"Swap Info"$C_NO
echo -n "total "; free -m | grep Swap | awk '{ print $2 }'
echo -n "used "; free -m | grep Swap | awk '{ print $3 }'
echo -n "free "; free -m | grep Swap | awk '{ print $4 }'
}
rdp() {
OUTPUT=$(zenity --forms --title="Remote Desktop" --text="Connection Settings" \
--add-entry="Server" \
--add-entry="User" \
--add-password="Password" \
--add-entry="Domain")
ip=$(awk -F'|' '{print $1}' <<<$OUTPUT)
us=$(awk -F'|' '{print $2}' <<<$OUTPUT)
pa=$(awk -F'|' '{print $3}' <<<$OUTPUT)
do=$(awk -F'|' '{print $4}' <<<$OUTPUT)
if [ "$ip" == "" ] || [ "$us" == "" ] || [ "$pa" == "" ] || [ "$do" == "" ]
then
echo Angaben unvollständig!
else
rdesktop -D -a24 -g 1680x950 -u $us -d $do -p $pa $ip &
fi
ip=
us=
pa=
do=
OUTPUT=
}
setjava6() {
setjava 6
}
setjava7() {
setjava 7
}
setjava8() {
setjava 8
}
setjava() {
export J=$1
export P=`update-alternatives --list java | grep oracle | grep java-$J`
sudo update-alternatives --set java $P
export P=`update-alternatives --list javaws | grep oracle | grep java-$J`
sudo update-alternatives --set javaws $P
}
pptail() {
# PortProblemTail
tail -f $1 | grep -E "LINK-3-UPDOWN|PORT-5-IF_DOWN_LINK_FAILURE|LINEPROTO-5-UPDOWN|PORT-5-IF_UP|CANNOT_BUNDLE|SNMP-4-HIGHCPU|Excessive Broadcast|Excessive CRC|Duplex Mismatch|Excessive late|Excessive link state|High collision|Excessive undersized|Excessive jabbering"
}
sshcl() {
# ssh clogin
ENV=$1
HOSTNAME=$2
COMMAND=$3
if [ "$1" == "ksa" ]; then
IP=10.140.8.100
PAT="/var/lib/rancid/bin"
fi
if [ "$1" == "flw" ]; then
IP=10.140.8.100
PAT="/var/lib/rancid/bin"
fi
if [ "$1" == "con" ]; then
IP=10.101.0.11
PAT="/home/rancid/bin"
fi
if [ "$3" != "" ]; then
ssh -l rancid $IP "$PAT/clogin -c \"$3\" $2"
else
ssh -l rancid $IP "$PAT/clogin $2"
fi
}
sshh() {
# ssh hops
HOPS=""
HOPS=$@
append=""
comd=""
for h in $HOPS
do
append="ssh -A -X -t $h "
comd=$comd$append
append=""
done
echo $comd
$comd
}
sshl() {
# ssh local
if [ "$1" == "home" ]; then
echo ""
echo "ssh 127.0.0.1:822 -> ssh://debian1:22/"
echo "observium 127.0.0.1:880 -> http://debian1:80/"
echo "ssh 127.0.0.1:1322 -> ssh://omv3:22/"
echo "omv3 127.0.0.1:1380 -> http://omv3:80/"
echo "pyLoad 127.0.0.1:1388 -> http://omv3:8888/"
echo "asa 127.0.0.1:2443 -> https://asa:443/"
echo "phpvboxweb 127.0.0.1:580 -> http://server:80/phpvirtualbox"
echo ""
sudo ssh -L 822:192.168.100.8:22 -L 880:192.168.100.8:80 -L 1322:192.168.100.13:22 -L 1380:192.168.100.13:80 -L 1388:192.168.100.13:8888 -L 2443:192.168.100.2:443 -L 580:192.168.100.5:80 andre@vpn-andregeissler.ddns.net -p 54321
elif [ "$5" == "" ]; then
echo sshl LOKALER_PORT REMOTE_HOST REMOTE_PORT PROXYUSER PROXYSERVER
echo "Beispiel:"
echo " sshl 2222 192.168.100.13 8888 andre vpn-andregeissler.ddns.net"
echo " ermöglicht connect auf localhost:2222 um vom user andre auf "
echo " vpn-andregeissler.ddns.net auf 192.168.100.13:8888"
echo " getunnelt zu werden"
elif [ "$6" == "" ]; then
echo kein Port angegeben
ssh -L $1:$2:$3 $4@$5
else
echo Port angegeben
ssh -L $1:$2:$3 S4@S% -p $6
fi
}
sshll() {
# listet die per ssh tunnel geöffneten lokalen ports auf
sudo lsof -i -n | grep ssh | grep 127.0.0.1 | grep LISTEN
}
asdm() {
echo "https://$1" >> /home/andre/.java/deployment/security/exception.sites
javaws "https://$1/admin/public/asdm.jnlp" &
}
asdmns() {
echo "Ermittele IP von Host $1 über DNS Server $2"
IP=`nslookup $1 $2 | tail -n2 | grep Address | cut -d':' -f2 | tr -d [:blank:]`
if [ "$IP" != "" ]; then
echo "IP ist $IP"
javaws "https://$IP/admin/public/asdm.jnlp" &
else
echo "IP ist unbekannt!"
fi
}
svncom() {
if [ "$1" == "" ]; then
echo "Keine Datei angegeben"
return
fi
COMMIT=`cat $1 | grep "#SVN:"`
if [ "$COMMIT" == "" ]; then
echo "Geben Sie einen Kommentar ein:"
read INPUT
if [ "$INPUT" == "" ]; then
COMMIT="add #SVN: somewhere to your file to use this line as commit message."
else
COMMIT="#SVN:$INPUT"
fi
fi
echo "Übertrage mit Kommentar '$COMMIT'"
svn commit -m "$COMMIT" $1
}
screen_h() {
echo "
Ctrl+a c(reate)
Ctrl+a n(ext)
Ctrl+a 0-9
Ctrl+a A (rename)
Ctrl+a d(etach)
Ctrl+a \" (liste)
Ctrl+a K(ill)
screen -r(eattach)
# Scrollen, Markieren, Einfügen
Ctrl+a [ wechselt in den Copy Mode
Mit den Pfeil-, Maustasten scrollen
Mit Enter Anfang der Markierung setzen, mit zweitem Enter das Ende setzen
Ctrl+a ] fügt markierten Bereich ein
"
}
sudo_h() {
echo "
/etc/sudoers
andre ALL=(ALL) NOPASSWD: ALL
"
}
iptables_h() {
echo "
# Policy für Chain setzen
iptables -P INPUT ACCEPT
iptables -P INPUT DROP
#Neue Chain anlegen
iptables -N NEW_CHAIN
# NEW_CHAIN an INPUT anhängen (-A) / am Anfang von INPUT einfügen (-I)
iptables -A/-I INPUT -j NEW_CHAIN
# Regeln an neue Chain anhängen (-A) / am Anfang einfügen (-I) oder löschen (-D)
iptables -A/-I/-D NEW_CHAIN -p tcp --dport 22 -j ACCEPT
iptables -A/-I/-D NEW_CHAIN -p udp --dport 53 -j ACCEPT
iptables -A/-I/-D NEW_CHAIN -s 10.0.0.0/8 -j DROP
iptables -A/-I/-D NEW_CHAIN -d 127.0.0.0/8 -j ACCEPT
iptables -A/-I/-D NEW_CHAIN -m state --state ESTABLISHED,RELATED -j ACCEPT
# Rücksprung aus Chain (nicht zwingend notwendig)
iptables -A NEW_CHAIN -j RETURN
#Chain aus Chain entfernen
iptables -D INPUT -j NEW_CHAIN
#Chain leeren (-F) / löschen (-X)
iptables -F NEW_CHAIN
"
}
init.d_h() {
echo "
#!/bin/bash
### BEGIN INIT INFO
# Provides:
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
### END INIT INFO
ACTION=$1
PIDDIR=\"/var/run\"
PIDFILE=\"provides\"
VAR=\"\"
function funktion {
if [ \"$1\" == \"START\" ]; then
fi
if [ \"$1\" == \"STOP\" ]; then
fi
}
case $ACTION in
start)
funktion START
;;
stop)
funktion STOP
;;
reload)
funktion STOP
funktion START
;;
status)
if [ -f $PIDDIR/$PIDFILE.pid ]; then
echo \"aktiv\"
exit
fi
echo \"nicht aktiv\"
;;
esac
"
}
install_ssh_key() {
echo $SSHK > /tmp/KEYFILE
echo $SSHKE >> /tmp/KEYFILE
scp /tmp/KEYFILE root@$1:/home/$USER/.ssh/authorized_keys
rm /tmp/KEYFILE
}
delete_files_older() {
if [ "$4" == "" ]; then
echo ""
echo "$0 <Pfad> <Tage> <d|f> <r|n>"
echo ""
echo "Pfad gibt an aus welchem Verzeichnis gelöscht werden soll"
echo "Tage gibt an ab welchem Alter Verzeichnisse und Dateien gelöscht werden"
echo "d Verzeichnisse löschen, f Dateien löschen"
echo "r rekursiv löschen, n nicht rekursiv löschen. Bei Dateilöschungen ist egal was hier angegeben wird"
echo ""
else
echo "Wechsle in Verzeichnis $1"
cd $1
for I in `find $1 -mtime +$2`
do
if [ $3 == "f" ]; then
if [ -f $I ]; then
echo "Lösche Datei $I"
rm $I
fi
elif [ $3 == "d" ]; then
if [ $4 == "r" ]; then
if [ -d $I ]; then
echo "Lösche Verzeichnis $I rekursiv"
rm -fR $I
fi
elif [ $4 == "n" ]; then
if [ -d $I ]; then
echo "Lösche Verzeichnis $I (nicht rekursiv)"
rmdir $I
fi
fi
fi
done
fi
}
delete_old_logs() {
find /var/log -name "*.gz" -o -name "*.1" -o -name "*.2" -o -name "*.old" | xargs rm
find /var/log -mtime +7 | xargs rm
}
update_ssh_personal_environment() {
if [ $# -gt 0 -a "$1" = "--debug" ] ; then
export SSH_PERS_ENV_DEBUG=1
shift
fi
if test -n "$SSH_PERS_ENV_FILES" -o "$#" -gt 0 ; then
export SSH_PERS_ENV_FILES=$(
eval echo $@ $SSH_PERS_ENV_FILES | \
tr " " "\n" | \
sort -u | \
tr "\n" " "
) # pattern expansion
test "${SSH_PERS_ENV_DEBUG:-}" && \
echo "Packing as SSH Personal Environment: $SSH_PERS_ENV_FILES" 1>&2
export SSH_PERS_ENV_DATA=$(tar -C ~ -cz $SSH_PERS_ENV_FILES | base64)
fi
}
ssh_personal_config() {
echo "append to /etc/ssh/ssh_config"
echo "# this content comes from the ssh-personal-environment package"
echo "SendEnv SSH_PERS_ENV_DATA SSH_PERS_ENV_FILES SSH_PERS_ENV_DEBUG"
echo "# end of content from the ssh-personal-environment package"
echo ""
echo "append to /etc/ssh/sshd_config"
echo "# this content comes from the ssh-personal-environment package"
echo "AcceptEnv SSH_PERS_ENV_DATA SSH_PERS_ENV_FILES SSH_PERS_ENV_DEBUG"
echo "# end of content from the ssh-personal-environment package"
echo ""
echo "insert into /etc/ssh/sshrc"
echo "#!/bin/sh"
echo "if which xauth >/dev/null 2>&1 && read proto cookie && test \"\$DISPLAY\" ; then"
echo " if test \"\$(expr substr \"\$DISPLAY\" 1 10)\" = localhost: ; then"
echo " # X11UseLocalhost=yes"
echo " echo add unix:\"\$(expr substr \"\$DISPLAY\" 11 99)\" \$proto \$cookie"
echo " else"
echo " # X11UseLocalhost=no"
echo " echo add \"\$DISPLAY\" \$proto \$cookie"
echo " fi | xauth -q -"
echo "fi"
echo "# unpack personal environment"
echo "if test \"\$SSH_PERS_ENV_DATA\" ; then"
echo " if [ ! \"\$USER\" = \"root\" ] ; then"
echo " test \"\$SSH_PERS_ENV_DEBUG\" && echo \"Unpacking SSH Personal Environment Data...\""
echo " echo \"\$SSH_PERS_ENV_DATA\" | base64 -d | tar \${SSH_PERS_ENV_DEBUG:+-v} -xzC ~"
echo " fi"
echo "fi"
echo ""
}
install_ssh_personal_config() {
#echo "append to /etc/ssh/ssh_config"
echo "# this content comes from the ssh-personal-environment package" >> /etc/ssh/ssh_config
echo "SendEnv SSH_PERS_ENV_DATA SSH_PERS_ENV_FILES SSH_PERS_ENV_DEBUG" >> /etc/ssh/ssh_config
echo "# end of content from the ssh-personal-environment package" >> /etc/ssh/ssh_config
#echo "append to /etc/ssh/sshd_config"
echo "# this content comes from the ssh-personal-environment package" >> /etc/ssh/sshd_config
echo "AcceptEnv SSH_PERS_ENV_DATA SSH_PERS_ENV_FILES SSH_PERS_ENV_DEBUG" >> /etc/ssh/sshd_config
echo "# end of content from the ssh-personal-environment package" >> /etc/ssh/sshd_config
#echo "insert into /etc/ssh/sshrc"
echo "#!/bin/sh" > /etc/ssh/sshrc
echo "if which xauth >/dev/null 2>&1 && read proto cookie && test \"\$DISPLAY\" ; then" >> /etc/ssh/sshrc
echo " if test \"\$(expr substr \"\$DISPLAY\" 1 10)\" = localhost: ; then" >> /etc/ssh/sshrc
echo " # X11UseLocalhost=yes" >> /etc/ssh/sshrc
echo " echo add unix:\"\$(expr substr \"\$DISPLAY\" 11 99)\" \$proto \$cookie" >> /etc/ssh/sshrc
echo " else" >> /etc/ssh/sshrc
echo " # X11UseLocalhost=no" >> /etc/ssh/sshrc
echo " echo add \"\$DISPLAY\" \$proto \$cookie" >> /etc/ssh/sshrc
echo " fi | xauth -q -" >> /etc/ssh/sshrc
echo "fi" >> /etc/ssh/sshrc
echo "# unpack personal environment" >> /etc/ssh/sshrc
echo "if test \"\$SSH_PERS_ENV_DATA\" ; then" >> /etc/ssh/sshrc
echo " if [ ! \"\$USER\" = \"root\" ] ; then" >> /etc/ssh/sshrc
echo " test \"\$SSH_PERS_ENV_DEBUG\" && echo \"Unpacking SSH Personal Environment Data...\"" >> /etc/ssh/sshrc
echo " echo \"\$SSH_PERS_ENV_DATA\" | base64 -d | tar \${SSH_PERS_ENV_DEBUG:+-v} -xzC ~" >> /etc/ssh/sshrc
echo " fi" >> /etc/ssh/sshrc
echo "fi" >> /etc/ssh/sshrc
chmod +x /etc/ssh/sshrc
/etc/init.d/ssh restart
}
logrotate() {
if [ "$1" == "" ]
then
echo ""
echo "Aufruf:"
echo ""
echo "logrotate <DIR>"
echo ""
return
fi
logdir=$1
oldlogdir=$logdir/rotate
echo $oldlogdir
mkdir $oldlogdir
date=`date +"%Y-%m-%d_%H-%M"`
# alte logfiles packen
pushd .
cd $logdir
tar -cvzf $date.tar.gz *.log
# archiv verschieben
mv $date.tar.gz $oldlogdir
# alte logs löschen
rm *.log
popd
}
cping() {
if [ "$1" == "" ]
then
echo ""
echo "Aufruf:"
echo ""
echo "[RET=x] cping <IP>"
echo ""
echo "x: Anzahl Wiederholungen, E für endlos"
echo ""
return
fi
if [ "$RET" == "" ]
then
RET=1
elif [ "$RET" == "E" ]
then
RET=2
END=1
fi
echo ""
for ((i=0; i < $RET; i++))
do
ping -c1 -W1 $1 >/dev/null
RV=$?
if [ $RV -eq 0 ]
then
echo -e "\e[42;30m$1 is up\e[0m"
else
echo -e "\e[41m$1 is down\e[m"
fi
sleep 1;
if [ "$END" == "1" ]
then
i=$i-1
fi
done
echo ""
}
eping() {
if [ "$1" == "" ]
then
echo ""
echo "Aufruf:"
echo ""
echo "[RET=x] eping <IP1> [IP2 [IP3 [IP4 [IP5 [IP6]]]]]"
echo ""
echo "x: Anzahl Wiederholungen, E für endlos"
echo "pingt bis zu 6 Adressen an und zeigt das Ergebnis in einer Tabelle"
echo ""
return
fi
if [ "$RET" == "" ]
then
RET=1
elif [ "$RET" == "E" ]
then
RET=2
END=1
fi
CT=0
for ((i=0; i < $RET; i++))
do
N=$(($CT % 5))
if [ "$(($CT % 20))" == "0" ]
then
echo ""
date
if [ "$1" != "" ]
then
echo -e "$1\t\c"
fi
if [ "$2" != "" ]
then
echo -e "$2\t\c"
fi
if [ "$3" != "" ]
then
echo -e "$3\t\c"
fi
if [ "$4" != "" ]
then
echo -e "$4\t\c"
fi
if [ "$5" != "" ]
then
echo -e "$5\t\c"
fi
if [ "$6" != "" ]
then
echo -e "$6\t\c"
fi
echo ""
fi
CT=$(($CT+1))
if [ "$1" != "" ]
then
ping -c1 -W1 $1 >/dev/null
RV1=$?
fi
if [ "$2" != "" ]
then
ping -c1 -W1 $2 >/dev/null
RV2=$?
fi
if [ "$3" != "" ]
then
ping -c1 -W1 $3 >/dev/null
RV3=$?
fi
if [ "$4" != "" ]
then
ping -c1 -W1 $4 >/dev/null
RV4=$?
fi
if [ "$5" != "" ]
then
ping -c1 -W1 $5 >/dev/null
RV5=$?
fi
if [ "$6" != "" ]
then
ping -c1 -W1 $6 >/dev/null
RV6=$?
fi
if [ "$1" != "" ]
then
if [ $RV1 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
if [ "$2" != "" ]
then
if [ $RV2 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
if [ "$3" != "" ]
then
if [ $RV3 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
if [ "$4" != "" ]
then
if [ $RV4 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
if [ "$5" != "" ]
then
if [ $RV5 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
if [ "$6" != "" ]
then
if [ $RV6 -eq 0 ]
then
echo -e "\e[42;30mup\e[0m\t\t\c"
else
echo -e "\e[41mdown\e[m\t\t\c"
fi
fi
sleep 1;
if [ "$END" == "1" ]
then
i=$i-1
fi
echo ""
done
echo ""
}
mount_all() {
mkdir -p ~/mnt-homes
mkdir -p ~/mnt-alle
sudo mount //192.168.100.13/homes ~/mnt-homes/ -o user=andre
sudo mount //192.168.100.13/alle ~/mnt-alle/ -o user=andre
#sudo umount /mnt/hidrive
#sudo mkdir -p /mnt/hidrive
#sudo chown $USER:$USER -R /mnt/
#ID=`id -u`
#sudo mount -t cifs //10.1.1.4/data/ /mnt/idefix/ -ouid=$ID,gid=$ID,username=ageissler,domain=conacc,password=K01v1kk0!
#sudo mount -t cifs //dlink/1TB /mnt/dlink/ -ouid=$ID,gid=$ID,username=root,password=K01v1kk0!
#sudo mount -t cifs //dlink/User /mnt/dlink2/ -ouid=$ID,gid=$ID,username=root,password=K01v1kk0!
}
mkdir -p ~/.ssh/
touch ~/.ssh/authorized_keys
if [[ -f ~/.ssh/authorized_keys ]] ; then
cat ~/.ssh/authorized_keys | grep "$SSHK" > /dev/null 2>&1
if [[ $? == "1" ]] ; then
echo "$SSHK" >> ~/.ssh/authorized_keys
fi
cat ~/.ssh/authorized_keys | grep "$SSHKE" > /dev/null 2>&1
if [[ $? == "1" ]] ; then
echo "$SSHKE" >> ~/.ssh/authorized_keys
fi
fi