wok-next annotate dropbear/stuff/sshx @ rev 17119

Up lilo (24.0), again
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Sep 04 13:22:11 2014 +0200 (2014-09-04)
parents caf768bb46f9
children 58f4bd56c8de
rev   line source
pascal@10917 1 #!/bin/sh
pascal@10917 2
pascal@10917 3 xdbclient()
pascal@10917 4 {
pascal@14027 5 read host data
pascal@14027 6 svr=${DISPLAY#*:}
pascal@11597 7 n=$((10+($RANDOM % 90))); dpy=localhost:$n
pascal@14027 8 scr=${DISPLAY/${DISPLAY%.*}/$dpy}
pascal@14027 9 r=""
pascal@11597 10 while true; do
pascal@14027 11 a="$1"
pascal@14027 12 r="$r $1"; shift
pascal@14027 13 case "$a" in
pascal@14027 14 -[piIlLRWKBJ]) r="$r $1"; shift;;
pascal@11597 15 -*) ;;
pascal@11597 16 *) break ;;
pascal@11597 17 esac
pascal@11597 18 done
pascal@15886 19 [ -n "$1" ] || set -- "${TERM:-xterm} -ls || ${TERM:-sakura} -l || xterm -ls"
pascal@14027 20 exec dbclient -f -R $((6000+$n)):localhost:$((6000+${svr%.*})) $r \
pascal@14027 21 "xauth add $dpy $data; export DISPLAY=$scr; $@ ; xauth remove $dpy" \
pascal@14027 22 </dev/null >/dev/null
pascal@10917 23 }
pascal@10917 24
pascal@14027 25 pppssh()
pascal@14027 26 {
pascal@14027 27 [ -z "$DROPBEAR_PASSWORD" ] && echo -n "ssh password: " &&
pascal@14027 28 read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD
pascal@15886 29 for i in $4 ; do
pascal@15886 30 echo "route add -net $i dev \$1"
pascal@15886 31 done > /etc/ppp/ip-up.d/pppssh$$
pascal@15886 32 chmod +x /etc/ppp/ip-up.d/pppssh$$
pascal@15886 33 ssh="dbclient -y"
pascal@15886 34 $ssh $1 true || exit 1
pascal@14027 35 n=10.$(($$%256)).$(($$/256))
pascal@15886 36 ppp="/usr/sbin/pppd local noauth nodetach"
pascal@15886 37 $ppp ${2:-$n.1:$n.2} passive pty "$ssh $1 $ppp ${3:-proxyarp} notty" \
pascal@15886 38 ipparam pppssh$$
pascal@15886 39 rm -f /etc/ppp/ip-up.d/pppssh$$
pascal@14027 40 }
pascal@14027 41
pascal@14027 42 case "$(basename $0)" in
pascal@15886 43 ppp*) [ -z "$1" ] && cat <<EOT || pppssh "$@" ;;
pascal@15886 44 Usage: $0 '[sshargs] user@remote' '[localip:remoteip] [localpppargs]' 'remotepppargs' 'routes'
pascal@15886 45 Example: $0 tux@slitaz.org '' '' '192.168.1.0/24 10.1.2.0/24'
pascal@15886 46 EOT
pascal@14027 47 *) [ -z "$DISPLAY" ] && exec dbclient "$@"
pascal@14027 48 xauth list $DISPLAY | xdbclient "$@"
pascal@10917 49 esac