diff options
Diffstat (limited to 'core/scripts/setup-install.sh')
-rwxr-xr-x | core/scripts/setup-install.sh | 176 |
1 files changed, 118 insertions, 58 deletions
diff --git a/core/scripts/setup-install.sh b/core/scripts/setup-install.sh index c1d2765..ef1cb10 100755 --- a/core/scripts/setup-install.sh +++ b/core/scripts/setup-install.sh @@ -1,29 +1,34 @@ #!/bin/bash -# Set Global Vars -ADMIN_USER=c9admin -DEV=$1 -CHROOT=$2 - # Absolute path to this script, # e.g. /home/user/c9-doc/core/scripts/foo.sh SCRIPT=$(readlink -f "$0") -# Absolute path this script is in, +# Absolute path this script is in, # e.g. /home/user/c9-doc/core/scripts SCRIPTPATH=$(dirname "$SCRIPT") # Absolute path to doc section, # e.g /home/user/c9-doc/core -DIR=$(dirname "$SCRIPTPATH"); +DIR_SCRIPT=$(dirname "$SCRIPTPATH"); # Absolute path to local data, # e.g /home/user/local -DIR_LOCAL="$(dirname $(dirname ${DIR}))/local"; +DIR_LOCAL="$(dirname $(dirname ${DIR_SCRIPT}))/local"; - -DIR_CONF="${DIR}/conf" -DIR_PRT="${DIR}/ports"; -ISO_FILE="${DIR_LOCAL}/crux-3.3.iso" - -ConfirmOrExit () +# Set Global Vars +ADMIN_USER=c9admin +CHROOT=$1 + +# DATA_DIR directory with data to +# to be installed, can be mounted +# iso file or backup directory from +# backup-system script +# from iso monted; +DATA_DIR=$(dirname "$SCRIPTPATH"); +PORT_PKG="${CHROOT}/media/crux" +# from backup; +#DATA_DIR=$2 +#PORT_PKG="${DATA_DIR}/crux" + +ConfirmOrExit() { while true do @@ -44,47 +49,110 @@ ConfirmOrExit () install_core() { - echo "1.1.4 Create core.lst and install pkgadd" - for p in ${CHROOT}mnt/media/crux/core/*; do echo $p >> ${CHROOT}core.lst; done + mkdir -p ${CHROOT}/usr/ports/packages + mkdir -p ${CHROOT}/var/lib/pkg + touch ${CHROOT}/var/lib/pkg/db + + CORE_LS="${DATA_DIR}/core.pkg" - tar xf "${CHROOT}mnt/media/crux/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}pkgadd + if [ ! -f ${CORE_LS} ]; then + CORE_LS=${CHROOT}/core.pkg + echo "1.1.4 Create core.pkg and install pkgadd" + for p in ${PORT_PKG}/core/*; + do + echo $(basename $p) >> ${CORE_LS}; + done + fi - chmod +x ${CHROOT}pkgadd + tar xf "${PORT_PKG}/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}/pkgadd - echo "1.1.4 File core.lst complete, review list of packages before continue..." + chmod +x ${CHROOT}/pkgadd + + echo "1.1.4 File core.pkg complete, review list of packages before continue..." read PAUSE - vim ${CHROOT}core.lst + vim ${CORE_LS} echo "1.1.4 Starting install" - touch ${CHROOT}/var/lib/pkg/db - cd $CHROOT + #cd $CHROOT while read line; do - echo "Installing $line;\n" - ${CHROOT}pkgadd -u -f -r ${CHROOT} ${line} - done < ${CHROOT}core.lst + pkg=${PORT_PKG}/core/${line} + echo "Installing ${pkg};\n" + ${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg} + done < ${CORE_LS} - rm ${CHROOT}pkgadd - rm ${CHROOT}core.lst + rm ${CHROOT}/pkgadd - mkdir ${CHROOT}usr/ports/packages - cp ${CHROOT}media/crux/core/* ${CHROOT}usr/ports/packages + if [ -f ${CHROOT}/core.pkg ]; then + rm ${CHROOT}/core.pkg; + fi +} + +install_ports() +{ + echo "1.1.5. Install core packages and ports;" + cp ${PORT_PKG}/core/* ${CHROOT}/usr/ports/packages + if [ -f "${PORT_PRT}/core.tar.gz" ]; then + mkdir -p ${CHROOT}/usr/ports/core + tar --xattrs -xpvf $PORT_PRT/core.tar.gz --directory=$CHROOT/usr/ports/core + fi + + echo "1.1.5. Install opt packages and ports;" + cp ${PORT_PKG}/opt/* $CHROOT/usr/ports/packages + if [ -f "${PORT_PRT}/opt.tar.gz" ]; then + mkdir -p ${CHROOT}/usr/ports/opt + tar --xattrs -xpvf $PORT_PRT/opt.tar.gz --directory=$CHROOT/usr/ports/opt + fi + + echo "1.1.5. Install contrib packages and ports;" + cp ${PORT_PKG}/contrib/* $CHROOT/usr/ports/packages + if [ -f "${PORT_PRT}/contrib.tar.gz" ]; then + mkdir -p ${CHROOT}/usr/ports/contrib + tar --xattrs -xpvf $PORT_PRT/contrib.tar.gz --directory=$CHROOT/usr/ports/contrib + fi + + + echo "1.1.5. Install xorg packages and ports;" + cp ${PORT_PKG}/xorg/* $CHROOT/usr/ports/packages + if [ -f "${PORT_PRT}/xorg.tar.gz" ]; then + mkdir -p ${CHROOT}/usr/ports/xorg + tar --xattrs -xpvf $PORT_PRT/xorg.tar.gz --directory=$CHROOT/usr/ports/xorg + fi + + echo "1.1.6. Install extra packages;" + cp ${PORT_PKG}/other/* $CHROOT/usr/ports/packages } setup_core() { + if [ -f "${DATA_CNF}/etc.tar.gz" ]; then + echo "1.1. Extracting configuration data;\n" + tar --xattrs -xpvf $DATA_CNF/etc.tar.gz --directory=$CHROOT/etc + tar --xattrs -xpvf $DATA_CNF/usr_etc.tar.gz --directory=$CHROOT/usr/etc + else + echo "1.1. Copying configuration data;\n" + cp -r $DATA_CNF/skel $CHROOT/etc/ + cp ${PORT_PKG}/handbook.txt $CHROOT/root/ + cp /etc/resolv.conf $CHROOT/etc + cp $DATA_CNF/fstab $CHROOT/etc/ + cp $DATA_CNF/prt-get.conf $CHROOT/etc/ + cp $DATA_CNF/sudoers $CHROOT/etc/ + cp $DATA_CNF/rc.d/* $CHROOT/etc/rc.d/ + cp $DATA_CNF/rc.conf $CHROOT/etc/ + cp $DATA_CNF/pkgmk.conf $CHROOT/etc/ + cp $DATA_CNF/hosts $CHROOT/etc/ + + fi + echo "1.1.7. dns resolver, copy resolv.conf;\n" - cp /etc/resolv.conf $CHROOT/etc + vim /etc/resolv.conf echo "1.1.8. Install Handbook\n" - cp $CHROOT/media/crux/handbook.txt $CHROOT/root/ echo "1.1.9. Install Skeletons\n" - cp -r $DIR_CONF/skel $CHROOT/etc/ echo "1.2.1. Set hostname and hosts;" - cp $DIR_CONF/hosts $CHROOT/etc/ vim $CHROOT/etc/hosts echo "1.2.2. Set timezone;" @@ -103,16 +171,12 @@ setup_core() { chroot $CHROOT /bin/bash -c "usermod -a -G wheel $ADMIN_USER" echo "1.2.4.3. Uncomment to allow members of group wheel to execute any command\n # %wheel ALL=(ALL) ALL" - cp $DIR_CONF/sudoers $CHROOT/etc/ echo "1.2.5. File system table;" - cp $DIR_CONF/fstab $CHROOT/etc/ chroot $CHROOT /bin/bash -c "mount >> /etc/fstab" vim $CHROOT/etc/fstab echo "1.2.6. Initialization Scripts;" - cp $DIR_CONF/rc.d/* $CHROOT/etc/rc.d/ - cp $DIR_CONF/rc.conf $CHROOT/etc/ vim $CHROOT/etc/rc.conf echo "1.3.1. Build as unprivileged user;" @@ -130,7 +194,7 @@ setup_core() { chroot $CHROOT /usr/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ - /bin/bash -c "chown -R root:pkgmk /usr/ports" + /bin/bash -c "chown -R pkgmk:pkgmk /usr/ports" chroot $CHROOT /usr/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ @@ -158,20 +222,15 @@ setup_core() { vim $CHROOT/etc/fstab echo "1.3.3 Configure pkgmk;" - cp $DIR_CONF/pkgmk.conf $CHROOT/etc/ #vim $CHROOT/etc/pkgmk.conf echo "1.3.4 Configure prt-get;" mv $CHROOT/etc/ports/contrib.rsync.inactive $CHROOT/etc/ports/contrib.rsync - cp $DIR_CONF/prt-get.conf $CHROOT/etc/ #vim $CHROOT/etc/prt-get.conf } -install_packages() { - echo "1.1.5. Install extra packages;" - cp $CHROOT/media/crux/opt/* $CHROOT/usr/ports/packages - cp $CHROOT/media/crux/xorg/* $CHROOT/usr/ports/packages +install_packages() { echo "Installing $CHROOT/usr/ports/packages/fakeroot" $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/fakeroot#* @@ -212,27 +271,28 @@ install_packages() { echo "Installing $CHROOT/usr/ports/packages/dosfstools" $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/dosfstools#* - echo "1.1.6. Install extra ports;\n" +} - mkdir $CHROOT/usr/ports/c9-ports - cp -r $DIR_PRT/* $CHROOT/usr/ports/c9-ports/ -} -echo "SCRIPT=$SCRIPT"; +DATA_CNF="${DATA_DIR}/conf" +PORT_PRT="${DATA_DIR}/ports"; + +#echo "SCRIPT=$SCRIPT"; echo "SCRIPTPATH=$SCRIPTPATH"; -echo "ADMIN_USER="$ADMIN_USER"\n" +echo "ADMIN_USER=${ADMIN_USER}" echo "CHROOT=$CHROOT"; -echo "DIR=$DIR"; -echo "DIR_CONF=$DIR_CONF"; -echo "DIR_PRT=$DIR_PRT"; -echo "ISO_FILE=$ISO_FILE"; +echo "DATA_DIR=$DATA_DIR"; +echo "DATA_CNF=$DATA_CNF"; +echo "PORT_PKG=${PORT_PKG}"; +echo "PORT_PRT=${PORT_PRT}"; + ConfirmOrExit -echo "press enter to continue" -read + install_core -#setup_core -#install_packages +install_ports +setup_core +install_packages echo "Ready to chroot $CHROOT /bin/bash \n" |