Commit fed56b4a authored by Franco Fichtner's avatar Franco Fichtner

rc: revamp rc.loader

We only merge chunks for loader.conf leaveraging a priority scheme
in order to be able to override standard modifications made by e.g.
core or plugins (in case of user changes).

Start to work on its scripts, but 20-console is dynamic so it needs
more work in the actual PHP code.

Discussed with: @adschellevis
parent 9a117cd0
#!/usr/local/bin/python2.7 #!/bin/sh
# Copyright (c) 2016 Ad Schellevis # Copyright (c) 2016 Franco Fichtner <franco@opnsense.org>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -25,20 +25,36 @@ ...@@ -25,20 +25,36 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
import os # Files are sorted and should adhere to the following
import glob # rule of thumb: "dd-identifier", for core package
import sys # loader.conf chunks should generally use something
# like "20-mycorevars" and for plugin packages rather
# "50-mypluginvars".
#
# It could be useful for the user to order variables
# or set a higher/lower priority in case some
# use case requires a slightly different setup.
LOADERDIR="/usr/local/etc/rc.loader.d"
LOADERCONF="/boot/loader.conf"
: > ${LOADERCONF}
if [ ! -d ${LOADERDIR} ]; then
# no dir no fun
exit 0;
fi
# collect all matching scripts
LOADERCHUNKS=$(find -s ${LOADERDIR} -type f)
for LOADERCHUNK in ${LOADERCHUNKS}; do
# extract loader chunk origin
LOADERCHUNK=${LOADERCHUNK##"${LOADERDIR}/"}
loader_dir="/usr/local/etc/rc.loader.d" echo "rc.loader: assembling ${LOADERCHUNK#??-}"
loader_conf_local='/boot/loader.conf.local'
if not os.path.isdir(loader_dir): cat ${LOADERDIR}/${LOADERCHUNK} >> ${LOADERCONF}
sys.exit(0) done
loader_conf_local_items=list() exit 0
for filename in glob.glob('%s/*'%loader_dir):
prop_name = os.path.basename(filename)
prop_value = open(filename,'r').read().strip()
loader_conf_local_items.append('%s="%s"'%(prop_name, prop_value))
# dump collected properies
open(loader_conf_local,'w').write('%s\n'%'\n'.join(loader_conf_local_items))
loader_brand="opnsense"
loader_logo="hourglass"
loader_menu_title=""
autoboot_delay="3"
hw.usb.no_pf="1"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment