oglive-builder/includes/etc/initramfs-tools/scripts/oginit

136 lines
4.7 KiB
Bash

# OpenGnsys oginit -*- shell-script -*-
#@file oginit
#@brief Guion modificador inicio initrd para OpenGnsys
#@warning
#@version 0.1 - basado en ROOTfs - rootfs over nfs -
#@author Antonio J. Doblas Viso. Universidad de Málaga
#@date 2009/00/00
#@version 0.2 - basado en RAMFS - instalador de ubunto -
#@author Alejandro Castillo, Ramón Gómez, Irina, Antonio Doblas
#@date 2010/00/00
#@version 0.7 - Hibrido en RAMFS + ROOTFS -mkinitrd, busybox, deboostrap-
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2010/05/24
#@version 0.8 - Soporte smb, asignación ip estática
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2010/06/24
#@version 0.8.1 - Integración RAMFS+ROOTFS con UnionFS y squasfs
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2010/06/29
#@version 1.0. - Adaptacion variables. Corrección enlace red
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2011/06/16
#@version 1.0.1 - Logica para inicio multiples dispositivos, usb, red, cd
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2011/07/4
#@version 1.0.2 - RAMFS: instalación y actualización automatica en cache
#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT.
#@date 2011/08/4
#@version 1.0.5 - Cambiar resolución de pantalla para Kernel con parámetro "video".
#@author Ramón Gómez, ETSII Universidad de Sevilla
#@date 2013/02/18
#*/
og_ask() {
echo "$1" >>/tmp/oginit.log
[ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "$1: y/N "; [ $? == 0 ] && sh || echo " "
}
mountroot () {
[ -f /scripts/VERSION.txt ] && OGVERSION=$(cat /scripts/VERSION.txt)
OGVERSION=${OGVERSION:-"OpenGnsys Client"}
echo; echo; echo "$OGVERSION"; echo; echo
#[ "$quiet" != "y" ] && log_begin_msg "Running OpenGnsys /scripts/og-top"
#run_scripts /scripts/og-top
#[ "$quiet" != "y" ] && log_end_msg
. /scripts/functions
. /scripts/ogfunctions
# If the root device hasn't shown up yet, give it a little while
# to deal with removable devices
sleep 2
og_ask "Stop before get OG variables"
set -a
log_success_msg "Checking kernel parameters"
ogExportKernelParameters
[ -n "$video" ] && ogChangeVideoResolution # Cambiar resolución de vídeo para kernels que usan el parámetro "video".
log_success_msg "Checking OpenGnsys Environmnet"
ogExportVarEnvironment
og_ask "Stop before configure ramfs structure for OG"
ogConfigureRamfs
og_ask "Stop before configure netmoule specified in kernel parameters"
ogLoadNetModule
#[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/og-premount"
#run_scripts /scripts/og-premount
#[ "$quiet" != "y" ] && log_end_msg
og_ask "Stop before configure networking"
if [ -n "$oglive" ]; then
while !(ping -c 1 $oglive &> /dev/null); do
ogConfigureNetworking
done
fi
log_success_msg "config networking"
ogConfigureLoopback
log_success_msg "config loopback"
og_ask "Stop before detect rootserver"
ogGetROOTSERVER && log_success_msg "Get Info from pxe server and ckeck distribuited OG services "
if [ "$ogupdateinitrd" == "true" ]; then
og_ask "Stop before check updating initrd"
fi
if [ "$ogupdateinitrd" == "true" -o ! -d /lib/modules/$(uname -r) ]; then
ogUpdateInitrd # Actualizar Initrd si se solicita o si no se corresponde con su kernel.
fi
og_ask "Stop before connect and merging the rootfs -ogLive- with $OGSERVERLIVE"
ogConnectOgLive && log_success_msg "Merge the initrd with the remote rootfs -ogLive- on $OGSERVERLIVE" || sh
# si es necesario realiza ogConnect $OGSERVERLIVE $OGPROTOCOL $SRCOGLIVE $DSTOGLIVE
og_ask "Stop before connect with client dir SHARE -engine,scripts,interface, -share- on $OGSERVERSHARE "
ogConnect $OGSERVERSHARE $OGPROTOCOL $SRCOGSHARE $DSTOGSHARE
if [ $? -ne 0 -a "$SRCOGSHARE" != "$DEFOGSHARE" ]; then
ogConnect $OGSERVERSHARE $OGPROTOCOL $DEFOGSHARE $DSTOGSHARE && SRCOGSHARE=$DEFOGSHARE
fi
unset DEFOGSHARE
og_ask "Stop before connect with client dir LOG STORAGE on $OGSERVERLOG "
ogConnect $OGSERVERLOG $OGPROTOCOL $SRCOGLOG $DSTOGLOG
og_ask "Stop before connect with REPOSITORY STORAGE on $OGSERVERIMAGES "
ogConnect $OGSERVERIMAGES $OGPROTOCOL $SRCOGIMAGES $DSTOGIMAGES ,ro
og_ask "Stop before doing the postconfiguration"
ogPostConfigureFS
setupcon -k
og_ask "Stop before calling oginit with /etc/inittab"
if [ "$oginit" ]; then
echo "exec oginit ($oginit)" >>/tmp/oginit.log
exec $oginit
else
echo "exec regular init" >>/tmp/oginit.log
exec init
fi
}