Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ci
Path: blob/main/scripts/build/config-head/basevm/override/etc/rc.local
1130 views
#!/bin/sh

echo
echo "--------------------------------------------------------------"
echo "rc.local start!"
echo "--------------------------------------------------------------"

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
export PATH

set -x

ddb script kdb.enter.panic="show pcpu; reset"

TARDEV=/dev/vtbd1
METADIR=/meta

ISTAR=$(file -s ${TARDEV} | grep "POSIX tar archive" | wc -l)

if [ ${ISTAR} -eq 1 ]; then
        rm -fr ${METADIR}
        mkdir -p ${METADIR}
        tar xvf ${TARDEV} -C ${METADIR}
        sh -ex ${METADIR}/run.sh
        tar cvf ${TARDEV} -C ${METADIR} .
else
	echo "ERROR: no device with POSIX tar archive format found."
	# Don't shutdown because this is not run in unattended mode
	exit 1
fi

if [ -f ${METADIR}/auto-shutdown ]; then
        shutdown -p now
fi