export JAIL=pkgp
export JAILHOSTNAME=pkgp
export JAILDOMAIN=ahlawat.com
export JAILIP=15
export JAILUSER=X
export JAILUSERID=1000
export JAILUSERVNC=false
export JAILSRC=true
/root/FreeBSD/jails/create.sh $JAIL $JAILHOSTNAME $JAILDOMAIN $JAILIP $JAILUSER $JAILUSERID $JAILUSERVNC $JAILSRC
iocage set jail_zfs=on children_max=32 securelevel=0 allow_mount_devfs=1 devfs_ruleset=4 allow_mount_tmpfs=1 allow_mount_nullfs=1 allow_mount_procfs=1 allow_mount=1 enforce_statfs=1 allow_chflags=1 allow_socket_af=1 allow_mlock=1 sysvmsg=new sysvsem=new sysvshm=new $JAIL
iocage exec $JAIL "mkdir /mnt/cache"
iocage fstab -a $JAIL /zroot/$JAIL /mnt/cache nullfs rw 0 0
iocage exec $JAIL "mkdir /usr/ports"
iocage fstab -a $JAIL /usr/ports /usr/ports nullfs rw 0 0
iocage exec $JAIL "mkdir /var/db/portsnap"
iocage fstab -a $JAIL /var/db/portsnap /var/db/portsnap nullfs rw 0 0
iocage fstab -l $JAIL
iocage exec $JAIL "zfs set mountpoint=/poudriere ship/iocage/jails/pkgp/data"
iocage exec $JAIL "zfs mount ship/iocage/jails/pkgp/data"
# this link is because of the behavior that iocage mounts only under /mnt even though the mountpoint is set for /
iocage exec $JAIL "ln -s /mnt/poudriere /poudriere"
iocage exec $JAIL "pkg install -y poudriere nginx ccache"
# if you want the latest ports version instead
# iocage console $JAIL
# cd /usr/ports/ports-mgmt/poudriere
# make install clean
# cd /usr/ports/www/nginx
# make install clean
# first time "portsnap fetch extract"
# iocage exec $JAIL "if [ -z /usr/ports ]; then portsnap fetch extract; else portsnap auto; fi"
iocage exec $JAIL "portsnap auto"
iocage exec $JAIL mkdir -p /usr/local/etc/ssl/{keys,certs}
iocage exec $JAIL chmod 0600 /usr/local/etc/ssl/keys
# first time
# openssl genrsa -out /usr/local/etc/ssl/keys/poudriere.key 4096
# openssl rsa -in /usr/local/etc/ssl/keys/poudriere.key -pubout -out /usr/local/etc/ssl/certs/poudriere.cert
# cp keys to /mnt/certs
iocage exec $JAIL "cp /mnt/config/ccache.conf /usr/local/etc"
iocage exec $JAIL "cp /mnt/config/ccache.conf /mnt/cache/ccache"
iocage exec $JAIL "cp /mnt/certs/poudriere.key /usr/local/etc/ssl/keys"
iocage exec $JAIL "cp /mnt/certs/poudriere.cert /usr/local/etc/ssl/certs"
iocage exec $JAIL "cp /mnt/config/poudriere.conf /usr/local/etc"
iocage exec $JAIL "cp /mnt/config/make.conf /usr/local/etc/poudriere.d"
iocage exec $JAIL "sysrc nginx_enable=YES"
iocage exec $JAIL "cp /mnt/config/nginx.conf /usr/local/etc/nginx"
iocage exec $JAIL "cp /mnt/config/mime.types /usr/local/etc/nginx"
iocage exec $JAIL "service nginx restart"