X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=.bashrc;h=c7125a5e552da943b92f035865683510ea2e1a25;hp=289d2e301b5c448e6a45e89335f82de72b71c52e;hb=e4afeff5ebd958d809856c85d7a9adf3baf90d2a;hpb=f86043f305e9877f64790c6a13664e47a8a1e3d7 diff --git a/.bashrc b/.bashrc index 289d2e3..c7125a5 100644 --- a/.bashrc +++ b/.bashrc @@ -11,11 +11,23 @@ if [ -n "$_home_short_dotbashrc_norc" -o "${TERM#norc-}" != "$TERM" ];then fi if [ -z "$_home_short_dotbashrc" ];then - _home_short_dotbashrc=true + # We permit later reinitialization by unsetting it. + # During our execution we forbid spawning to prevent deadlock by: + # source /etc/bashrc + # . /etc/profile.d/lang.sh + # unicode_start iso02.08 + export _home_short_dotbashrc=true # $TERM gets restored to its 'norc-' state after ~/.bashrc # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"' function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }; export -f norc +# Fix $USER and $LOGNAME (not $MAIL) for /etc/passwd line: +# root-lace:x:0:0:root for Jan Kratochvil:/home/root-lace:/bin/bash +if [ "$UID" -eq 0 -a "$USER" = "root" -a "$HOME" != "${HOME#*/root-}" ];then + USER="${HOME##*/}" + LOGNAME="$USER" +fi + if [ -f /etc/bashrc ];then source /etc/bashrc;fi function _bash_profile_addpath # , @@ -129,7 +141,7 @@ unalias 2>/dev/null du # -h export IGNOREEOF=10 # '2>/dev/null' to prevent: TMOUT: readonly variable -export TMOUT=900 2>/dev/null +[ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null export EDITOR='vim' [ -x /bin/less ] && export PAGER='/bin/less -MMh5cis' export PERL_MM_OPT="PERL=$HOME/bin/perlilib" @@ -149,11 +161,17 @@ if [ -n "$PS1" ];then # set only in interactive sessions export MINICOM="-m -c on" # metakeys+color export HISTSIZE=100000 export HISTFILESIZE="$HISTSIZE" +export GDBHISTFILE="$HOME/.gdb_history" export CVS_RSH="ssh" # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220 # as Sun workaround as Debian misses: /etc/termcap # expects: $uname_p [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux +if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp;then + export http_proxy=http://127.0.0.1:3128/ + export https_proxy=http://127.0.0.1:3128/ + export ftp_proxy=http://127.0.0.1:3128/ +fi export SOCKS5_SERVER=icsocks.holland.sun.com @@ -212,13 +230,52 @@ function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx function revlines { perl -e 'my @r=();push @r,$_ while (<>);print pop @r while @r;'; }; export -f revlines -ulimit -c 0 +ulimit -S -c 0 set +H shopt -s mailwarn unset OPTIND if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi +# Interactive part: +for key in $HOME/.ssh/id_dsa;do + [ -r "$key" ] || continue + [ -n "$SSH_TTY" ] && continue + + agenteval=/tmp/.$USER.ssh-agent.eval + if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then + test -f $agenteval -a -O $agenteval -a -G $agenteval && + # ">/dev/null" to prevent: echo Agent pid 31074; + source $agenteval >/dev/null + if [ "ssh-agent" != "`(xargs -0 /dev/null `" ];then + rm -f $agenteval + (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!' + # ">/dev/null" to prevent: echo Agent pid 31074; + source $agenteval >/dev/null + fi + rm -f $agenteval.lock + fi + + # Prevent gdm(8) lockups on non-interactive consoles. + tty -s || continue + (ssh-add -l|grep -qw "$key") && continue + if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then + echo >&2 -n "Locking: $agenteval.input.lock ... " + lockfile -1 -r -1 $agenteval.input.lock + echo >&2 "locked" + fi + # Recheck identity existence after the lock acquire + if ssh-add -l|grep -qw "$key";then + echo >&2 "Identity $key already appended in the meantime." + else + # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa) + ssh-add "$key" 2>/dev/null + fi + rm -f $agenteval.input.lock + echo >&2 "$agenteval.input.lock unlocked." +done +unset agenteval + unset _home_short_dotbashrc # permit later reinitializations fi # _home_short_dotbashrc