#!/bin/sh # server-side script to add an architecture. Should be run as root. # configurable variables pbc=${PORTBUILD_CHECKOUT:-/a/portbuild} pbd=${PORTBUILD_DATA:-/a/portbuild} PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:${pbc}/scripts QMANAGER=qmanager.py test_fs() { local fs=$1 zfs list -Ht filesystem ${fs} > /dev/null 2>&1 } usage () { echo "usage: $0 arch" exit 1 } if [ ! -e ${pbc}/admin/conf/admin.conf ] ; then echo "You must first create ${pbc}/admin/conf/admin.conf." exit 1 fi . ${pbc}/admin/conf/admin.conf if [ ! -e ${pbc}/conf/server.conf ] ; then echo "You must first create ${pbc}/admin/conf/admin.conf." exit 1 fi . ${pbc}/admin/conf/admin.conf if [ ! -e ${pbc}/conf/server.conf ] ; then echo "You must first create ${pbc}/conf/server.conf." exit 1 fi . ${pbc}/conf/server.conf if [ $# -lt 1 ]; then usage fi arch=$1 # validate arch. this somewhat duplicates buildenv. valid_arch=0 for i in ${SUPPORTED_ARCHS}; do if [ ${i} = ${arch} ]; then valid_arch=1 break fi done if [ $valid_arch = 0 ]; then echo "You must first add ${arch} to SUPPORTED_ARCHS in ${pbc}/admin/conf/admin.conf." echo "Currently supported archs are: ${SUPPORTED_ARCHS}." exit 1 fi if [ ! -z "${PORTBUILD_USER}" ]; then uid=${PORTBUILD_USER} else echo "You must first define PORTBUILD_USER in ${pbc}/admin/conf/admin.conf." exit 1 fi if [ ! -z "${PORTBUILD_GROUP}" ]; then gid=${PORTBUILD_GROUP} else gid=${uid} fi # create zfs instance for arch if it does not already exist. (duplicates 'build') archdir=${pbd}/${arch} archfs=${ZFS_VOLUME}/portbuild/${arch} if ! test_fs "${archfs}"; then echo "The ${archfs} filesystem does not exist. I'll create and mount it for you." zfs create ${archfs} || exit 1 fi loads=${archdir}/loads if [ ! -d ${loads} ]; then echo "The ${loads} directory does not exist. I'll create it for you." mkdir -p ${loads} || exit 1 fi lockfiles=${archdir}/lockfiles if [ ! -d ${lockfiles} ]; then echo "The ${lockfiles} directory does not exist. I'll create it for you." mkdir -p ${lockfiles} || exit 1 fi mlist=${archdir}/mlist if [ ! -e ${mlist} ]; then echo "${mlist} does not exist. I'll create an empty one." touch ${mlist} fi conf=${archdir}/portbuild.conf if [ ! -e ${conf} ]; then echo "${conf} does not exist. I'll try to create it, but you may not like the defaults." cat >> ${conf} << EOF arch=${arch} client_user=${uid} user=${uid} pb=/a/portbuild rsync_gzip=-z scp_cmd="/usr/bin/scp" ssh_cmd="/usr/bin/ssh" sudo_cmd="sudo -H" disconnected=1 http_proxy="http://localhost:3128/" mailto=root@`hostname` md_size=11g pkg_sufx=".tbz" scratchdir=/usr2/pkgbuild squid_dir=/usr2/squid use_jail=1 use_md_swap=1 use_zfs=0 EOF chown -R ${uid}:${gid} ${conf} || exit 1 chmod 664 ${conf} || exit 1 fi if [ ! -x ${pbc}/qmanager/${QMANAGER} ]; then echo "you need to install ${QMANAGER} under ${pbc}/qmanager/ and re-run this script." exit 1 else running=`ps ax | grep -v grep | grep ${QMANAGER}` if [ -z "${running}" ]; then echo "${QMANAGER} is not running. run '/usr/local/etc/rc.d/qmanager start' and re-run this script." exit 1 else echo "adding default entry to qmanager ..." python ${pbc}/qmanager/qclient add_acl name=deny_all uidlist= gidlist= sense=0 echo "adding ${arch} to qmanager ..." python ${pbc}/qmanager/qclient add_acl name=ports-${arch} uidlist=${uid} gidlist=${gid} sense=1 echo "... done." fi fi