Skip to content

Instantly share code, notes, and snippets.

@paulc
Last active April 8, 2021 22:16
Show Gist options
  • Save paulc/1d69f6e7b35f3b7e61a7 to your computer and use it in GitHub Desktop.
Save paulc/1d69f6e7b35f3b7e61a7 to your computer and use it in GitHub Desktop.
FreeBSD 10.0 VM
# pw usermod -n root -s /bin/sh
# export ENV=${HOME}/.shrc
export EDITOR=vi
set -o emacs
alias ls="ls -F"
PS1="[${USER}@\H] \w \$ "
#!/bin/sh
#
# BEFORE: DAEMON
# PROVIDE: ezjail.example.config
#
# ezjail flavour example
. /etc/rc.subr
name=ezjail.flavour.example
start_cmd=flavour_setup
set_shrc() {
[ $# -ne 1 ] && return
su -l $1 -c "cat > .shrc" <<-EOM
export EDITOR=vi
set -o emacs
alias ls="ls -F"
PS1="[\${USER}@\H] \w \\$ "
EOM
}
flavour_setup() {
# Remove traces of ourself
# N.B.: Do NOT rm $0, it points to /etc/rc
##########################
rm -f "/etc/rc.d/ezjail.flavour.example"
# Groups
#########
# Users
########
pw usermod -n root -s /bin/sh -m -k /usr/share/skel
su -l root -c "echo export ENV=/root/.shrc >> .profile"
set_shrc root
pw useradd -n jail -s /bin/sh -m -G wheel -c 'Jail User' -k /usr/share/skel
set_shrc jail
# Files
########
# Packages
###########
ASSUME_ALWAYS_YES=YES pkg bootstrap -f
# Postinstall
##############
}
run_rc_command "$1"
pkg bootstrap
pkg install ezjail
pkg install mdnsresponder
/usr/local/etc/rc.d/mdnsresponderposix
-command_args="-b -P ${mdnsresponderposix_pidfile}"
+command_args="-b -P ${mdnsresponderposix_pidfile} ${mdnsresponderposix_flags}"
ext_if = "{ em0 }"
nat_if = "{ lo1 }"
nat pass on $ext_if from $nat_if to any -> $ext_if
# System
fsck_y_enable="YES"
dumpdev="AUTO"
# Network
hostname="freebsd10"
ifconfig_em0="DHCP"
cloned_interfaces="lo1"
ipv4_addrs_lo1="192.168.1.1-8/24"
# Services
sshd_enable="YES"
#sshd_flags="-o ListenAddress=$(ifconfig em0 | awk '/inet / { print $2 }' )"
sshd_flags="-o ListenAddress=10.0.1.127"
syslogd_flags="-s -b 127.0.0.1"
mdnsresponderposix_enable="YES"
mdnsresponderposix_flags="-n $(hostname) -t _ssh._tcp. -p 22"
pf_enable="YES"
ntpdate_enable="YES"
ezjail_enable="YES"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment