Skip to content

Commit

Permalink
Refactor finalize script
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Dec 10, 2021
1 parent 89b5650 commit ccc067c
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions export-image/03-finalise/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,31 @@

IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}"

rm -v -f "${ROOTFS_DIR}/usr/bin/qemu-arm-static"

rm -v -f "${ROOTFS_DIR}/etc/apt/sources.list~"
rm -v -f "${ROOTFS_DIR}/etc/apt/trusted.gpg~"

rm -v -f "${ROOTFS_DIR}/etc/passwd-"
rm -v -f "${ROOTFS_DIR}/etc/group-"
rm -v -f "${ROOTFS_DIR}/etc/shadow-"
rm -v -f "${ROOTFS_DIR}/etc/gshadow-"
rm -v -f "${ROOTFS_DIR}/etc/subuid-"
rm -v -f "${ROOTFS_DIR}/etc/subgid-"
# Remove backup files
find "${ROOTFS_DIR}/etc/apt" -type f -name "*.save" -exec rm -v {} \;
find "${ROOTFS_DIR}/etc" -type f -name "*.dpkg-old" -exec rm -v {} \;
find "${ROOTFS_DIR}/etc" -type f -name "*-" -exec rm -v {} \;
find "${ROOTFS_DIR}/etc" -type f -name "*~" -exec rm -v {} \;
find "${ROOTFS_DIR}/var" -type f -name "*-old" -exec rm -v {} \;
find "${ROOTFS_DIR}/boot" -type f -name "*.old" -exec rm -v {} \;
find "${ROOTFS_DIR}/boot" -type f -name "*.bak" -exec rm -v {} \;

rm -v -f "${ROOTFS_DIR}/var/cache/debconf/"*-old
rm -v -f "${ROOTFS_DIR}/var/lib/dpkg/"*-old
# Truncate all logs
find "${ROOTFS_DIR}/var/log/" -type f -exec cp -v /dev/null {} \;

rm -v -rf "${ROOTFS_DIR}/boot/"dtb*
rm -v -f "${ROOTFS_DIR}/boot/"*.old
# Clear up /run directory
rm -v -rf "${ROOTFS_DIR}/run/"*

# Remove generated host keys
rm -v -f "${ROOTFS_DIR}/etc/xrdp/rsakeys.ini"
rm -v -f "${ROOTFS_DIR}/etc/xrdp/cert.pem"
rm -v -f "${ROOTFS_DIR}/etc/xrdp/key.pem"
rm -v -f "${ROOTFS_DIR}/etc/ssl/certs/ssl-cert-snakeoil.pem"
rm -v -f "${ROOTFS_DIR}/etc/ssl/private/ssl-cert-snakeoil.key"
rm -v -f "${ROOTFS_DIR}/etc/ssh/ssh_host_"*"_key"*

find "${ROOTFS_DIR}/boot/firmware" -type f -name "*.bak" -exec rm -v {} \;
find "${ROOTFS_DIR}/etc/apt" -type f -name "*.save" -exec rm -v {} \;
find "${ROOTFS_DIR}/etc" -type f -name "*.dpkg-old" -exec rm -v {} \;

find "${ROOTFS_DIR}/var/log/" -type f -exec cp /dev/null {} \;

rm -v -rf "${ROOTFS_DIR}/run/"*
# Remove resolver configuration
rm -v -f "${ROOTFS_DIR}/etc/resolv.conf"

ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"

Expand Down

0 comments on commit ccc067c

Please sign in to comment.