summaryrefslogtreecommitdiffstats
path: root/useful/lddcopy
blob: c8f5ceb678b22379e26df75ae38d324bad74a5b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

if [ $# -ne 2 ]; then
	echo "Usage: $0 FILE TARGET_HOST" >&2
	exit 1
fi

# libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f0844776000)
if [ -e "$1" ]; then
	FILE="$1"
else
	FILE=$(which "$1")
fi

if [ ! -e "$FILE" ]; then
	echo "FILE NOT FOUND: $FILE" >&2
	exit 1
fi

SOS=$(ldd "$FILE" | sed -r 's/^[^=]*=> ([^ ]*) .*$/\1*/g' | grep '^/')
set -x
tar -cpP $FILE $SOS | ssh "root@$2" "tar -xp -C /"