Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save corpix/3f97265309a5435185d59187a3e519cf to your computer and use it in GitHub Desktop.
Save corpix/3f97265309a5435185d59187a3e519cf to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
set -x
mkdir recovery
cd recovery
# Iterate installed packages (pkgname=pkgversion)
for pkgfullname in `dpkg -l | grep '^ii' | awk '{print $2"="$3}'`; do
# Get package name without version
pkgname="$(echo "$pkgfullname"|awk -F= '{print $1}')"
# Filter packages with files in /etc/init.d,
# download it and extract into current directory
dpkg-query -L "$pkgname" | \
grep -F '/etc/init.d' > /dev/null && \
apt-get download "$pkgfullname" && \
dpkg -x "${pkgname}_"*.deb .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment