From 0714cda81fdc4669d7af100105066e17be8af07e Mon Sep 17 00:00:00 2001 From: adv Date: Tue, 2 Aug 2011 18:23:56 +0000 Subject: [PATCH] version 1.0.2 boot-tools #404 #420 git-svn-id: https://opengnsys.es/svn/branches/version1.0@2256 a21b9725-9963-47de-94b9-378ad31fedc9 --- boottoolsfunctions.lib | 72 +++------ boottoolsgenerator.sh | 103 ++++--------- includes/etc/securetty.template | 142 ++++++++++++++++++ .../bin/boot-tools/boottoolsFsOpengnsys.sh | 2 +- .../boottoolsFsPostconfiguration.sh | 22 --- .../boot-tools/boottoolsSoftwareInstall.sh | 2 +- 6 files changed, 195 insertions(+), 148 deletions(-) create mode 100644 includes/etc/securetty.template diff --git a/boottoolsfunctions.lib b/boottoolsfunctions.lib index a5d951b..f968d75 100644 --- a/boottoolsfunctions.lib +++ b/boottoolsfunctions.lib @@ -9,11 +9,9 @@ #*/ - - # btGetVariables: define las constantes a utilizar # Autor: Antonio J. Doblas Viso. Universidad de Málaga. -btogGetVar() +function btogGetVar() { export BTSVNBOOTTOOLS=/tmp/opengnsys_installer/opengnsys/client/boot-tools export BTSVNSHARE=/tmp/opengnsys_installer/opengnsys/client/shared @@ -75,7 +73,7 @@ function btogGetOsInfo () #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 # error code return 2 -btogSetFsVirtual () +function btogSetFsVirtual () { local RERROR DISKLOOP PARTLOOP #return code error @@ -157,7 +155,7 @@ fi #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 # error code return 3 -btogSetFsBase () +function btogSetFsBase () { # Dependencias @@ -197,7 +195,7 @@ fi #@version 1.0 - Compatibilidad OpengGnsys X. #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 -btogSetFsAccess() +function btogSetFsAccess() { echoAndLog "$FUNCNAME: Iniciando la configuración del schroot " cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.`getDateTime` @@ -243,45 +241,46 @@ return 0 #@version 1.0 - Compatibilidad OpengGnsys X. #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 -btogFsInitrd () +function btogFsInitrd () { #DEPENDENCIAS -ogClientVar -ogClientOsInfo -# $1 +[ -z "$BTROOTFSIMG" ] && btogGetVar +[ -z "$OSCODENAME" ] && btogGetOsInfo + + #TODO generara md5 del kernel y del initrd. cd / -schroot -c IMGogclient -- /root/GenerateInitrd.generic.sh -echo "cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR" -cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR -cp /tmp/initrd.img-${OSRELEASE} ${OGCLIENTBASEDIR}/oginitrd.img -cp /tmp/vmlinuz-${OSRELEASE} ${OGCLIENTBASEDIR}/ogvmlinuz +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsInitrdGenerate.sh +echo "cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}" +cp /tmp/*-${OSRELEASE} ${BTTARGETDIR} +cp /tmp/initrd.img-${OSRELEASE} ${BTTARGETDIR}/oginitrd.img +cp /tmp/vmlinuz-${OSRELEASE} ${BTTARGETDIR}/ogvmlinuz cd - chmod -R 755 $OGCLIENTBASEDIR } -#btogFsToSqfs convierte el sistema root en sqfs +#btogFsSqfs convierte el sistema root en sqfs #@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2010/05/24 #@version 1.0 - Compatibilidad OpengGnsys X. #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 -btogFsSqfs () +function btogFsSqfs () { #Dependencias. ogClientVar echoAndLog "$FUNCNAME: Iniciando la creación del sistema de archivos en sqfs " # si ya existe un sqfs lo renombramos -[ -f $OGCLIENTBASEDIR/ogclient.sqfs ] && mv $OGCLIENTBASEDIR/ogclient.sqfs $OGCLIENTBASEDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S` -mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 +[ -f $BTTARGETDIR/ogclient.sqfs ] && mv $BTTARGETDIR/ogclient.sqfs $BTTARGETDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S` +mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 -mksquashfs $OGCLIENTMOUNT $OGCLIENTBASEDIR/ogclient.sqfs -chmod 744 $OGCLIENTBASEDIR/ogclient.sqfs +mksquashfs $BTROOTFSMNT $BTTARGETDIR/ogclient.sqfs +chmod 744 $BTTARGETDIR/ogclient.sqfs -mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT +mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT } @@ -296,9 +295,6 @@ mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011/08/03 function btogIsoGenerator { -apt-get install syslinux genisoimage -#TODO: deb http://free.nchc.org.tw/drbl-core drbl stable -#apt-get install gpxe mkdir -p /tmp/iso/isolinux #cd tmp/iso/ cp -prv /usr/lib/syslinux/* /tmp/iso/isolinux/ @@ -320,16 +316,6 @@ MENU LABEL gpxe KERNEL /clonezilla/live/vmlinuz1 APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia - -#default 0 -#prompt 1 -#timeout 100 - -#display mensaje.txt - - - - LABEL 0 MENU LABEL ogClient vga irqpool acpi ogdebug ip:none KERNEL /ogclient/linuxISO @@ -350,33 +336,24 @@ MENU LABEL ogClient ip=dhcp KERNEL /ogclient/linuxISO APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp - -#LABEL ogclient -#KERNEL /ogclient/linuxISO -#APPEND initrd=/ogclient/initrdISO.img - -#KERNEL linuxISO -#APPEND initrd=initrdISO.img - LABEL 4 MENU LABEL local localboot 0x80 append - - label 5 MENU LABEL Network boot via gPXE lkrn KERNEL gpxe.lkrn -label 5 +label 6 MENU LABEL Network boot via gPXE usb KERNEL gpxe.usb -label 5 +label 7 MENU LABEL Network boot via gPXE pxe KERNEL gpxe.pxe -label 5 +label 8 MENU LABEL Network boot via gPXE iso KERNEL gpxe.iso FIN @@ -391,7 +368,6 @@ mkisofs -V ogClient -o ogClient.iso -b isolinux/isolinux.bin -c isolinux/boot.ca #initrd /oginitrd.img #} - } diff --git a/boottoolsgenerator.sh b/boottoolsgenerator.sh index ce37eff..b21ed84 100755 --- a/boottoolsgenerator.sh +++ b/boottoolsgenerator.sh @@ -33,28 +33,15 @@ echoAndLog "OpenGnSys CLIENT installation begins at $(date)" ########################################################################## ## FASE 1 - Instalación de software adicional. -DEPENDENCIES=( debootstrap subversion schroot squashfs-tools) +cat /etc/apt/sources.list | grep "http://free.nchc.org.tw/drbl-core" || echo "deb http://free.nchc.org.tw/drbl-core drbl stable " >> /etc/apt/sources.list apt-get update -# Instalación de dependencias (paquetes de sistema operativo). -declare -a notinstalled -checkDependencies DEPENDENCIES notinstalled -if [ $? -ne 0 ]; then - installDependencies notinstalled - if [ $? -ne 0 ]; then - echoAndLog "Error while installing some dependeces, please verify your server installation before continue" - exit 1 - fi -fi -########### FIN FASE 1 +apt-get -y --force-yes install debootstrap subversion schroot squashfs-tools syslinux genisoimage apt-get install gpxe ##### FASE 2 - Asignación de variables -#obtenemos las variables necesarias. -btogGetVar -#obtenemos la información del host. -btogGetOsInfo -##### FIN fase 2 +#obtenemos las variables necesarias y la información del host. +btogGetVar && btogGetOsInfo -############# FASE 3: Creación del Sistema Root (Segundo Sistema archivos (img)) +############# FASE 3: Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. file $BTROOTFSIMG | grep "partition 1: ID=0x83" if [ $? == 1 ] @@ -70,26 +57,17 @@ else btogSetFsBase || exit 3 fi - -############### FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot +# FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess - - - -############### FASE 5: Configuración del Segundo Sistema de archivos (img) con la estructura especial de OpenGnsys -cp ${BTSVNBOOTTOOLS}/includes/root/* /tmp/ +# FASE 5: Incorporando con ficheros OG el sistema raiz rootfs +cp -prv ${BTSVNBOOTTOOLS}/includes/usr/bin/* /tmp/ chmod 777 /tmp/*.sh -schroot -p -c IMGogclient -- /tmp/importSVNboot-tools.sh +schroot -p -c IMGogclient -- /tmp/boottoolsFsOpengnsys.sh - - - - - -############# FASE6: Ejecutamos los scripts de personalización del 2º sistema de archivos (img) desde la jaula schroot -### 6.1 instalacion de software con apt-get -schroot -p -c IMGogclient -- /root/InstallSoftware.sh +# FASE6: Instalacion de software +# 6.1 instalacion de software con apt-get +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh echo "saltando" if [ $? -ne 0 ]; then errorAndLog "Instalando sofware adicional OG : ERROR" @@ -97,60 +75,33 @@ echo "saltando" else echoAndLog "Instalando sofware adicional OG: OK" fi -#### 6.2 compilación de software. +# 6.2 compilación de software. cd / -schroot -p -c IMGogclient -- /root/CompileSoftware.sh +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh cd - -### 6.3 configuracion hostname passroot securety -cd / -schroot -c IMGogclient -- /root/ConfFS.sh -cd - -#schroot -c IMGogclient -- echo -ne "og1\nog1\n" | passwd root -# schroot -c IMGogclient -- passwd root | echo "root" - - -### 6.4 incorporamos la clave publica del servidor +#Fase 7. Personalizando +### 7.1 incorporamos la clave publica del servidor cd / ssh-keygen -q -f /root/.ssh/id_rsa -N "" cp /root/.ssh/id_rsa.pub /tmp -schroot -p -c IMGogclient -- /root/importSshKeys.sh +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh cd - -############ y la del propio cliente. -schroot -c IMGogclient -- /root/generateSshKeysClient.sh +### 7.2 y la del propio cliente. +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh -## configuramos los locales. -schroot -c IMGogclient -- /root/ReconfigureLocales.sh +## 7.3 configuramos los locales. +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh exit 99 -################## FIN fase 6. Fin de comfiguración del segundo sistema de archivos (img) - - - - - - - - - - - -################## FASE 7. Generamos el 1er sistema de archivos. INITRD +#Fase 7. Generando la ISO. +#7.1 el initrd btogFsInitrd - - -################## FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) -# generamos el 2sistema de archivos en squashfs -ogClient2ndSqfs -################## FIN FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) - - -##################### FASE 9. algunos detallas del pxe -#dejamos ficheros de ejemplo para el pxe y el nfs -#ogClientConfpxe -##################### FIN FASE 9. algunos detallas del pxe - +#7.2 Convertivos el sistema raiz img en formato sqfs +btogFsSqfs +#7.3 Generamos la iso +btogIsoGenerator # Mostrar sumario de la instalación e instrucciones de post-instalación. installationSummary diff --git a/includes/etc/securetty.template b/includes/etc/securetty.template new file mode 100644 index 0000000..491d8f5 --- /dev/null +++ b/includes/etc/securetty.template @@ -0,0 +1,142 @@ +# /etc/securetty: list of terminals on which root is allowed to login. +# See securetty(5) and login(1). +console + + +pts/0 +pts/1 +pts/2 +pts/3 + + +# Standard serial ports +ttyS0 +ttyS1 +ttyS2 +ttyS3 +ttyS4 +ttyS5 + +# USB dongles +ttyUSB0 +ttyUSB1 +ttyUSB2 + +# PowerMac +ttyPZ0 +ttyPZ1 +ttyPZ2 +ttyPZ3 + +# Embedded MPC platforms +ttyPSC0 +ttyPSC1 +ttyPSC2 +ttyPSC3 +ttyPSC4 +ttyPSC5 + +# PA-RISC mux ports +ttyB0 +ttyB1 + +# Standard hypervisor virtual console +hvc0 + +# Oldstyle Xen console +xvc0 + +# Standard consoles +tty1 +tty2 +tty3 +tty4 +tty5 +tty6 +tty7 +tty8 +tty9 +tty10 +tty11 +tty12 +tty13 +tty14 +tty15 +tty16 +tty17 +tty18 +tty19 +tty20 +tty21 +tty22 +tty23 +tty24 +tty25 +tty26 +tty27 +tty28 +tty29 +tty30 +tty31 +tty32 +tty33 +tty34 +tty35 +tty36 +tty37 +tty38 +tty39 +tty40 +tty41 +tty42 +tty43 +tty44 +tty45 +tty46 +tty47 +tty48 +tty49 +tty50 +tty51 +tty52 +tty53 +tty54 +tty55 +tty56 +tty57 +tty58 +tty59 +tty60 +tty61 +tty62 +tty63 + +# Local X displays (allows empty passwords with pam_unix's nullok_secure) +:0 +:0.0 +:0.1 +:1 +:1.0 +:1.1 +:2 +:2.0 +:2.1 +:3 +:3.0 +:3.1 + +# Embedded Freescale i.MX ports +ttymxc0 +ttymxc1 +ttymxc2 +ttymxc3 +ttymxc4 +ttymxc5 + +# Embedded Renesas SuperH ports +ttySC0 +ttySC1 +ttySC2 +ttySC3 +ttySC4 +ttySC5 \ No newline at end of file diff --git a/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh b/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh index 0067715..d493ef0 100644 --- a/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh +++ b/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh @@ -45,7 +45,7 @@ fi #fi #damos permiso al directorio de scripts -chmod 775 ${SVNCLIENTDIR}/clientstructure/root/* +chmod -R 775 ${SVNCLIENTDIR}/includes/usr/bin/* # los copiamos cp -prv ${SVNCLIENTDIR}/includes/* / diff --git a/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh b/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh index 3e0f4b5..05a7907 100755 --- a/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh +++ b/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh @@ -1,24 +1,2 @@ #!/bin/bash -dpkg-divert --local --rename --add /sbin/initctl -ln -s /bin/true /sbin/initctl -#mv /etc/fstab /etc/fstab.original 2>/dev/null -#mv /etc/mtab /etc/mtab.original 2>/dev/null -#TODO: fichero etc/hosts -#TODO: fichero etc/resolv.conf -echo "ogClient" > /etc/hostname - -#export PASSROOT=og -#dpkg-reconfigure passwd -#echo "root:$PASSROOT" | chpasswd - - -#for i in pts/0 pts/1 pts/2 pts/3 do -# -# -#done -#TODO: introducir mas consoluas para el acceso como root. -echo "pts/0" >> /etc/securetty -echo "pts/1" >> /etc/securetty -echo "pts/2" >> /etc/securetty -echo "pts/3" >> /etc/securetty \ No newline at end of file diff --git a/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh b/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh index 11838ea..2c182ad 100755 --- a/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh +++ b/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh @@ -14,10 +14,10 @@ uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i38 export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" - dpkg-divert --local --rename --add /sbin/initctl ln -s /bin/true /sbin/initctl + apt-get clean apt-get -y update