[PC-BSD Commits] r21884 - in pcbsd/current/src-sh/warden: bin scripts/backend

svn at pcbsd.org svn at pcbsd.org
Sat Mar 16 17:14:48 PDT 2013


Author: kris
Date: 2013-03-17 00:14:48 +0000 (Sun, 17 Mar 2013)
New Revision: 21884

Modified:
   pcbsd/current/src-sh/warden/bin/warden
   pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/functions.sh
Log:

New feature! When creating warden jails, now we will boot-strap PKGNG, and setup
the pcbsd-utils package, allowing the user to pull packages from our repo, and use
pc-metapkgmanager, PBI, etc. 



Modified: pcbsd/current/src-sh/warden/bin/warden
===================================================================
--- pcbsd/current/src-sh/warden/bin/warden	2013-03-16 23:20:21 UTC (rev 21883)
+++ pcbsd/current/src-sh/warden/bin/warden	2013-03-17 00:14:48 UTC (rev 21884)
@@ -45,6 +45,7 @@
 
 echo "
          auto - Toggles the autostart flag for a jail
+      bspkgng - BootStrap pkgng and setup TrueOS repo
       checkup - Check for updates to a jail
        chroot - Launches chroot into a jail 
        create - Creates a new jail 
@@ -326,7 +327,24 @@
 "
 };
 
+help_bspkgng()
+{
+ title
+ echo "Help bspkgng
 
+BootStraps the pkgng package system, and installs the TrueOS repository
+and utilities into a jail. 
+
+Usage:
+
+  warden bspkgng <IP>
+
+Example:
+
+  warden bspkgng 192.168.0.5
+"
+};
+
 help_auto()
 {
  title
@@ -510,6 +528,7 @@
   -32       		       (Create 32bit jail on 64bit system)
   --src       		       (Includes /usr/src system source)
   --ports     		       (Includes the ports tree)
+  --vanilla    		       (Don't install PC-BSD pkgng repo and utilities)
   --startauto 		       (Start this jail at system boot)
   --portjail  		       (Make this a portjail)
   --linuxjail <script>         (Make this a linux jail and use supplied script for installation)
@@ -535,6 +554,7 @@
 
    help) case "$2" in
              auto) help_auto ;;
+          bspkgng) help_bspkgng ;;
            create) help_create ;;
            start) help_start ;;
            stop) help_stop ;;
@@ -631,7 +651,14 @@
 	   *) exit_err "Invalid TYPE" ;;
          esac
          ;;
+ bspkgng) require_root
+	 IP="${2}"
 
+         if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
+         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         bootstrap_pkgng "${JDIR}/$IP"
+         ;;
+
    auto) require_root
 	 IP="${2}"
 
@@ -857,7 +884,8 @@
              --src) SRC="YES" ;;
              --ports) PORTS="YES" ;;
              --startauto) AUTO="YES" ;;
-             --portjail) PORTJAIL="YES" ;;
+              --portjail) PORTJAIL="YES" ;;
+               --vanilla) VANILLA="YES" ;;
              --linuxjail) LINUXJAIL="YES" ; shift
 			  if [ -z "$1" ] ; then exit_err "No linux setup script specified!"; fi
 			  LINUX_JAIL_SCRIPT="$1" ; export LINUX_JAIL_SCRIPT
@@ -896,7 +924,7 @@
          if [ -e "${JDIR}/${IP}" ]; then exit_err "A jail with this IP already exists!"; fi  
 
           # Passed all tests, create the jail now
-          ${PROGDIR}/scripts/backend/createjail.sh "${IP}" "${HOST}" "${SRC}" "${PORTS}" "${AUTO}" "${PORTJAIL}" "${LINUXJAIL}" "${ARCHIVE_FILE}"
+          ${PROGDIR}/scripts/backend/createjail.sh "${IP}" "${HOST}" "${SRC}" "${PORTS}" "${AUTO}" "${PORTJAIL}" "${LINUXJAIL}" "${ARCHIVE_FILE}" "$VANILLA"
 
         ;;
   delete) require_root

Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-03-16 23:20:21 UTC (rev 21883)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-03-17 00:14:48 UTC (rev 21884)
@@ -79,6 +79,7 @@
 PORTJAIL="${6}"
 LINUXJAIL="${7}"
 ARCHIVEFILE="${8}"
+VANILLA="${9}"
 
 # See if we are overriding the default archive file
 if [ ! -z "$ARCHIVEFILE" ] ; then
@@ -236,25 +237,32 @@
   touch "${JMETADIR}/autostart"
 fi
 
+# Allow pinging by default
+echo "allow.raw_sockets=true" > ${JMETADIR}/jail-flags
+
 # Check if we need to copy the timezone file
 if [ -e "/etc/localtime" ] ; then
    cp /etc/localtime ${JDIR}/${IP}/etc/localtime
 fi
 
+# Setup PC-BSD PKGNG repo / utilities
+if [ "$VANILLA" != "YES" ] ; then
+  bootstrap_pkgng "${JAILDIR}"
+  if [ $? -ne 0 ] ; then
+     echo "You can manually re-try by running # warden bspkgng ${IP}"
+  fi
+fi
+
 # Set the default meta-pkg set
 mkdir -p ${JDIR}/${IP}/usr/local/etc >/dev/null 2>/dev/null
-echo "PCBSD_METAPKGSET: warden" > ${JDIR}/${IP}/usr/local/etc/pcbsd.conf
+echo "PCBSD_METAPKGSET: trueos" > ${JDIR}/${IP}/usr/local/etc/pcbsd.conf
 
-# Copy over the pbid scripts
-checkpbiscripts "${JDIR}/${IP}"
-
 # Check if making a portjail
 if [ "$PORTJAIL" = "YES" ] ; then mkportjail "${JDIR}/${IP}" ; fi
 
 # If we are auto-starting the jail, do it now
 if [ "$STARTUP" = "YES" ] ; then warden start ${IP} ; fi
 
-echo "Success!"
 echo "Jail created at ${JDIR}/${IP}"
 
 exit 0

Modified: pcbsd/current/src-sh/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-03-16 23:20:21 UTC (rev 21883)
+++ pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-03-17 00:14:48 UTC (rev 21884)
@@ -351,3 +351,41 @@
       fi
    done
 }
+
+bootstrap_pkgng()
+{
+  cd ${1}
+  SYSVER="$(uname -r)"
+  echo "Boot-strapping pkgng"
+  mkdir -p ${1}/usr/local/etc
+  cp /usr/local/etc/pkg-pubkey.cert ${1}/usr/local/etc/
+
+  echo '#!/bin/sh
+  tar xvf pkg.txz --exclude +MANIFEST --exclude +MTREE_DIRS 2>/dev/null
+  pkg add pkg.txz
+  rm pkg.txz
+  ARCH=$(uname -m)
+  REL=$(uname -r)
+  echo "packagesite: http://getmirror.pcbsd.org/packages/$REL/$ARCH" >/usr/local/etc/pkg.conf
+  echo "HTTP_MIRROR: http" >>/usr/local/etc/pkg.conf
+  echo "PUBKEY: /usr/local/etc/pkg-pubkey.cert" >>/usr/local/etc/pkg.conf
+  echo "PKG_CACHEDIR: /usr/local/tmp" >>/usr/local/etc/pkg.conf
+  pkg install -y pcbsd-utils
+  exit $?
+' > ${1}/bootstrap-pkgng
+  chmod 755 ${1}/bootstrap-pkgng
+
+  if [ -e "pkg.txz" ] ; then rm pkg.txz ; fi
+  get_file_from_mirrors "/packages/${SYSVER}/${ARCH}/Latest/pkg.txz" "pkg.txz"
+  if [ $? -eq 0 ] ; then
+    chroot ${1} /bootstrap-pkgng
+    if [ $? -eq 0 ] ; then
+      rm ${1}/bootstrap-pkgng
+      chroot ${1} pc-extractoverlay server --sysinit
+      return 0
+    fi 
+  fi
+  echo "Failed boot-strapping PKGNG, most likely cause is internet connection failure."
+  rm ${1}/bootstrap-pkgng
+  return 1
+}



More information about the Commits mailing list