Skip to content

Commit

Permalink
jail2iso.conf added. jail2iso: playing with UEFI. initenv-tui: re-run…
Browse files Browse the repository at this point in the history
… initenv after commit; jrctl.conf; jclone: fix for ip4_addr
  • Loading branch information
olevole committed Aug 6, 2014
1 parent ea80dff commit abc08a1
Show file tree
Hide file tree
Showing 19 changed files with 693 additions and 370 deletions.
2 changes: 2 additions & 0 deletions etc/defaults/bhyve-freebsd-FreeBSD-from-jail.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ from_jail=1

default_jailname="freebsd"
freesize="2g"

ip4_addr="DHCP"
6 changes: 6 additions & 0 deletions etc/defaults/jail2iso.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PRODUCT="CBSD jail2iso"
LABEL="CBSD"
PUBLISHER="The CBSD Project. http://www.bsdstore.ru"

# enable efi boot ?
efi=1
5 changes: 5 additions & 0 deletions etc/defaults/jrctl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alljails="0"
shownode="0"

# sample of display:
#display="jname,memoryuse,swapuse,nice"
25 changes: 25 additions & 0 deletions etc/defaults/rctl-defaults.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
rctl_profile="defaults"
profile_description="No limits"
stacksize="0"
coredumpsize="0"
memoryuse="0"
memorylocked="0"
maxproc="0"
openfiles="0"
vmemoryuse="0"
pseudoterminals="0"
swapuse="0"
nthr="0"
msgqqueued="0"
msgqsize="0"
nmsgq="0"
nsem="0"
nsemop="0"
nshm="0"
shmsize="0"
wallclock="0"
pcpu="0"
fsquota="0"
nice="0"
bw="0"
nice="0"
5 changes: 5 additions & 0 deletions etc/defaults/rctl-litejail.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rctl_profile="litejail"
profile_description="Limit jail by 512 physical mem, 128MB of swap, 100 descriptors"
openfiles="100"
vmemoryuse="512m"
swapuse="128m"
6 changes: 4 additions & 2 deletions jailctl/jclone
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/local/bin/cbsd
#v10.0.4
#v10.0.7
MYARG="old new host_hostname"
MYOPTARG="ip4_addr verbose"
MYDESC="Jail cloning"
Expand All @@ -22,6 +22,8 @@ myjid=$( cbsdsql local SELECT jid FROM jails WHERE jname=\"${new}\" 2>/dev/null
[ -n "${myjid}" ] && err 1 "${MAGENTA}Jail already exist: ${GREEN}${new}${NORMAL}"

jname="${old}"
ip4_addr_new="${ip4_addr}"

. ${jrcconf}
[ "${emulator}" = "bhyve" ] && err 1 "${MAGENTA}Jail in bhyve mode. Use ${GREEN}cbsd brename${MAGENTA} instead${NORMAL}"

Expand Down Expand Up @@ -74,7 +76,7 @@ fi

cbsdsql local UPDATE jails SET path=\"${jaildir}/${new}\",mount_fstab=\"${jailfstabdir}/${jailfstabpref}${new}\",data=\"${jaildatadir}/${new}-${jaildatapref}\",rcconf=\"${jailrcconfdir}/rc.conf_${new}\",host_hostname=\"${host_hostname}\" WHERE jname=\"${new}\"

[ -n "${ip4_addr}" ] && cbsdsql local UPDATE jails SET ip4_addr=\"${ip4_addr}\" WHERE jname=\"${new}\"
[ -n "${ip4_addr_new}" ] && cbsdsql local UPDATE jails SET ip4_addr=\"${ip4_addr_new}\" WHERE jname=\"${new}\"

jname=${new}
if [ "${verbose}" = "1" ]; then
Expand Down
27 changes: 15 additions & 12 deletions jailctl/jexport
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/local/bin/cbsd
#v9.2.2
globalconf="${workdir}/cbsd.conf";
MYARG="jname"
Expand All @@ -12,6 +12,9 @@ CBSDMODULE="jail"
. ${inventory}
. ${color}
. ${strings}
. ${tools}

[ -z "${1}" ] && select_jail_by_list -s "List of all jails"
init $*

[ -z "${imgname}" ] && imgname="${jname}.img"
Expand All @@ -22,7 +25,7 @@ DEST="${exportdir}/${imgname}"
JAILRCCONF="${jailrcconfdir}/rc.conf_${jname}"

trap "rm -f ${JAILRCCONF}" HUP INT ABRT BUS TERM EXIT
cbsd jmkrcconf jname=${jname} > $JAILRCCONF
jmkrcconf jname=${jname} > $JAILRCCONF

# check for already existance and offline
[ ! -d "${data}" ] && err 1 "${MAGENTA}No jail data for ${jname}: ${GREEN}${data}${NORMAL}"
Expand All @@ -40,36 +43,36 @@ ___NCSTART_DATA=1"
for _part in ${SPACER}; do
case ${_part} in
___NCSTART_HEADER*)
cbsd imgpart mode=pack jname=${jname} part=header out=${DEST}
imgpart mode=pack jname=${jname} part=header out=${DEST}
;;
___NCSTART_RCCONF*)
#currenlty we import/export operation for rc.conf via ascii format
#cause diffrence node can have version of cbsd with incompattible jail schema
#so create rc.conf for pack operation
cbsd imgpart mode=pack jname=${jname} part=rcconf out=${DEST}
imgpart mode=pack jname=${jname} part=rcconf out=${DEST}
;;
___NCSTART_PKGINFO*)
cbsd imgpart mode=pack jname=${jname} part=pkginfo out=${DEST}
imgpart mode=pack jname=${jname} part=pkginfo out=${DEST}
;;
___NCSTART_DESCR*)
cbsd imgpart mode=pack jname=${jname} part=descr out=${DEST}
imgpart mode=pack jname=${jname} part=descr out=${DEST}
;;
___NCSTART_INFO*)
cbsd imgpart mode=pack jname=${jname} part=info out=${DEST}
imgpart mode=pack jname=${jname} part=info out=${DEST}
;;
___NCSTART_FSTAB*)
TMPFSTAB="${ftmpdir}/fstab.$$"
[ ! -f "${mount_fstab}" ] && touch ${mount_fstab}
cp ${mount_fstab} ${TMPFSTAB}
cbsd replacewdir file0="${mount_fstab}" old=${workdir} new="CBSDROOT"
cbsd imgpart mode=pack jname=${jname} part=fstab out=${DEST}
replacewdir file0="${mount_fstab}" old=${workdir} new="CBSDROOT"
imgpart mode=pack jname=${jname} part=fstab out=${DEST}
mv ${TMPFSTAB} ${mount_fstab}
;;
___NCSTART_LOCALFSTAB*)
cbsd imgpart mode=pack jname=${jname} part=localfstab out=${DEST}
imgpart mode=pack jname=${jname} part=localfstab out=${DEST}
;;
___NCSTART_SYSDATA*)
cbsd imgpart mode=pack jname=${jname} part=sysdata out=${DEST}
imgpart mode=pack jname=${jname} part=sysdata out=${DEST}
;;
___NCSTART_DATA*)
#test for zfs mounted & mount if not
Expand All @@ -85,7 +88,7 @@ for _part in ${SPACER}; do
[ $WASNOMOUNT -eq 1 ] && zfs mount "${ZPOOL}"
;;
esac
cbsd imgpart mode=pack jname=${jname} part=data out=${DEST}
imgpart mode=pack jname=${jname} part=data out=${DEST}
[ "$WASNOMOUNT" = "1" ] && zfs unmount "${ZPOOL}"
;;
esac
Expand Down
17 changes: 12 additions & 5 deletions jailctl/jimport
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ CBSDMODULE="jail"
. ${color}
init $*

if [ -n "$list" ]; then
ls -1 ${importdir} |grep .img$ |sed 's/\.img//g'
exit
fi
list_img()
{
ls -1 ${importdir} |grep .img$ |sed 's/\.img//g'
exit 0
}

[ -n "$list" ] && list_img
[ -z "${jname}" ] && jname=$1
[ -z "${jname}" ] && err 1 "${MAGENTA}Give me jname or full path${NORMAL}"

if [ -z "${jname}" ]; then
${ECHO} "${MAGENTA}Give me jname or full path${NORMAL}"
${ECHO} "${MAGENTA}Content of ${GREEN}${importdir}${MAGENTA}:${NORMAL}"
list_img
fi

DATA="${importdir}"
SRC="${DATA}/${jname}.img"
Expand Down
3 changes: 2 additions & 1 deletion jailctl/jrctl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ EXTHELP="wf_jrctl.html"
. ${sharedir}/rctl.conf
. ${workdir}/jrctl.subr

readconf jrctl.conf
init $*

[ -z "${display}" ] && display="jname,memoryuse,maxproc,openfiles,vmemoryuse,swapuse,pcpu,fsquota,nice,bw"
Expand Down Expand Up @@ -117,7 +118,7 @@ show_jails()
exit
fi

if [ -n "${alljails}" ]; then
if [ "${alljails}" = "1" ]; then
show_local
header=0
show_remote
Expand Down
2 changes: 1 addition & 1 deletion release/generate-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cp -Rp /usr/local/cbsd ${DSTDIR}/usr/local

cp /usr/local/bin/rsync ${DSTDIR}/usr/local/bin/

/usr/local/cbsd/release/mkisoimages.sh ${LABEL} /usr/cbsd.iso ${DSTDIR}
/usr/local/cbsd/release/mkisoimages.sh -l ${LABEL} -n /usr/cbsd.iso -d ${DSTDIR}

mv ${DSTDIR}/root/.cshrc-orig ${DSTDIR}/root/.cshrc
mv ${DSTDIR}/etc/ttys-orig ${DSTDIR}/etc/ttys
66 changes: 56 additions & 10 deletions release/mkisoimages.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
#!/bin/sh
bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot"
#bootable=""

if [ $# -lt 3 ]; then
echo "Usage: $0 image-label image-path-name path"
exit 1
# -l "LABEL"
# -n "NAME"
# -d "DPATH"
# -c "CHROOT"
# -p "PUBLISHER"
# -e "1|0" - enable EFI
while getopts "l:n:d:c:p:e:" opt; do
case "$opt" in
l) LABEL="${OPTARG}" ;;
n) NAME="${OPTARG}" ;;
d) DPATH="${OPTARG}" ;;
c) CHROOT="${OPTARG}" ;;
p) PUBLISHER="${OPTARG}" ;;
e) EFI="${OPTARG}" ;;
esac
shift $(($OPTIND - 1))
done

make_efi()
{
local _md _tmpmnt

[ ! -f "${CHROOT}/boot/loader.efi" ] && return 0
/bin/dd if=/dev/zero of=/tmp/efiboot.$$.img bs=4k count=100
_md=$( /sbin/mdconfig -a -t vnode -f /tmp/efiboot.$$.img )
/sbin/newfs_msdos -F 12 -m 0xf8 /dev/${_md}
_tmpmnt=$( mktemp -d )
/sbin/mount -t msdosfs /dev/${_md} ${_tmpmnt}
/bin/mkdir -p ${_tmpmnt}/efi/boot
/bin/cp ${CHROOT}/boot/loader.efi ${_tmpmnt}/efi/boot/bootx64.efi
/sbin/umount ${_tmpmnt}
/sbin/mdconfig -d -u ${_md}
rmdir ${_tmpmnt}
}

[ -z "${LABEL}" ] && LABEL="NOLABEL"

if [ -z "${NAME}" ]; then
echo "Empty NAME, use -n "
exit 1
fi

LABEL=$1
NAME=$2
PATH=$3
PUBLISHER="The CBSD Project. http://www.bsdstore.ru"
if [ -z "${DPATH}" ]; then
echo "Empty DPATH, use -d "
exit 1
fi

[ -z "${PUBLISHER}" ] && PUBLISHER="The CBSD Project. http://www.bsdstore.ru"
[ -z "${EFI}" ] && EFI=1

if [ ${EFI} -eq 1 ]; then
make_efi
bootable="-o bootimage=i386;/tmp/efiboot.$$.img -o no-emul-boot -o bootimage=i386;${CHROOT}/boot/cdboot -o no-emul-boot"
else
bootable="-o bootimage=i386;${CHROOT}/boot/cdboot -o no-emul-boot"
fi

/usr/sbin/makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="${PUBLISHER}" $NAME $PATH
/usr/sbin/makefs -t cd9660 ${bootable} -o rockridge -o label=${LABEL} -o publisher="${PUBLISHER}" ${NAME} ${DPATH}
[ ${EFI} -eq 1 ] && /bin/rm -f /tmp/efiboot.$$.img
2 changes: 2 additions & 0 deletions settings-tui.subr
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ get_jail_ips()
for _i in $(seq 0 255); do
eval _jname="\$jname$_i"
[ -z "${_jname}" ] && break
# skip for myself
[ "${_jname}" = "${jname}" ] && continue
eval _existing_ipjail="\$ips$_i"
[ -z "${_existing_ipjail}" ] && break

Expand Down
18 changes: 15 additions & 3 deletions sudoexec/initenv
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if [ "$1" = "--help" ]; then
exit 0
fi

if [ "$1" = "inter=0" ]; then
inter=0
shift
fi

[ -n "${1}" -a -f "${1}" ] && INITCFG="${1}" && shift

desc_question()
Expand Down Expand Up @@ -591,8 +596,9 @@ start()
-----------------------------
EOF_HEADER

getyesno "Do you want prepare or upgrade hier environment for ${product} now?" || exit 0

if [ "${inter}" != "0" ]; then
getyesno "Do you want prepare or upgrade hier environment for ${product} now?" || exit 0
fi
${ECHO} "${MAGENTA}>>> Installing or upgrading${NORMAL}"
phase0
phase1
Expand Down Expand Up @@ -652,7 +658,13 @@ EOF_HEADER
}

### MAIN ###
[ $# -ne 1 ] && /usr/bin/lockf -t0 -s ${MYLOCK} env INITCFG="${INITCFG}" $0 start
if [ $# -ne 1 ]; then
if [ "${inter}" = "0" ]; then
/usr/bin/lockf -t0 -s ${MYLOCK} env INITCFG="${INITCFG}" $0 inter=0 start
else
/usr/bin/lockf -t0 -s ${MYLOCK} env INITCFG="${INITCFG}" $0 start
fi
fi

case "$1" in
start)
Expand Down
Loading

0 comments on commit abc08a1

Please sign in to comment.