16 lines
832 B
Bash
16 lines
832 B
Bash
|
#!/bin/bash
|
||
|
mkdir /tmp/tmproot && mount none /tmp/tmproot -t tmpfs
|
||
|
mkdir /tmp/tmproot/{proc,sys,usr,var,run,oldroot,root}
|
||
|
cp -ax /{bin,etc,mnt,sbin,lib} /tmp/tmproot/
|
||
|
cp -a /dev /tmp/tmproot/dev
|
||
|
lsof -Fn / | grep ^n/ | cut -c2- | sort -u | grep /usr | rsync -v --files-from=- / /tmp/tmproot/
|
||
|
NEEDED_BINARIES=(/usr/bin/wget /usr/bin/gzip /usr/bin/dd /usr/bin/mount /usr/bin/ls /usr/bin/cp /usr/bin/cat /usr/sbin/sshd /usr/bin/systemctl /lib/systemd/systemd)
|
||
|
for binary_path in "${NEEDED_BINARIES[@]}"
|
||
|
do
|
||
|
ldd $binary_path | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | xargs -n1 readlink -f | rsync -v --files-from=- / /tmp/tmproot/
|
||
|
ldd $binary_path | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | rsync -lv --files-from=- / /tmp/tmproot/
|
||
|
rsync -v $binary_path /tmp/tmproot$binary_path
|
||
|
done
|
||
|
|
||
|
rsync -lv /sbin/init /tmp/tmproot/sbin/init
|