oglive-builder/old/ogFSHlnk/initramfs-tools-OG-unionfs/etc/initramfs-tools-OG/scripts/og

195 lines
4.6 KiB
Bash

# OpenGnsys Local filesystem mounting -*- shell-script -*-
ogLinkBusybox ()
{
for n in `busybox | tail -19 | tr "," "\\n" | sed -e "s/ \|\t//"|grep .` ; do
ln -f /bin/busybox /bin/$n
done
ln -f /bin/busybox /bin/sh
}
ogConfigureRamfs ()
{
mkdir -p /tmp/og2ndFStmp/
touch /tmp/og2ndFStmp/modules.dep.temp
touch /tmp/og2ndFStmp/modules.dep
}
ogExportKernelParameters ()
{
GLOBAL="cat /proc/cmdline"
for i in `${GLOBAL}`
do
echo $i | grep "=" > /dev/null && export $i
done
}
ogCheckPointBreak ()
{
# firstshell=0 SH para Arranque en modo depuracion para el cliente intrd
if [ "$firstshell" = "0" ]
then
echo "entrando en sh antes de configurar la red"
sh
fi
if [ "$firstshell" = "1" ]
then
echo "entrando en sh despues de configurar la red"
sh
fi
# firstrunt=sh Arranque en modo depuracion para el cliente intrd
if [ "$firstrun" = "9" ]
then
sh
fi
}
ogLoadNetModule ()
{
#cargando netmodule
if [ -n "$netmodule" ]
then
echo "Cargando modulo de red $netmodule"
insmod `find /lib/modules/ -name ${netmodule}*`
fi
}
ogGetROOTSERVER ()
{
# get nfs root from dhcp
if [ "x${NFSROOT}" = "xauto" ]; then
# check if server ip is part of dhcp root-path
if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
else
NFSROOT=${ROOTPATH}
fi
# nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
elif [ -n "${NFSROOT}" ]; then
# nfs options are an optional arg
if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
NFSOPTS="-o ${NFSROOT#*,}"
fi
NFSROOT=${NFSROOT%%,*}
if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
NFSROOT=${ROOTSERVER}:${NFSROOT}
fi
fi
export ROOTSERVER
}
ogConectROOTSERVER ()
{
echo Preparando conexión con el Repositorio \$ROOTSERVER \$BOOTMODE \$MOUNTOPTS
## Montamos el resto de cosas necesarias
#printf "$MSG_MOUNTREPO\n" $BOOTMODE;
nfsmount -o nolock,ro $ROOTSERVER:/opt/opengnsys/client /opt/opengnsys;
#mount -t nfs -onolock,ro $ROOTSERVER:/opt/opengnsys/client /opt/opengnsys;
nfsmount -o nolock $ROOTSERVER:/opt/opengnsys/log/clients /opt/opengnsys/log;
#mount -t nfs -o nolock $ROOTSERVER:/opt/opengnsys/log/clients /opt/opengnsys/log;
#mount -t nfs -o "\$MOUNTOPTS" \$SERVERNFS:/opt/opengnsys/images /opt/opengnsys/images;
#mount -t tmpfs none /opt/opengnsys/images -o size=5m
}
unionmount()
{
FUSE_OPT="-o default_permissions -o allow_other -o use_ino -o nonempty -o suid"
UNION_OPT="-o cow -o noinitgroups"
UPATH="/unionfs"
UBIN="unionfs-fuse"
mkdir -p /unionfs/host
mkdir -p /unionfs/union
dir=$1
#echo "creando mkdir -p /unionfs/host/$dir"
mkdir -p /unionfs/host/$dir
#echo "montando mount --bind /$dir /unionfs/host/$dir "
mount --bind /$dir /unionfs/host/$dir
##########echo "creando mkdir -p /unionfs/union/$dir"
mkdir -p /unionfs/union/$dir
host="/unionfs/host/${dir}=RW"
common="/opt/og2fs/${dir}=RO"
#####echo " ejecuantdo $UBIN $FUSE_OPT $UNION_OPT ${host}:${common} /unionfs/union/$dir "
$UBIN $FUSE_OPT $UNION_OPT ${host}:${common} /unionfs/union/$dir
mount --bind /unionfs/union/$dir /$dir
}
# Parameter: Where to mount the filesystem
mountroot ()
{
[ "$quiet" != "y" ] && log_begin_msg "Running OpenGnsys /scripts/og-top"
run_scripts /scripts/og-top
[ "$quiet" != "y" ] && log_end_msg
# If the root device hasn't shown up yet, give it a little while
# to deal with removable devices
ogConfigureRamfs
ogExportKernelParameters
ogCheckPointBreak
ogLoadNetModule
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/og-premount"
run_scripts /scripts/og-premount
[ "$quiet" != "y" ] && log_end_msg
. /scripts/functions
configure_networking
# for the portmapper we need localhost
ifconfig lo 127.0.0.1
/etc/init.d/portmap start
ogGetROOTSERVER
ogCheckPointBreak
ogConectROOTSERVER
# ogConectROOTMEDIA
ogCheckPointBreak
mkdir -p /opt/og2fs
mount /opt/opengnsys/og2ndFS /opt/og2fs -o loop -o ro
#mount -t tmpfs -o size=8192 tmpfs /unionfs
for i in etc; do
unionmount $i
done
# root var lib bin sbin usr
cat /proc/mounts > /etc/mtab
#cp -R /opt/og2fs/etc/* /etc/ # */
mount /opt/og2fs/usr /usr
mount /opt/og2fs/lib /lib
mount /opt/og2fs/bin /bin
mount /opt/og2fs/sbin /sbin
#export PATH=$PATH:/opt/og2fs/opt/drbl/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
#chmod 777 /etc/rcog
##unset PATH
##export PATH=$PATH:/opt/og2fs/sbin
##export PATH=/opt/og2fs/bin:$PATH
##export PATH=/opt/og2fs/sbin:$PATH
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/og-bottom"
run_scripts /scripts/og-bottom
[ "$quiet" != "y" ] && log_end_msg
#set -a
#trap "mount | grep loop && /opt/og2fs/bin/bash" 1 2 3 9 15
#/opt/opengnsys/etc/preinit/default.sh
echo "llamando a init desde scritps og"
exec init
}