55# cd scripts/tools/
66# wget https://link/rancheros-xxx.iso
77# wget http://link/custom.crt
8+ #
89# ./flush_crt_iso.sh --iso rancheros-vmware-autoformat.iso --cert custom.crt
10+ # # or
11+ # ./flush_crt_iso.sh --initrd initrd-xxxx --cert custom.crt
12+ #
913# exit
1014# ls ./build/
1115#
@@ -21,6 +25,10 @@ mkdir -p ${ORIGIN_DIR} ${NEW_DIR} ${WORK_DIR} ${DAPPER_SOURCE}/build
2125
2226while [ " $# " -gt 0 ]; do
2327 case $1 in
28+ --initrd)
29+ shift 1
30+ INITRD_FILE=$( readlink -f $1 )
31+ ;;
2432 --iso)
2533 shift 1
2634 ISO_FILE=$( readlink -f $1 )
@@ -36,6 +44,30 @@ while [ "$#" -gt 0 ]; do
3644 shift 1
3745done
3846
47+ function rebuild_initrd() {
48+ local initrd_name=$1
49+ local output_dir=$2
50+
51+ # update and rebuild the initrd
52+ pushd ${WORK_DIR}
53+ mv initrd-* ${initrd_name} .gz
54+ gzip -d ${initrd_name} .gz
55+ cpio -i -F ${initrd_name}
56+ rm -f ${initrd_name}
57+
58+ cat ${CERT_FILE} >> ${WORK_DIR} /usr/etc/ssl/certs/ca-certificates.crt
59+
60+ find | cpio -H newc -o | gzip -9 > ${output_dir} /${initrd_name}
61+ popd
62+ }
63+
64+
65+ if [ ! -z ${INITRD_FILE} ]; then
66+ cp ${INITRD_FILE} ${WORK_DIR} /
67+ rebuild_initrd $( basename ${INITRD_FILE} ) ${DAPPER_SOURCE} /build/
68+ exit 0
69+ fi
70+
3971# copy the iso content
4072mount -t iso9660 -o loop ${ISO_FILE} ${ORIGIN_DIR}
4173cp -rf ${ORIGIN_DIR} /* ${NEW_DIR}
@@ -44,17 +76,7 @@ cp -rf ${ORIGIN_DIR}/* ${NEW_DIR}
4476INITRD_NAME=$( basename ${ORIGIN_DIR} /boot/initrd-* )
4577cp ${ORIGIN_DIR} /boot/initrd-* ${WORK_DIR} /
4678
47- # update and rebuild the initrd
48- pushd ${WORK_DIR}
49- mv initrd-* ${INITRD_NAME} .gz
50- gzip -d ${INITRD_NAME} .gz
51- cpio -i -F ${INITRD_NAME}
52- rm -f ${INITRD_NAME}
53-
54- cat ${CERT_FILE} >> ${WORK_DIR} /usr/etc/ssl/certs/ca-certificates.crt
55-
56- find | cpio -H newc -o | gzip -9 > ${NEW_DIR} /boot/${INITRD_NAME}
57- popd
79+ rebuild_initrd ${INITRD_NAME} ${NEW_DIR} /boot
5880
5981pushd ${NEW_DIR}
6082xorriso \
0 commit comments