Skip to content

Instantly share code, notes, and snippets.

@dragid10
Last active Jul 11, 2021
Embed
What would you like to do?
#!/bin/bash
# Take in and validate jail name from user
JAIL_NAME=$1
SLEEP_TIME=3
if [[ -z ${JAIL_NAME} ]]; then
>&2 echo "Error: jail name is unset"
exit 1
else
echo "jail name will be '$JAIL_NAME'"
fi
# Packages to install by default on the new jail
# We're installing vim and neovim (for options), as well as java and mono just in case we want to do any C# stuff
echo '{"pkgs":["mediainfo","sqlite3","ca_root_nss","curl","wget","git","vim","zsh","neovim","nano","java/openjdk8","mono"]}' >/tmp/pkg.json
# Create new jail with default params
iocage create --name=$JAIL_NAME --release=12.2-RELEASE --pkglist=/tmp/pkg.json defaultrouter="192.168.1.1" dhcp="on" vnet="on" bpf="on" allow_raw_sockets="1" allow_tun="on" boot="on"
# Commands to run on newly created jail
# Install Oh My Zsh and set it as the default shell experience
echo "Installing Oh My ZSH"
iocage exec $JAIL_NAME -- "pkg update --force --quiet"
iocage exec $JAIL_NAME -- "wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh; sh install.sh"
iocage exec $JAIL_NAME -- "wget https://github.com/jailmanager/jailmanager.github.io/releases/download/v0.0.1/mono-6.8.0.105.txz"
iocage exec $JAIL_NAME -- "pkg install mono-6.8.0.105.txz"
iocage exec $JAIL_NAME -- "chsh -s $(which zsh) $(whoami)"
# Exit successfully
echo "Exiting"
iocage exec $JAIL_NAME -- "exit 0"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment