wok view dropbear/stuff/sshx @ rev 18145
Add defragfs
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jun 18 16:31:01 2015 +0200 (2015-06-18) |
parents | 56c606af68bc |
children | 0c87072c012d |
line source
1 #!/bin/sh
3 xdbclient()
4 {
5 read host data
6 svr=${DISPLAY#*:}
7 n=$((10+($RANDOM % 90))); dpy=localhost:$n
8 scr=${DISPLAY/${DISPLAY%.*}/$dpy}
9 r=""
10 while true; do
11 a="$1"
12 r="$r $1"; shift
13 case "$a" in
14 -[piIlLRWKBJ]) r="$r $1"; shift;;
15 -*) ;;
16 *) break ;;
17 esac
18 done
19 [ -n "$1" ] || set -- "${TERM:-xterm} -ls || ${TERM:-sakura} -l || xterm -ls"
20 exec dbclient -f -R $((6000+$n)):localhost:$((6000+${svr%.*})) $r \
21 "xauth add $dpy $data; export DISPLAY=$scr; $@ ; xauth remove $dpy" \
22 </dev/null >/dev/null
23 }
25 pppssh()
26 {
27 ssh="dbclient -y"
28 $ssh $1 true || {
29 [ -z "$DROPBEAR_PASSWORD" ] && echo -n "ssh password: " &&
30 read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD
31 $ssh $1 true || exit 1
32 }
33 extra="$(route -n | awk -vd=$(nslookup ${1#*@} | \
34 sed '$!d;s/.*: \([^ ]*\).*/\1/') \
35 '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')"
36 for i in ${4/default/128.0.0.0/1 0.0.0.0/1} ; do
37 echo "route add -net $i dev \$1"
38 done > /etc/ppp/ip-up.d/pppssh$$
39 [ "$4" ] && echo "route add $extra" >> /etc/ppp/ip-up.d/pppssh$$
40 chmod +x /etc/ppp/ip-up.d/pppssh$$
41 n=10.$(($$%256)).$(($$/256))
42 ppp="/usr/sbin/pppd local noauth nodetach"
43 $ppp ${2:-$n.1:$n.2} passive pty "$ssh $1 $ppp ${3:-proxyarp} notty" \
44 ipparam pppssh$$
45 [ "$4" ] && route del $extra
46 rm -f /etc/ppp/ip-up.d/pppssh$$
47 }
49 case "$(basename $0)" in
50 ppp*) [ -z "$1" ] && cat <<EOT || pppssh "$@" ;;
51 Usage: $0 '[sshargs] user@remote' '[localip:remoteip] [localpppargs]' 'remotepppargs' 'routes'
52 Example: $0 tux@slitaz.org '' '' '192.168.1.0/24 10.1.2.0/24'
53 EOT
54 *) [ -z "$DISPLAY" ] && exec dbclient "$@"
55 xauth list $DISPLAY | xdbclient "$@"
56 esac