#!/bin/sh target_ready() { [ -r /target/bin/apt-get ] \ && [ -r /target/bin/bash ] } cacerts_installed() { [ -r /target/var/lib/dpkg/info/ca-certificates.list ] } install_cacerts() { mkdir /target/mycd mount -o ro /dev/cdrom /target/mycd cd /target OPENSSL_PKG=$(find mycd -iname openssl_*.deb) if [ -f $OPENSSL_PKG ] ; then in-target /bin/apt install -y /$OPENSSL_PG fi CACERTS_PKG=$(find mycd -iname ca-certificates_*all.deb) if [ -f $CACERTS_PKG ] ; then in-target /bin/apt install -y /$CACERTS_PKG fi umount /target/mycd } mylog() { /usr/bin/logger -t cacert_install "$1" } main() { for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ;do mylog "checking if /target is ready" if target_ready ; then mylog "/target is ready" if ! cacerts_installed ; then mylog "ca-certificates not installed, trying to install (try: $i)" install_cacerts mylog "ca-certificates installed. Verfiying." cacerts_installed && exit 0 mylog "ca-certificates still not installed" else exit 0 fi else mylog "/target not ready so far" fi sleep 10 done mylog "could not install ca-certificates after 20 tries. giving up." } main >/tmp/cacertinstall.log 2>&1 &