Skip to content

Commit

Permalink
Use config file for init
Browse files Browse the repository at this point in the history
  • Loading branch information
mekanix committed Nov 24, 2017
1 parent 3202828 commit af0b310
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ compress_man:
.endfor

install: install_bin install_templates install_makefiles install_scripts install_man
install -d ${DESTDIR}${PREFIX}/etc
install -m 0644 reggae.conf.sample ${DESTDIR}${PREFIX}/etc

install_bin:
install -d ${DESTDIR}${PREFIX}${BIN}
Expand Down
8 changes: 8 additions & 0 deletions reggae.conf.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Following are default values

BRIDGE_INTERFACE="bridge1"
CBSD_WORKDIR="/cbsd"
DOMAIN="my.domain"
IP_POOL="10.0.0.0/24"
JAIL_INTERFACE="lo1"
ZFS_POOL="zroot"
28 changes: 19 additions & 9 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
CBSD_WORKDIR="/cbsd"
DOMAIN="my.domain"
#!/bin/sh

if [ -e "/usr/local/etc/reggae.conf" ]; then
. "/usr/local/etc/reggae.conf"
fi
CBSD_WORKDIR=${CBSD_WORKDIR:-"/cbsd"}
DOMAIN=${DOMAIN:-"my.domain"}
BRIDGE_INTERFACE=${BRIDGE_INTERFACCE:-"bridge1"}
JAIL_INTERFACE=${JAIL_INTERFACE:-"lo1"}
ZFS_POOL=${ZFS_POOL:-"zroot"}
IP_POOL=${IP_POOL:-"10.0.0.0/24"}
SSHD_FLAGS=`sysrc -n sshd_flags`
SHORT_HOSTNAME=`hostname -s`
HOSTNAME=`hostname`
Expand All @@ -17,20 +26,20 @@ for iface in ${CLONED_INTERFACES}; do
done


LO1_INTERFACE=`grep '^lo1$' /tmp/ifaces.txt`
LO1_INTERFACE=`grep "^${JAIL_INTERFACE}$" /tmp/ifaces.txt`
if [ -z "${LO1_INTERFACE}" ]; then
if [ -z "${CLONED_INTERFACES}" ]; then
CLONED_INTERFACES="lo1"
CLONED_INTERFACES="${JAIL_INTERFACE}"
else
CLONED_INTERFACES="${CLONED_INTERFACES} lo1"
CLONED_INTERFACES="${CLONED_INTERFACES} ${JAIL_INTERFACE}"
fi
sysrc ifconfig_lo1="up"
fi

BRIDGE1_INTERFACE=`grep '^bridge1$' /tmp/ifaces.txt`
BRIDGE1_INTERFACE=`grep "^${BRIDGE_INTERFACE}$" /tmp/ifaces.txt`
if [ -z "${BRIDGE1_INTERFACE}" ]; then
CLONED_INTERFACES="${CLONED_INTERFACES} bridge1"
sysrc ifconfig_bridge1="inet 172.16.0.1 netmask 255.255.255.0 description ${EGRESS}"
CLONED_INTERFACES="${CLONED_INTERFACES} ${BRIDGE_INTERFACE}"
sysrc ifconfig_${BRIDGE_INTERFACE}="inet 172.16.0.1 netmask 255.255.255.0 description ${EGRESS}"
fi

sysrc cloned_interfaces="${CLONED_INTERFACES}"
Expand All @@ -39,7 +48,7 @@ rm -rf /tmp/ifaces.txt


if [ ! -d "${CBSD_WORKDIR}" ]; then
zfs create -o mountpoint=${CBSD_WORKDIR} zroot${CBSD_WORKDIR}
zfs create -o mountpoint=${CBSD_WORKDIR} ${ZFS_POOL}${CBSD_WORKDIR}
fi

if [ "${HOSTNAME}" == "${SHORT_HOSTNAME}" ]; then
Expand All @@ -57,6 +66,7 @@ sed \
-e "s:NODEIP:${NODEIP}:g" \
-e "s:NAMESERVER:${RESOLVER}:g" \
-e "s:NATIP:${NATIP}:g" \
-e "s:IP_POOL:${IP_POOL}:g" \
/usr/local/share/reggae/templates/initenv.conf >"${TEMP_INITENV_CONF}"

env workdir="${CBSD_WORKDIR}" /usr/local/cbsd/sudoexec/initenv "${TEMP_INITENV_CONF}"
Expand Down
2 changes: 1 addition & 1 deletion templates/initenv.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nodename="HOSTNAME"

nodeip="NODEIP"
jnameserver="NAMESERVER"
nodeippool="10.0.0.0/24"
nodeippool="IP_POOL"
natip="NATIP"
nat_enable="0"
sshd_flags="0"
Expand Down

0 comments on commit af0b310

Please sign in to comment.