mirror of
https://github.com/rancher/os.git
synced 2025-08-16 22:08:26 +00:00
Support for flushing cert to initrd only
This commit is contained in:
parent
3fac5f7604
commit
7cad727413
@ -5,7 +5,11 @@
|
|||||||
# cd scripts/tools/
|
# cd scripts/tools/
|
||||||
# wget https://link/rancheros-xxx.iso
|
# wget https://link/rancheros-xxx.iso
|
||||||
# wget http://link/custom.crt
|
# wget http://link/custom.crt
|
||||||
|
#
|
||||||
# ./flush_crt_iso.sh --iso rancheros-vmware-autoformat.iso --cert custom.crt
|
# ./flush_crt_iso.sh --iso rancheros-vmware-autoformat.iso --cert custom.crt
|
||||||
|
# # or
|
||||||
|
# ./flush_crt_iso.sh --initrd initrd-xxxx --cert custom.crt
|
||||||
|
#
|
||||||
# exit
|
# exit
|
||||||
# ls ./build/
|
# ls ./build/
|
||||||
#
|
#
|
||||||
@ -21,6 +25,10 @@ mkdir -p ${ORIGIN_DIR} ${NEW_DIR} ${WORK_DIR} ${DAPPER_SOURCE}/build
|
|||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--initrd)
|
||||||
|
shift 1
|
||||||
|
INITRD_FILE=$(readlink -f $1)
|
||||||
|
;;
|
||||||
--iso)
|
--iso)
|
||||||
shift 1
|
shift 1
|
||||||
ISO_FILE=$(readlink -f $1)
|
ISO_FILE=$(readlink -f $1)
|
||||||
@ -36,6 +44,30 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
function rebuild_initrd() {
|
||||||
|
local initrd_name=$1
|
||||||
|
local output_dir=$2
|
||||||
|
|
||||||
|
# update and rebuild the initrd
|
||||||
|
pushd ${WORK_DIR}
|
||||||
|
mv initrd-* ${initrd_name}.gz
|
||||||
|
gzip -d ${initrd_name}.gz
|
||||||
|
cpio -i -F ${initrd_name}
|
||||||
|
rm -f ${initrd_name}
|
||||||
|
|
||||||
|
cat ${CERT_FILE} >> ${WORK_DIR}/usr/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
|
find | cpio -H newc -o | gzip -9 > ${output_dir}/${initrd_name}
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ ! -z ${INITRD_FILE} ]; then
|
||||||
|
cp ${INITRD_FILE} ${WORK_DIR}/
|
||||||
|
rebuild_initrd $(basename ${INITRD_FILE}) ${DAPPER_SOURCE}/build/
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# copy the iso content
|
# copy the iso content
|
||||||
mount -t iso9660 -o loop ${ISO_FILE} ${ORIGIN_DIR}
|
mount -t iso9660 -o loop ${ISO_FILE} ${ORIGIN_DIR}
|
||||||
cp -rf ${ORIGIN_DIR}/* ${NEW_DIR}
|
cp -rf ${ORIGIN_DIR}/* ${NEW_DIR}
|
||||||
@ -44,17 +76,7 @@ cp -rf ${ORIGIN_DIR}/* ${NEW_DIR}
|
|||||||
INITRD_NAME=$(basename ${ORIGIN_DIR}/boot/initrd-*)
|
INITRD_NAME=$(basename ${ORIGIN_DIR}/boot/initrd-*)
|
||||||
cp ${ORIGIN_DIR}/boot/initrd-* ${WORK_DIR}/
|
cp ${ORIGIN_DIR}/boot/initrd-* ${WORK_DIR}/
|
||||||
|
|
||||||
# update and rebuild the initrd
|
rebuild_initrd ${INITRD_NAME} ${NEW_DIR}/boot
|
||||||
pushd ${WORK_DIR}
|
|
||||||
mv initrd-* ${INITRD_NAME}.gz
|
|
||||||
gzip -d ${INITRD_NAME}.gz
|
|
||||||
cpio -i -F ${INITRD_NAME}
|
|
||||||
rm -f ${INITRD_NAME}
|
|
||||||
|
|
||||||
cat ${CERT_FILE} >> ${WORK_DIR}/usr/etc/ssl/certs/ca-certificates.crt
|
|
||||||
|
|
||||||
find | cpio -H newc -o | gzip -9 > ${NEW_DIR}/boot/${INITRD_NAME}
|
|
||||||
popd
|
|
||||||
|
|
||||||
pushd ${NEW_DIR}
|
pushd ${NEW_DIR}
|
||||||
xorriso \
|
xorriso \
|
||||||
|
Loading…
Reference in New Issue
Block a user