diff options
author | Mario Izquierdo (mariodebian) <mariodebian@gmail.com> | 2012-06-22 12:42:53 +0100 |
---|---|---|
committer | Mario Izquierdo (mariodebian) <mariodebian@gmail.com> | 2012-06-22 12:42:53 +0100 |
commit | 85e11fb132b2b81b50a45647b070e8f6fd648d65 (patch) | |
tree | 1238a0e269d68604457ef6435e1c7ec18ffe7e20 /scripts |
tcos (0.89.90) unstable; urgency=low
* debian/initramfs-tools-tcos.postrm:
- piuparts, don't call delgroup if can't
* Add overlayfs as aufs alternative
* hooks-addons/clean_initramfs: multiarch with libpci3
* Simplify grep commands
* Install conf/tcos.conf instead of conf/tcos.conf.etc
* Use a global LIB_MULTIARCH var
* tcos-standalone French translation, thanks to Julien Patriarca, (closes: #672135)
# imported from the archive
Diffstat (limited to 'scripts')
35 files changed, 2376 insertions, 0 deletions
diff --git a/scripts/tcos b/scripts/tcos new file mode 100644 index 0000000..e0f0fba --- /dev/null +++ b/scripts/tcos @@ -0,0 +1,29 @@ +# TCOS -*- shell-script -*- +# (Thin Client Operating System)live filesystem mounting +# + + +# Parameter: Where to mount the filesystem +mountroot () +{ + # checkings + #log_begin_msg "Running /scripts/tcos-top" + run_scripts /scripts/tcos-top + #log_end_msg + + # if not booting in NFS mode exec other scripts + if [ "$(cat /tmp/less_ram)" = "0" ]; then + # Find and mount the Image + maybe_break tcos-premount + + #log_begin_msg "Running /scripts/tcos-premount" + run_scripts /scripts/tcos-premount + #log_end_msg + + maybe_break tcos-bottom + + #log_begin_msg "Running /scripts/tcos-bottom" + run_scripts /scripts/tcos-bottom + #log_end_msg + fi +} diff --git a/scripts/tcos-bottom/01download_settings b/scripts/tcos-bottom/01download_settings new file mode 100755 index 0000000..a9de132 --- /dev/null +++ b/scripts/tcos-bottom/01download_settings @@ -0,0 +1,27 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +# if break=download_settings STOP here +maybe_break download_settings + +. /conf/tcos.conf +. /conf/tcos-run-functions + +MYIP=$(awk -F"=" '/^ip=/ {print $2}' /tmp/net.data) + +download_file /tcos/conf/${MYIP}.conf /conf/mysettings.conf +if [ $? -eq 0 ]; then + log_begin_msg "Download personalized settings ${MYIP}.conf" + log_end_msg 0 +else + log_begin_msg "No personalized settings to download" + log_end_msg 0 +fi + +exit 0 diff --git a/scripts/tcos-bottom/04hwclock b/scripts/tcos-bottom/04hwclock new file mode 100755 index 0000000..27f4068 --- /dev/null +++ b/scripts/tcos-bottom/04hwclock @@ -0,0 +1,19 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +# fixme, don't work as expected +exit 0 + +quiet=n +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +log_begin_msg "Setting clock based on hardware clock" + hwclock --localtime --hctosys +log_end_msg $? + +exit 0 diff --git a/scripts/tcos-bottom/05inittcos b/scripts/tcos-bottom/05inittcos new file mode 100755 index 0000000..3ec628d --- /dev/null +++ b/scripts/tcos-bottom/05inittcos @@ -0,0 +1,52 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +# if break=inittcos STOP here +maybe_break inittcos + + +# Loop over every line in /etc/modules. +# patch from Roberto IbaƱez +grep '^[^#]' /etc/modules | \ +while read module args; do + [ "$module" ] || continue + modprobe "$module" "$args" >> /tmp/initramfs.debug 2>&1 +done + + +# load modules +if [ -x /usr/bin/pcimodules ]; then + for mod in $(pcimodules) ; do + modprobe -s -k "$mod" >> /tmp/initramfs.debug 2>&1 & + done +fi +# detect Xorg kernel module and driver +# pcimodules --class 0x30000 --classmask 0xffff00 | grep -v fb$ + + + +if [ "$(which loadkeys)" ]; then + _log "INITTCOS loading keymap" + log_begin_msg "Loading default server keymap" + [ -e /etc/console/boottime.kmap.gz ] && loadkeys -q /etc/console/boottime.kmap.gz >> /tmp/initramfs.debug 2>&1 & + [ -e /etc/console-setup/cached.kmap.gz ] && loadkeys -q /etc/console-setup/cached.kmap.gz >> /tmp/initramfs.debug 2>&1 & + [ -e /etc/console-setup/boottime.kmap.gz ] && loadkeys -q /etc/console-setup/boottime.kmap.gz >> /tmp/initramfs.debug 2>&1 & + log_end_msg $? +else + _log "INITTCOS not loading default keymap" +fi + + + + + +exit 0 diff --git a/scripts/tcos-bottom/06start_acpi b/scripts/tcos-bottom/06start_acpi new file mode 100755 index 0000000..c5ff993 --- /dev/null +++ b/scripts/tcos-bottom/06start_acpi @@ -0,0 +1,12 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + + +quiet=n + +[ -x /sbin/startacpid ] && /sbin/startacpid > /var/log/acpid.log 2>&1 + +exit 0 diff --git a/scripts/tcos-bottom/10ldconfig b/scripts/tcos-bottom/10ldconfig new file mode 100755 index 0000000..acdbe6b --- /dev/null +++ b/scripts/tcos-bottom/10ldconfig @@ -0,0 +1,78 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +# if break=ldconfig STOP here +maybe_break ldconfig + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + +# update lib cache +log_begin_msg "Updating lib cache" + /usr/sbin/ldconfig >> /tmp/initramfs.debug 2>&1 & +log_end_msg $? + +# needed for ssh login +grep ^export /conf/tcos.conf > /root/.profile + +# mount /dev/shm +# if not mounted +# this causes to break browsers and italc +mkdir -p /dev/shm +mount -t tmpfs shmfs /dev/shm >>/tmp/initramfs.debug 2>&1 + +# italc 1.0.0 new version +if [ -x /sbin/startica ]; then + ln -s /sbin/startica /sbin/startivs +fi + + +if [ -z "$(which Xorg)" ]; then + _log "LDCONFIG Xorg not found" + log_failure_msg "Xorg not found" + log_end_msg 1 + exit 0 +fi + + + + _log "LDCONFIG Updating links in Xorg 7.x mode" + [ ! -e /usr/lib/libGLcore.so.1 -a -e /usr/lib/libGLcore.so ] && ln -sf /usr/lib/libGLcore.so /usr/lib/libGLcore.so.1 + [ ! -e /usr/lib/libGL.so.1 -a -e /usr/lib/libGL.so.1.2 ] && ln -sf /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1 + [ ! -e /usr/lib/libGL.so -a -e /usr/lib/libGL.so.1 ] && ln -sf /usr/lib/libGL.so.1 /usr/lib/libGL.so + [ ! -e /usr/lib/libGLU.so.1 -a -e /usr/lib/libGLU.so ] && ln -sf /usr/lib/libGLU.so /usr/lib/libGLU.so.1 + mkdir -p /usr/share/X11/ + ln -s /etc/X11/rgb.txt /usr/share/X11/rgb.txt + ln -s /usr/share/X11/xkb /etc/X11/xkb + mkdir -p /usr/X11R6 >> /tmp/initramfs.debug 2>&1 + ln -s /usr/bin /usr/X11R6/bin >> /tmp/initramfs.debug 2>&1 + + mkdir -p /var/lib/xkb + ln -s /var/lib/xkb /etc/X11/xkb/compiled + ln -s /usr/bin/xkbcomp /etc/X11/xkb/xkbcomp + + # make links in keymap rules + [ ! -e /usr/share/X11/xkb/rules/xfree86 ] &&\ + ln -s /usr/share/X11/xkb/rules/base /usr/share/X11/xkb/rules/xfree86 + [ ! -e /usr/share/X11/xkb/rules/xfree86.lst ] &&\ + ln -s /usr/share/X11/xkb/rules/base.lst /usr/share/X11/xkb/rules/xfree86.lst + [ ! -e /usr/share/X11/xkb/rules/xfree86.xml ] &&\ + ln -s /usr/share/X11/xkb/rules/base.xml /usr/share/X11/xkb/rules/xfree86.xml + + [ ! -e /usr/share/X11/xkb/rules/xorg ] &&\ + ln -s /usr/share/X11/xkb/rules/base /usr/share/X11/xkb/rules/xorg + [ ! -e /usr/share/X11/xkb/rules/xorg.lst ] &&\ + ln -s /usr/share/X11/xkb/rules/base.lst /usr/share/X11/xkb/rules/xorg.lst + [ ! -e /usr/share/X11/xkb/rules/xorg.xml ] &&\ + ln -s /usr/share/X11/xkb/rules/base.xml /usr/share/X11/xkb/rules/xorg.xml + + +exit 0 diff --git a/scripts/tcos-bottom/22intel b/scripts/tcos-bottom/22intel new file mode 100755 index 0000000..51c5f51 --- /dev/null +++ b/scripts/tcos-bottom/22intel @@ -0,0 +1,28 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n +. /conf/tcos.conf + +[ "$TCOS_XORG_VIDEO_DRIVER" = "fullauto" ] && exit 0 +[ "$TCOS_XORG_VIDEO_DRIVER" = "xorgauto" ] && exit 0 + +test_intel=0 +test_intel=$(get_vga_vendor 8086) + +if [ -e /usr/lib/xorg/modules/drivers/intel_drv.so ] && [ "$test_intel" = "1" ]; then + # force intel driver (intel don't like VESA) + configurexorg --newsettings --xdriver=intel +fi + + + + + + + +exit 0 + diff --git a/scripts/tcos-bottom/25startx b/scripts/tcos-bottom/25startx new file mode 100755 index 0000000..3a7c0a9 --- /dev/null +++ b/scripts/tcos-bottom/25startx @@ -0,0 +1,128 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions +. /conf/tcos-modules.conf + +# set limits in memory +. /bin/set-limits + + +# if break=startx STOP here +maybe_break startx + + +modprobe -q mousedev 2>&1 >> /tmp/initramfs.debug +modprobe -q psmouse 2>&1 >> /tmp/initramfs.debug +modprobe -q agpgart 2>&1 >> /tmp/initramfs.debug + + + +# Create magic cookie +# http://www.xs4all.nl/~zweije/xauth-6.html +# cookie=$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | awk '{print $1}' |sed -e 's/^/add :0 . /') +# cookie=$(mcookie) +# xauth -f /root/.Xauthority -q ${cookie} + +if [ ! -f $XAUTHORITY ]; then + value=0 + log_begin_msg "Creating magic cookie for X" + _log "STARTX creating cookie..." + #MYIP=$(awk -F"=" '/^ip=/ {print $2}' /tmp/net.data) + MYIP=$(getinfo.sh -i NETWORK_IP) + cookie=$(mcookie || value=1) + xauth -f $XAUTHORITY -q add :0 MIT-MAGIC-COOKIE-1 $cookie 2>> /tmp/initramfs.debug || value=1 + xauth -f $XAUTHORITY -q add localhost:0 MIT-MAGIC-COOKIE-1 $cookie 2>> /tmp/initramfs.debug || value=1 + xauth -f $XAUTHORITY -q add localhost.localdomain:0 MIT-MAGIC-COOKIE-1 $cookie 2>> /tmp/initramfs.debug || value=1 + xauth -f $XAUTHORITY -q add $(hostname):0 MIT-MAGIC-COOKIE-1 $cookie 2>> /tmp/initramfs.debug || value=1 + xauth -f $XAUTHORITY -q add ${MYIP}:0 MIT-MAGIC-COOKIE-1 $cookie 2>> /tmp/initramfs.debug || value=1 + # for new LTSPFS + echo $cookie > /var/run/ltspfs_token + #xauth list >> /tmp/initramfs.debug + _log "STARTX end cookie" + log_end_msg $value +fi + + +# read some settings from cmdline +# DOCUMENTME xdriver=foo | set default X driver (auto, vesa , via, vmware, ...) +xdriver=$(read_cmdline_var "xdriver" "") + +# DOCUMENTME xres=bar | set default X resolution (1024x768, 800x600, 640x480, ...) +xres=$(read_cmdline_var "xres" "") + +XORG_CFG_APPEND="" +if [ "${xdriver}" != "" ]; then + XORG_CFG_APPEND="${XORG_CFG_APPEND} --xdriver=${xdriver}" +fi + +if [ "${xres}" != "" ]; then + XORG_CFG_APPEND="${XORG_CFG_APPEND} --xres=${xres}" +fi + +if [ ! -f /etc/X11/xorg.conf ]; then + # generate xorg.conf + log_begin_msg "Generating xorg.conf" + configurexorg --verbose --newsettings ${XORG_CFG_APPEND} --outputfile=/etc/X11/xorg.conf 2>> /tmp/initramfs.debug + log_end_msg $? +else + log_begin_msg "xorg.conf exists, no overwrite" + log_end_msg $? +fi + + +# DOCUMENTME startx=X | set default X session (R=remote L=local N=none, F=freenx, S=sshX) +startx=$TCOS_XORG_TYPE + +if [ $(cat /conf/mysettings.conf | wc -l) -gt 1 ] ;then + startx_type=$(grep ^xsession /conf/mysettings.conf | awk -F "=" '{print $2}' | sed s/'"'/''/g ) + case $type in + XDMCP) + startx=R + ;; + local) + startx=L + ;; + sshX) + startx=S + ;; + FreeNX) + startx=F + ;; + rDesktop) + startx=W + ;; + esac +fi + + +# always overwrite with cmdline +startx=$(read_cmdline_var "startx" "${startx}") + + +if [ "$startx" = "L" ] ; then + ln -s /sbin/startlocalx /sbin/startx + startlocalx & +elif [ "$startx" = "R" ] ; then + ln -s /sbin/startremotex /sbin/startx + startremotex & +elif [ "$startx" = "F" ] ; then + ln -s /sbin/startnx /sbin/startx + startnx & +elif [ "$startx" = "S" ] ; then + ln -s /sbin/startsshx /sbin/startx + startsshx & +elif [ "$startx" = "W" ] ; then + ln -s /sbin/startrdesktop /sbin/startx + startrdesktop & +fi + + +exit 0 diff --git a/scripts/tcos-bottom/35services b/scripts/tcos-bottom/35services new file mode 100755 index 0000000..1eb61d1 --- /dev/null +++ b/scripts/tcos-bottom/35services @@ -0,0 +1,52 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +# if break=inittcos STOP here +maybe_break services + + + +if [ "$(which dropbear)" ] ; then + # need read from /dev/urandom not /dev/random + # http://www.nomis52.net/?section=projects§2=netgear&page=dropbear + # ugly hack or recompile with #define DROPBEAR_RANDOM_DEV "/dev/urandom" + mv /dev/random /dev/random.old + ln -s /dev/urandom /dev/random + + _log "INITTCOS starting dropbear ssh daemon" + log_begin_msg "Starting dropbear SSH daemon" + ln -s /var/run/dropbear /etc/dropbear/superwise >> /tmp/initramfs.debug 2>&1 + ln -s /var/log/dropbear /etc/dropbear/log/main >> /tmp/initramfs.debug 2>&1 + ln -s /var/run/dropbear.log /etc/dropbear/log/superwise >> /tmp/initramfs.debug 2>&1 + dropbear -p 22 -E -d /etc/dropbear/dropbear_dss_host_key -r /etc/dropbear/dropbear_rsa_host_key 2> /tmp/sshd.log + log_end_msg $? + + rm -f /dev/random + mv /dev/random.old /dev/random + + +else + _log "INITTCOS not starting dropbear ssh server" +fi + + +if [ "$(which inetd)" ] && [ -e /etc/inetd.conf ] ; then + _log "INITTCOS starting inetd daemon" + log_begin_msg "Starting inetd" + inetd + log_end_msg $? +else + _log "INITTCOS not starting inetd" +fi + +exit 0 diff --git a/scripts/tcos-bottom/40initsound b/scripts/tcos-bottom/40initsound new file mode 100755 index 0000000..bce1879 --- /dev/null +++ b/scripts/tcos-bottom/40initsound @@ -0,0 +1,101 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +. /bin/set-limits + +# if break=initsound STOP here +maybe_break initsound + +TCOS_DISABLE_SOUND=$(read_cmdline_var "nosound" "0") + +if [ "${TCOS_SOUND}" = "0" -o "${TCOS_DISABLE_SOUND}" = "1" ]; then + log_begin_msg "Sound disabled" + log_end_msg 1 + exit 0 +fi + + +# check if soundcard is avalaible +if [ ! -e /proc/asound ] && [ ! -e /dev/dsp ] ; then + _log "INITSOUND /proc/asound and /dev/dsp don't exists, need other kernel modules!!!" + log_failure_msg "No soundcard found" + log_end_msg 1 + exit 0 +fi + +# DOCUMENTME volume=XX% | set master and pcm volume levels to value passed (0%-100% or integer from 1 to 31) +TCOS_VOLUME=$(read_cmdline_var "volume" "${TCOS_VOLUME}") + +if [ -e /dev/dsp ] && [ ! -e /proc/asound ]; then + export TCOS_SOUND_OSS=1 + echo "TCOS_SOUND_OSS=1" >> /conf/tcos.conf + + log_begin_msg "OSS detected, try to search another sound device with ALSA support" + log_end_msg 1 + exit 0 +fi + +if [ -n "$TCOS_PULSEAUDIO" ]; then + log_begin_msg "Init sound server (PulseAudio)" + _log "INITSOUND starting pulseaudio" + startpulseaudio 2> /var/log/pulseaudio.log & + log_end_msg $? +fi + +TCOS_VOLUME_MIC=75 + +# setting volumes, set after sound server initialization +log_begin_msg "Setting audio levels to ${TCOS_VOLUME}%" + _log "INITSOUND Setting volume to ${TCOS_VOLUME}" + tmixer -c 0 sset 'Front' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Front' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'PCM' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'PCM' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Mono' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Mono' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Front' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Front' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Digital' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Master Digital' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic' ${TCOS_VOLUME_MIC} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Front Mic' ${TCOS_VOLUME_MIC} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Rear Mic' ${TCOS_VOLUME_MIC} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Front Mic' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Rear Mic' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic Boost (+20dB)' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic Boost' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Rear Mic Boost' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Front Mic Boost' off >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic Boost (+20dB)' 0% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Mic Boost' 0% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Rear Mic Boost' 0% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Front Mic Boost' 0% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Headphone' ${TCOS_VOLUME} >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Headphone' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Speaker' on >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture' cap >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,0' cap >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,1' cap >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,2' cap >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,3' cap >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture' 90% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,0' 90% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,1' 90% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,2' 90% >> /tmp/initramfs.debug 2>&1 + tmixer -c 0 sset 'Capture,3' 90% >> /tmp/initramfs.debug 2>&1 +log_end_msg 0 + +exit 0 diff --git a/scripts/tcos-bottom/55checksumoff b/scripts/tcos-bottom/55checksumoff new file mode 100755 index 0000000..cb41a61 --- /dev/null +++ b/scripts/tcos-bottom/55checksumoff @@ -0,0 +1,34 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf +. /scripts/functions +. /conf/tcos-run-functions + +rxtxoff=$(read_cmdline_var "rxtxoff" "0") + +if [ ${rxtxoff} = 1 ]; then + # get list of network interfaces + TCOS_NET_DEVS=$(ls /sys/class/net/|grep -v -e lo -e sit0 -e wmaster -e vmnet -e pan) + + # search for network interfaces with link ok status + for dev in $TCOS_NET_DEVS; do + # have link ??? + if [ -e /sys/class/net/$dev/carrier ] && \ + [ "$(cat /sys/class/net/$dev/carrier 2>/dev/null)" = 1 ] && \ + [ "$(/sbin/ethtool $dev| grep -c "Wake-on: g")" = "1" ] ; then + _log "55checksumoff disabling rx, tx protocol checksum on ifaces..." + /sbin/ethtool -K $dev rx off tx off >> /tmp/initramfs.debug 2>&1 + fi + done +fi + + + +exit 0 + diff --git a/scripts/tcos-bottom/55mount_listener b/scripts/tcos-bottom/55mount_listener new file mode 100755 index 0000000..779c39c --- /dev/null +++ b/scripts/tcos-bottom/55mount_listener @@ -0,0 +1,37 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n +. /conf/tcos-run-functions + + +# enable tcos-udev.sh events +mkdir -p /var/run/ +touch /var/run/tcos-udev.run + + +nodevices=$(read_cmdline_var "nodevices" "0") +if [ "${nodevices}" = "1" ]; then + _log "Devices disabled from cmdline" + exit 0 +fi + +if [ "$(configctl.sh --get TCOS_DISABLE_USB)" = "1" ] || \ + [ "$(configctl.sh --get TCOS_DISABLE_IDE)" = "1" ]; then + _log "Devices disabled" + exit 0 +fi + +if [ -x /usr/sbin/listener-daemon.sh ]; then + /usr/sbin/listener-daemon.sh > /var/log/listener-daemon.log 2>&1 & +fi + + +if [ -x /usr/sbin/cdrom-mount ]; then + /usr/sbin/cdrom-mount > /var/log/cdrom-mount.log 2>&1 & +fi + +exit 0 diff --git a/scripts/tcos-bottom/56tcosxmlrpc b/scripts/tcos-bottom/56tcosxmlrpc new file mode 100755 index 0000000..100acd1 --- /dev/null +++ b/scripts/tcos-bottom/56tcosxmlrpc @@ -0,0 +1,33 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + + +# if break=xmlrpc STOP here +maybe_break xmlrpc + +# DOCUMENTME noxmlrpc | disable tcosxmlrpc daemon +noxmlrpc=$(read_cmdline_var "noxmlrpc" "0") +if [ ${noxmlrpc} = 1 ]; then + _log "START-XMLR-PC xmlrpc disabled from cmdline" + exit 0 +fi + + +# start daemon +log_begin_msg "Starting tcosxmlrpc server" + _log "START-XMLRCP starting startxmlrpc...." + startxmlrpc & +log_end_msg $? + + + +exit 0 + diff --git a/scripts/tcos-bottom/57devices b/scripts/tcos-bottom/57devices new file mode 100755 index 0000000..a577e63 --- /dev/null +++ b/scripts/tcos-bottom/57devices @@ -0,0 +1,74 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +. /bin/set-limits + +# rewrite /etc/fstab from NFS +if [ "$(cat /tmp/less_ram)" != "0" ]; then + export NO_UDEV=1 + /scripts/tcos-top/50fstab + unset NO_UDEV +fi + +nodevices=$(read_cmdline_var "nodevices" "0") +if [ ${nodevices} = 1 ]; then + _log "Devices disabled from cmdline" + exit 0 +fi + + +if [ ${TCOS_USB} ]; then + # load floppy from /lib/extramodules + [ -e /lib/extramodules/ide-floppy.ko ] && insmod /lib/extramodules/ide-floppy.ko & + [ -e /lib/extramodules/floppy.ko ] && insmod /lib/extramodules/floppy.ko & + + MODULES="scsi_mod sd_mod sr_mod isofs vfat usbcore ehci-hcd ohci-hcd uhci-hcd usb-storage" + log_begin_msg "Loading usb modules" + for mod in ${MODULES}; do + _log "INITTCOS Loading module ${mod}" + modprobe -q $mod >> /tmp/initramfs.debug 2>&1 & + done + log_end_msg 0 +else + _log "INITTCOS usb support disabled" +fi + + + +# if break=ltspfs STOP here +maybe_break ltspfs + +# DOCUMENTME noltspfs | disable ltspfs daemon +noltspfs=$(read_cmdline_var "noltspfs" "0") +if [ ${noltspfs} = 1 ]; then + _log "LTSPFS ltspfs disabled from cmdline" + exit 0 +fi + +################################################### +# http://wiki.ltsp.org/twiki/bin/view/Ltsp/LtspFS # +################################################### + +if [ "$TCOS_REMOTEFS" = "ltspfs" ]; then + if [ -x "$(which ltspfsd)" ] ; then + # start ltspfsd daemon + log_begin_msg "Start ltspfs daemon" + _log "LTSPFS Starting ltspfs daemon" + ltspfsd + log_end_msg $? + fi +fi # end of TCOS_REMOTEFS=ltspfs + + + +exit 0 diff --git a/scripts/tcos-bottom/60installer b/scripts/tcos-bottom/60installer new file mode 100755 index 0000000..e5fa1e9 --- /dev/null +++ b/scripts/tcos-bottom/60installer @@ -0,0 +1,46 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +. /conf/tcos-run-functions + + +# try to exec installer +INSTALLER=$(read_cmdline_var "installer" "0") + +# try to exec installer-update +INSTALLER_UPDATE=$(read_cmdline_var "installer-update" "0") + +if [ "${INSTALLER}" = "1" ]; then + chvt 1 + # launch installer + #clear + /sbin/installer.sh + echo "" + echo "Installer done. You can reboot now or connect server." + echo "" + echo " for reboot/poweroff exec => reboot poweroff" + echo " for connect to server exec => startremotex" + echo "" + sh +elif [ "${INSTALLER_UPDATE}" = "1" ]; then + chvt 1 + # launch installer + #clear + /sbin/installer.sh --update + echo "" + echo "Installer update done. You can reboot now or connect server." + echo "" + echo " for reboot/poweroff exec => reboot poweroff" + echo " for connect to server exec => startremotex" + echo "" +fi + + + +exit 0 diff --git a/scripts/tcos-bottom/70wakeonlan b/scripts/tcos-bottom/70wakeonlan new file mode 100755 index 0000000..d562864 --- /dev/null +++ b/scripts/tcos-bottom/70wakeonlan @@ -0,0 +1,37 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf +. /scripts/functions +. /conf/tcos-run-functions + +if [ -z "$TCOS_WAKEONLAN" ]; then + exit 0 +fi + + +# get list of network interfaces +TCOS_NET_DEVS=$(ls /sys/class/net/|grep -v -e lo -e sit0 -e wmaster -e vmnet -e pan) + +# search for network interfaces with link ok status +for dev in $TCOS_NET_DEVS; do + # have link ??? + if [ -e /sys/class/net/$dev/carrier ] && \ + [ "$(cat /sys/class/net/$dev/carrier 2>/dev/null)" = 1 ] && \ + [ "$(/sbin/ethtool $dev| grep -c "Wake-on: g")" = "1" ] ; then + _log "70WAKEONLAN Enabling WOL in $dev iface..." + [ -x /sbin/ethtool ] && \ + /sbin/ethtool -s $dev wol g >> /tmp/initramfs.debug 2>&1 + fi +done + + + + +exit 0 + diff --git a/scripts/tcos-bottom/72ntpdate b/scripts/tcos-bottom/72ntpdate new file mode 100755 index 0000000..aa54b8f --- /dev/null +++ b/scripts/tcos-bottom/72ntpdate @@ -0,0 +1,24 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf + +if [ -z "$TCOS_NTPDATE" ]; then + exit 0 +fi + + +/usr/bin/ntpdate $TCOS_NTPDATE_SERVER >> /tmp/initramfs.debug 2>&1 +if [ $? = 0 ]; then + # save clock in BIOS + hwclock --systohc >> /tmp/initramfs.debug 2>&1 +fi + + +exit 0 + diff --git a/scripts/tcos-bottom/75print b/scripts/tcos-bottom/75print new file mode 100755 index 0000000..7e20685 --- /dev/null +++ b/scripts/tcos-bottom/75print @@ -0,0 +1,35 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf +. /scripts/functions +. /conf/tcos-run-functions + +. /bin/set-limits + +if [ $TCOS_PRINTER ]; then + + LP="" + [ -e /dev/lp0 ] && LP=/dev/lp0 + [ -e /dev/lp1 ] && LP=/dev/lp1 + [ -e /dev/usblp0 ] && LP=/dev/usblp0 + [ -e /dev/usb/lp0 ] && LP=/dev/usb/lp0 + + if [ "${LP}" = "" ]; then exit 0; fi + + if [ -e /usr/bin/p910nd ]; then + + mkdir -p /var/lock/p910nd + /usr/bin/p910nd -f $LP > /var/log/p910nd.log 2>&1 & + + fi + + +fi + +exit 0 diff --git a/scripts/tcos-bottom/78cpufreq b/scripts/tcos-bottom/78cpufreq new file mode 100755 index 0000000..36fa135 --- /dev/null +++ b/scripts/tcos-bottom/78cpufreq @@ -0,0 +1,22 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf + + +if [ "$TCOS_CPUFREQ" = "1" ]; then + + modprobe acpi-cpufreq + modprobe cpufreq_powersave + if [ -e /sys/devices/system/cpu/cpu0/cpufreq ]; then + echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + fi + +fi + +exit 0 diff --git a/scripts/tcos-bottom/80shell b/scripts/tcos-bottom/80shell new file mode 100755 index 0000000..afd3a0d --- /dev/null +++ b/scripts/tcos-bottom/80shell @@ -0,0 +1,60 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /conf/tcos.conf +. /scripts/functions +. /conf/tcos-run-functions + + +# kill bootchart +if grep -q bootchartd /proc/cmdline ; then + [ -x /sbin/tcos-bootchartd ] && /sbin/tcos-bootchartd stop +fi + +TCOS_TTY=$(read_cmdline_var "ttys" "${TCOS_TTY}") + +export PS1="($(whoami)@$(hostname)) # " + +grep -q " startx=N " /proc/cmdline && chvt 1 + +# empty memory cache +# from http://linux-mm.org/Drop_Caches +sync +echo 3 > /proc/sys/vm/drop_caches + +# no clear +#clear + + +while [ ${TCOS_TTY} -ge 1 ]; do + if [ ${TCOS_TTY} = 1 ] ; then + if [ "${TCOS_TTY1_PROTECTED}" = "1" ]; then + rungetty tty${TCOS_TTY} + else + echo "" + echo "" + echo "Press enter to activate this console..." + read enter + sh + fi + else + rungetty tty${TCOS_TTY} & + fi + + TCOS_TTY=$((TCOS_TTY -1)) +done + + + + + +while [ 1 ]; do + sh +done + +exit 0 diff --git a/scripts/tcos-premount/15uselocal b/scripts/tcos-premount/15uselocal new file mode 100644 index 0000000..8d766b5 --- /dev/null +++ b/scripts/tcos-premount/15uselocal @@ -0,0 +1,102 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions + +# if break=uselocal STOP here +maybe_break uselocal + + +. /conf/tcos.conf +. /conf/tcos-run-functions + +mkdir -p /mnt/tmp >/dev/null 2>&1 + +# DOCUMENTME uselocal | enable use of local disks +uselocal=$(read_cmdline_var "uselocal" "0") +if [ ${uselocal} = 0 ]; then + _log "USELOCAL uselocal not enabled from cmdline" + exit 0 +fi + + +# try to mount any part in /mnt/tmp +######################################### +ext3_parts_num=$(grep ^/dev /etc/fstab|grep -c ext3) +ext3_parts_devs=$(grep ^/dev /etc/fstab|grep ext3 | awk '{print $1}') + +vfat_parts_num=$(grep ^/dev /etc/fstab|grep -c vfat) +vfat_parts_devs=$(grep ^/dev /etc/fstab|grep vfat | awk '{print $1}') + +need_free_space=131072 +######################################### + + + + +if [ ${ext3_parts_num} != 0 ]; then +log_begin_msg "Try to use some ext3 parts" + for ext3 in ${ext3_parts_devs}; do + mount -t ext3 -o rw ${ext3} /mnt/tmp >> /tmp/initramfs.debug 2>&1 + sync + sleep 1 + if [ $(grep -c ${ext3} /proc/mounts) != 1 ]; then + _log "USELOCAL ${ext3} not mounted, next..." + # not mounted + else + _log "USELOCAL ${ext3} mounted, check free space" + free_space=$(df ${ext3}| grep ^/dev| awk '{print $4}') + # check if free space > 64 Mb + if [ ${free_space} -ge ${need_free_space} ] ; then + _log "USELOCAL have more than ${need_free_space} in ${ext3}" + log_end_msg 0 + exit 0 + else + _log "USELOCAL no free space in ${ext3}" + umount ${ext3} + fi + + fi + done +# if here no ext3 part +log_end_msg 1 +fi + + +if [ ${vfat_parts_num} != 0 ]; then +log_begin_msg "Try to use some vfat parts" + for vfat in ${vfat_parts_devs}; do + mount -t vfat -o rw ${vfat} /mnt/tmp >> /tmp/initramfs.debug 2>&1 + sync + sleep 1 + if [ $(grep -c ${vfat} /proc/mounts) != 1 ]; then + _log "USELOCAL ${vfat} not mounted, next..." + # not mounted + else + _log "USELOCAL ${vfat} mounted, check free space" + free_space=$(df ${vfat}| grep ^/dev| awk '{print $4}') + # check if free space > 64 Mb + if [ ${free_space} -ge ${need_free_space} ] ; then + _log "USELOCAL have more than ${need_free_space} in ${vfat}" + log_end_msg 0 + exit 0 + else + _log "USELOCAL no free space in ${vfat}" + umount ${vfat} + fi + + fi + done +# if here no vfat part +log_end_msg 1 +fi + +log_begin_msg "NO parts avalaible (ext3 or fat)" +log_end_msg 0 + +exit 0 diff --git a/scripts/tcos-premount/20hdd b/scripts/tcos-premount/20hdd new file mode 100755 index 0000000..0503de2 --- /dev/null +++ b/scripts/tcos-premount/20hdd @@ -0,0 +1,54 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +# if break=sqmount STOP here +maybe_break hdd + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + + + +# check if we are booting from HD / USB +_INITRD=$(read_cmdline_var "initrd" "") +if [ "$_INITRD" = "initrd.gz" ]; then + # booting from hdd, use usr.squashfs from HDD if exists + mkdir -p /mnt/tmp + + for part in $(grep -e ext3 -e vfat /etc/fstab| awk '{print $1":"$3}'); do + device=$(echo $part | awk -F":" '{print $1}') + fs=$(echo $part | awk -F":" '{print $2}') + mount -t${fs} ${device} /mnt/tmp + + if [ -f /mnt/tmp/usr.squashfs ]; then + USR_SQUASH=/mnt/tmp/usr.squashfs + _log "SQMOUNT found usr.squashfs in $device " + break + elif [ -f /mnt/tmp/usr-$(uname -r).squashfs ]; then + USR_SQUASH=/mnt/tmp/usr-$(uname -r).squashfs + _log "SQMOUNT found usr-$(uname -r).squashfs in $device " + break + else + umount /mnt/tmp + fi + done +fi + + + + + +############################################## + + +exit 0 + diff --git a/scripts/tcos-premount/20swapon b/scripts/tcos-premount/20swapon new file mode 100755 index 0000000..96004b3 --- /dev/null +++ b/scripts/tcos-premount/20swapon @@ -0,0 +1,112 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +# if break=swapon STOP here +maybe_break swapon + +. /conf/tcos.conf +. /conf/tcos-run-functions + + +# DOCUMENTME noswap | disable swap file creation (swap partition is used always, if found) +noswap=$(read_cmdline_var "noswap" "0") +if [ ${noswap} = 1 ]; then + _log "SWAPON swap disabled from cmdline" + exit 0 +fi + + +############ VARS ############### +# need 64 mb of free space (in kb) +need_free_space=65536 + +mem_max=$(grep MemTotal /proc/meminfo | awk '{print $2}') +mem_max_dd=901120 + +if [ ${need_free_space} -ge ${mem_max} ] ; then + # mem_max - 10 Mb + need_free_space=$(($mem_max-10240)) +fi + +if [ ${need_free_space} -ge ${mem_max_dd} ];then + need_free_space=${mem_max_dd} +fi + +################################# + +swap_parts_num=$(grep ^/dev /etc/fstab|grep -c swap) +swap_parts_devs=$(grep ^/dev /etc/fstab|grep swap | awk '{print $1}') + +ext3_parts_num=$(grep ^/dev /etc/fstab|grep -c ext3) +ext3_parts_devs=$(grep ^/dev /etc/fstab|grep ext3 | awk '{print $1}') + +fat32_parts_num=$(grep ^/dev /etc/fstab|grep -c vfat) +fat32_parts_devs=$(grep ^/dev /etc/fstab|grep vfat | awk '{print $1}') + +######### FUNCTIONS ########## + +check_if_swaps() { + # exit if swap is mounted + if [ $(grep -c -v ^Filename /proc/swaps ) != 0 ]; then + _log "SWAPON have swap !!!" + log_end_msg 0 + exit 0 + fi +} + +mount_exits_swap() { + for dev in $1 ; do + swapon ${dev} + done +} + + +swap_mnt_file=/mnt/tmp/swap.file + +# check if /mnt/tmp is mounted and create swap file into /mnt/tmp +create_swap () { + if [ $(grep -c /mnt/tmp /proc/mounts) -gt 0 ]; then + # have /mnt/tmp !!!! + # check if file exists + if [ -f ${swap_mnt_file} ]; then + # file exists, mount + swapon ${swap_mnt_file} >> /tmp/initramfs.debug 2>&1 + else + # file not exists, create it + dd if=/dev/zero of=${swap_mnt_file} bs=${need_free_space}k count=1 >> /tmp/initramfs.debug 2>&1 + mkswap ${swap_mnt_file} >> /tmp/initramfs.debug 2>&1 + swapon ${swap_mnt_file} >> /tmp/initramfs.debug 2>&1 + fi + fi + +} + + + +############# begin code ############ + +log_begin_msg "Active swap partitions" + +# first we search for a swap mounted and exit + _log "SWAPON checking swap mounted partitions" + check_if_swaps + +# no swap partition, create swap file in /mnt/tmp (if mounted) + create_swap + + + + +# if here we have no swap +_log "SWAP no swap avalaible" +log_end_msg 1 + + +exit 0 diff --git a/scripts/tcos-premount/25nbd_filesystem b/scripts/tcos-premount/25nbd_filesystem new file mode 100644 index 0000000..c2608b6 --- /dev/null +++ b/scripts/tcos-premount/25nbd_filesystem @@ -0,0 +1,44 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions + +# if break=nbd_filesystem STOP here +maybe_break nbd_filesystem + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + +TCOS_ENABLE_NBD=$(read_cmdline_var "nbd" "0") + +if [ "$TCOS_ENABLE_NBD" != "0" ]; then + + log_begin_msg "Mounting remote squashfs with NBD" + + NBD_PORT=$(read_cmdline_var "nbdport" "2000") + + # load 1 nbd devices + modprobe nbd nbds_max=1 + + # wait for device + while [ ! -e /dev/nbd0 ]; do + sleep 1 + done + + nbd-client tcos-server $NBD_PORT /dev/nbd0 + sleep 1 + + mount /dev/nbd0 /usr + + log_end_msg $? + +fi + +exit 0 diff --git a/scripts/tcos-premount/30rootfs b/scripts/tcos-premount/30rootfs new file mode 100755 index 0000000..7ae3601 --- /dev/null +++ b/scripts/tcos-premount/30rootfs @@ -0,0 +1,135 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + +. /scripts/functions +# if break=sqmount STOP here +maybe_break rootfs + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + + +############################################## +TCOS_ENABLE_USENFS=$(read_cmdline_var "usenfs" "${TCOS_USENFS}") + +if [ "$TCOS_ENABLE_USENFS" != "1" ]; then + _log "ROOTFS no NFS support, exiting" + exit 0 +fi + + + +rootfs_file=/mnt/tmp/rootfs-$(uname -r).squashfs +mkdir -p /mnt/tmp /target + +if [ "${TCOS_USENFS}" = "nfs" ]; then + value=0 + log_begin_msg "Mounting NFS /mnt/tmp" + MOPTS="nolock,ro" + mount -n -t ramfs none /target + nfsmount -o ${MOPTS} $(read_server "nfs-server"):${nfs_dir} /mnt/tmp 2>&1 > /dev/null ||\ + nfsmount -o ${MOPTS} $(read_server "nfs-server"):${nfs_dir} /mnt/tmp 2>&1 > /dev/null ||\ + value=1 + log_end_msg $value + +fi + + +############################################## +TCOS_ENABLE_ROOTFS=$(read_cmdline_var "rootfs" "${TCOS_ROOTFS}") + +if [ "$TCOS_ENABLE_ROOTFS" != "1" ]; then + _log "ROOTFS no rootfs support, exiting" + exit 0 +fi + + +if [ ! -f ${rootfs_file} ]; then + _log "ROOTFS is __NOT__ in /mnt/tmp" + log_begin_msg "Downloading rootfs" + download_file /tcos/rootfs-$(uname -r).squashfs ${rootfs_file} + log_end_msg $? +else + _log "ROOTFS is in /mnt/tmp" + log_begin_msg "Using NFS rootfs" + sync + log_end_msg $? +fi + +# Mount squashfs filesystems +_log "ROOTFS mounting rootfs in /target" +log_begin_msg "Mounting rootfs filesystem" + mount -r -o loop -t squashfs ${rootfs_file} /target >> /tmp/initramfs.debug 2>&1 +log_end_msg $? + +_log "ROOTFS remounting /target as RW" +log_begin_msg "Remounting /target in rw mode" + mkdir -p /.target + mount_unionfs /mnt/rootram /.target /target +log_end_msg $? + +_log "ROOTFS copy some things on /target" + +# copy some things +rm -rf /target/conf/ && cp -ra /conf/ /target/ +rm -rf /target/scripts/ && cp -ra /scripts/ /target/ +mkdir -p /target/tmp && cp -ra /tmp/* /target/tmp + +#mkdir -p /var/lib/dhcp/ +#cp /var/lib/dhcp/dhclient.leases /target/var/lib/dhcp/dhclient.leases +cat /tmp/net.data > /root/tmp/net.data + +cp /etc/hostname /target/etc/hostname +cp /etc/resolv.conf /target/etc/resolv.conf +cp /etc/fstab /target/etc/fstab +cp /etc/mtab /target/etc/mtab + + + +_log "ROOTFS creating init_rootfs script" + +# make a /sbin/init_rootfs +cat << EOF >> /target/init2 +#!/bin/sh + +echo "Loading second stage, please wait..." +. /conf/initramfs.conf +. /scripts/functions + +run_scripts /scripts/tcos-bottom + +EOF + +chmod 755 /target/init2 + +_log "ROOTFS pivot_root /target" + +cd /target +pivot_root . ../ + +_log "ROOTFS mounting /dev /proc and /sys into /target" +# mount -o bind some things +log_begin_msg "Moving /dev /proc and /sys" + mkdir -p /target/dev /target/proc /target/sys /target/mnt/tmp + mount -n -o move /dev /target/dev + mount -n -o move /sys /target/sys + mount -n -o move /mnt/tmp /target/mnt/tmp + mount -n -o move /proc /target/proc +log_end_msg $? + + +# enter to jail +exec chroot . /scripts/init2 <dev/console >dev/console 2>&1 + +_log "ROOTFS run-init /script" +#exec run-init /target/ /scripts/init2 "$@" </target/dev/console >/target/dev/console + + +exit 0 diff --git a/scripts/tcos-premount/36squashfs-methods b/scripts/tcos-premount/36squashfs-methods new file mode 100755 index 0000000..88ae859 --- /dev/null +++ b/scripts/tcos-premount/36squashfs-methods @@ -0,0 +1,75 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +quiet=n + +# if break=nfs-squashfs STOP here +maybe_break nfs-squashfs + + + +# if use NFS try to mount: +# +# SERVER_IP:/var/lib/tcos/fs-$(uname -r) +# + + + + + +# SQUASHFS NFS ? +SQUASHFS_MODE=$(read_cmdline_var "squashfs" "") + + +if [ "${SQUASHFS_MODE}" = "nfs" ]; then + + MNTOPT="ro,nolock,rsize=2048,wsize=2048,retrans=10" + NFS_RO=/mnt/nfs-squashfs + mkdir -p $NFS_RO + + log_begin_msg "Trying to mount NFS-SQUAHSFS" + nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/tftp ${NFS_RO} 2>/dev/null + + + # try again + if [ $? -ne 0 ]; then + log_begin_msg "Second retry to mount NFS-SQUAHFS" + nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/tftp ${NFS_RO} 2> /dev/null + fi + + if [ $? -ne 0 ]; then + panic "Unable to mount NFS, check NFS service in server and ${TCOS_VAR}/tftp dir" + fi + + log_end_msg 0 + + # copy squashfs file in /mnt/tmp to not download + log_begin_msg "Copy SQUASHFS to /mnt/tmp" + cp ${NFS_RO}/usr-$(uname -r).squashfs /mnt/tmp/usr-$(uname -r).squashfs + log_end_msg 0 + + umount ${NFS_RO} + +elif [ "${SQUASHFS_MODE}" = "http" ]; then + + + log_begin_msg "Downloading SQUASHFS using HTTP" + wget http://$(read_server "nfs-server"):8080/usr-$(uname -r).squashfs -O- > /mnt/tmp/usr-$(uname -r).squashfs + log_end_msg 0 + + +fi # end of SQUASHFS_MODE + + + + + +exit 0 diff --git a/scripts/tcos-premount/40tftp b/scripts/tcos-premount/40tftp new file mode 100755 index 0000000..a2c3084 --- /dev/null +++ b/scripts/tcos-premount/40tftp @@ -0,0 +1,74 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + + +. /scripts/functions +# if break=tftp STOP here +maybe_break tftp + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + + +if [ -e /usr/bin/Xorg ]; then + # we have a mounted /usr with other method + exit 0 +fi + + + + +############################################### +if [ ! -e /mnt/tmp/usr-$(uname -r).squashfs ] && [ ! -e /mnt/tmp/usr.squashfs ]; then + # download usr.squashfs from tftp server + + log_begin_msg "Downloading usr.squashfs from $(read_server "tftp-server")" + _log "SQMOUNT downloading squashfs" + value=0 + download_file /tcos/usr-$(uname -r).squashfs /mnt/tmp/usr-$(uname -r).squashfs || value=1 + #sync + #sleep 1 + log_end_msg $value + + + if [ "$(if_is_zero /mnt/tmp/usr-$(uname -r).squashfs)" = "0" ]; then + panic "Error downloading extra data from server $(read_server "tftp-server")" + fi +#else +# log_begin_msg "usr-$(uname -r).squashfs not downloaded" +# sync +# log_end_msg $? +fi + +############################################## + + +# DOCUMENTME allmodules | download with tftp allmodules.squashfs to test what modules need thin client +TCOS_ALL_MODULES_CMD=$(read_cmdline_var "allmodules" "0") + +if [ "$TCOS_ALL_MODULES_CMD" = "1" ] || [ ! -z $TCOS_ALL_MODULES_DOWNLOAD ]; then + + if [ ! -e /mnt/tmp/allmodules-$(uname -r).squashfs ] && [ ! -e /mnt/tmp/allmodules.squashfs ]; then + + _log "SQMOUNT Downloading allmodules-$(uname -r).squashfs" + log_begin_msg "Downloading all kernel modules: allmodules-$(uname -r).squashfs" + download_file /tcos/allmodules-$(uname -r).squashfs /mnt/tmp/allmodules-$(uname -r).squashfs + sync + if [ "$(if_is_zero /mnt/tmp/allmodules-$(uname -r).squashfs)" = "0" ]; then + echo "Error downloading allmodules" + log_end_msg 1 + exit 0 + fi + log_end_msg 0 + fi + +fi + + +exit 0 + diff --git a/scripts/tcos-premount/45sqmount b/scripts/tcos-premount/45sqmount new file mode 100755 index 0000000..0cb1dbe --- /dev/null +++ b/scripts/tcos-premount/45sqmount @@ -0,0 +1,83 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +# if break=sqmount STOP here +maybe_break sqmount + + +. /conf/tcos.conf +. /conf/tcos-run-functions + +TCOS_SQUASHFS=$(read_cmdline_var "squashfs" "${TCOS_SQUASHFS}") + +if [ ! -z $TCOS_DISABLE_SQUASHFS ]; then + _log "SQMOUNT no squashfs support, exiting" + # no squashfs support defined + exit 0 +fi + + +USR_SQUASH=/mnt/tmp/usr-$(uname -r).squashfs +MOD_SQUASH=/mnt/tmp/allmodules-$(uname -r).squashfs + +# check if have in /mnt/tmp without version +if [ -e /mnt/tmp/usr.squashfs ]; then + USR_SQUASH=/mnt/tmp/usr.squashfs +fi + +if [ -e /mnt/tmp/allmodules.squashfs ]; then + MOD_SQUASH=/mnt/tmp/allmodules.squashfs +fi + + + + + +############################################## + + +if [ ! -e /dev/loop0 ] && [ ! -e /dev/loop1 ]; then + for NUM in $(seq 0 8) ; do + mknod /dev/loop$NUM b 7 $NUM + done +fi + + + +# Mount squashfs filesystems +log_begin_msg "Mounting usr filesystem" + mount -r -o loop -t squashfs ${USR_SQUASH} /usr >> /tmp/initramfs.debug 2>&1 + # check if squashfs mount give an error + if [ $? != 0 ]; then + panic "Error mounting usr.squashfs check squashfs module or bugs" + else + log_end_msg 0 +fi + + + +############################################### + + + +# DOCUMENTME allmodules | download with tftp allmodules.squashfs to test what modules need thin client +TCOS_ALL_MODULES_CMD=$(read_cmdline_var "allmodules" "0") + +if [ "$TCOS_ALL_MODULES_CMD" = "1" ] || [ ! -z $TCOS_ALL_MODULES_DOWNLOAD ]; then + if [ -f ${MOD_SQUASH} ]; then + log_begin_msg "Mounting allmodules.squashfs" + mount -r -o loop -t squashfs ${MOD_SQUASH} /lib/modules/$(uname -r)/ >> /tmp/initramfs.debug 2>&1 + log_end_msg $? + fi +fi + + +exit 0 + diff --git a/scripts/tcos-premount/50unionfs b/scripts/tcos-premount/50unionfs new file mode 100755 index 0000000..d0ea5a5 --- /dev/null +++ b/scripts/tcos-premount/50unionfs @@ -0,0 +1,46 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +# if break=unionfs STOP here +maybe_break unionfs + + +. /conf/tcos.conf +. /conf/tcos-run-functions + + +# Mount squashfs over unionfs +log_begin_msg "Mounting UNIONFS usr filesystem" + if [ ! -d /usr/share ]; then + panic "Error mounting usr.squashfs check squashfs module or bugs" + fi + mount_unionfs /mnt/ram /.usr /usr +log_end_msg $? + + + +############################################### + + + +# DOCUMENTME allmodules | download with tftp allmodules.squashfs to test what modules need thin client +TCOS_ALL_MODULES_CMD=$(read_cmdline_var "allmodules" "0") + +if [ "$TCOS_ALL_MODULES_CMD" = "1" ] || [ ! -z $TCOS_ALL_MODULES_DOWNLOAD ]; then + if [ -d /mnt/.modules/ ]; then + log_begin_msg "Remounting allmodules in RW mode" + mount_unionfs /mnt/.ram-modules /mnt/.modules /lib/modules/$(uname -r) + log_end_msg $? + fi +fi + + +exit 0 + diff --git a/scripts/tcos-top/01busybox b/scripts/tcos-top/01busybox new file mode 100755 index 0000000..5d94043 --- /dev/null +++ b/scripts/tcos-top/01busybox @@ -0,0 +1,90 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + + +# set kernel very silent +if grep -q quiet /proc/cmdline ; then + echo "1 1 1 7" > /proc/sys/kernel/printk + dmesg -n 1 +fi + + +# start syslogd (busybox embeded) +killall syslogd 2>/dev/null +syslogd 2>/dev/null + +if [ $? != 0 ]; then + # create a fuck logger + rm -f /bin/logger + cat << EOF > /bin/logger +#!/bin/sh + +echo "[\$(date +'%d/%m/%y %H:%M:%S')] \$2: \$3" >> /var/log/messages +EOF + chmod +x /bin/logger +fi + + +# hack for ubuntu old udev +while [ 1 ]; do + [ -e /sys/class/net/eth0 ] && break + [ -e /sys/class/net/eth1 ] && break + [ -e /sys/class/net/eth2 ] && break + [ -e /sys/class/net/wlan0 ] && break + [ -e /sys/class/net/wlan1 ] && break + [ -x /sbin/udevtrigger ] && /sbin/udevtrigger + [ -x /sbin/udevplug ] && /sbin/udevplug + [ -x /sbin/udevadm ] && /sbin/udevadm trigger + [ -x /sbin/udevadm ] && /sbin/udevadm settle + if [ ! -e /tmp/waiting_for_net ]; then + echo -n " * Waiting for net device " + fi + touch /tmp/waiting_for_net + echo -n "." + sleep 1 +done +echo "" + +modprobe -q loop >> /tmp/initramfs.debug 2>&1 +modprobe -q squashfs >> /tmp/initramfs.debug 2>&1 + +# network and nfs +modprobe nfs 2>/dev/null +modprobe af_packet 2>/dev/null + +if [ ! -z "$TCOS_DISABLE_IDE" ]; then + # load cdrom and HDD modules + modprobe -q ide_disk >> /tmp/initramfs.debug 2>&1 & + modprobe -q ide_cd >> /tmp/initramfs.debug 2>&1 & +fi + +# from > 2.6.26 we need to load aufs module (unionfs is deprecated) +# TCOS_UNIONFS is generated in hooks-addons/99tcos and saved in /conf/tcos.conf +if [ "$TCOS_UNIONFS" = "aufs" ]; then + _log "BUSYBOX load aufs module" + modprobe -q aufs >> /tmp/initramfs.debug 2>&1 & +else + + if [ "$(read_cmdline_var "aufs" "0")" = "1" ] && [ $(modprobe aufs -q ; echo $?) != 1 ]; then + _log "BUSYBOX loaded aufs module" + modprobe -q aufs >> /tmp/initramfs.debug 2>&1 & + else + _log "BUSYBOX load unionfs module and if fail try aufs" + modprobe unionfs || modprobe aufs >> /tmp/initramfs.debug 2>&1 & + fi + +fi + +grep -q -e aufs -e unionfs /proc/filesystems || modprobe -q -b overlayfs + +exit 0 diff --git a/scripts/tcos-top/02check_ram b/scripts/tcos-top/02check_ram new file mode 100755 index 0000000..1512c7d --- /dev/null +++ b/scripts/tcos-top/02check_ram @@ -0,0 +1,41 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +echo 0 > /tmp/less_ram + +# read MemTotal (in MB) +have_mem=$(awk '/^MemTotal/ {print int($2/1000)}' /proc/meminfo) + +if [ ${have_mem} -lt ${TCOS_MIN_RAM} ]; then + # we have less than TCOS_MIN_RAM + # need to start in NFS mode + echo 1 > /tmp/less_ram +fi + + +# force boot without nfs if booting from disk +FORCE_NO_NFS=$(read_cmdline_var 'nonfs' '0') + +if [ $FORCE_NO_NFS = 1 ]; then + echo 0 > /tmp/less_ram +fi + +# force boot nfs +FORCE_NFS=$(read_cmdline_var 'forcenfs' '0') + +if [ $FORCE_NFS = 1 ]; then + echo 1 > /tmp/less_ram +fi + + +exit 0 diff --git a/scripts/tcos-top/05network b/scripts/tcos-top/05network new file mode 100755 index 0000000..b5097d0 --- /dev/null +++ b/scripts/tcos-top/05network @@ -0,0 +1,274 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n + + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +# if break=sqmount STOP here +maybe_break network + +# localhost +log_begin_msg "Bring up Local loopback device" + ifconfig lo up +log_end_msg $? + +touch /etc/resolv.conf + +#if [ -d /var/lib/dhcp3 ]; then +# # link to work with dhcp-client or dhcp3-client +# ln -s /var/lib/dhcp3 /var/lib/dhcp + +# chown root:dhcp /lib/dhcp3-client 2>/dev/null +# chown 775 /lib/dhcp3-client +# chmod 4744 /lib/dhcp3-client/call-dhclient-script + +# chown root:dhcp /etc/resolv.conf 2>/dev/null +# chmod 644 /etc/resolv.conf +#fi + +# wireless TCOS minihowto +# +# start thin client with something like this: +# +# boot: tcos wifi=1 essid="ESSID" server=xx.xx.xx.xx +# * server is tftpd and XMDCP host +# * ESSID is wireless network + + +if [ $(read_cmdline_var 'wifi' '0') = "1" ]; then + # load kernel modules + log_begin_msg "Loading wireless kernel modules" + modprobe -q arc4 + modprobe -q ecb + modprobe -q mac80211 + modprobe -q ieee80211_crypt + modprobe -q ieee80211 + modprobe -q ieee80211softmac + #modprobe -q rc80211_simple + + for kmod in $TCOS_WIRELESS_MODS; do + if [ "$kmod" = "madwifi" ]; then + #ath-pci ath-hal wlan_tkip wlan_scan_sta ath-hal + modprobe -q ath-pci 2>/dev/null + modprobe -q ath-hal 2>/dev/null + modprobe -q wlan_tkip 2>/dev/null + modprobe -q wlan_scan_sta 2>/dev/null + elif [ "$kmod" = "zd1211" -o "$kmod" = "zd1211rw" ]; then + modprobe -q zd1211rw 2>/dev/null + elif [ "$kmod" = "rt2400" -o "$kmod" = "rt2400pci" ]; then + modprobe -q rt2400pci 2>/dev/null + elif [ "$kmod" = "rt2500" -o "$kmod" = "rt2500pci" ]; then + modprobe -q rt2500pci 2>/dev/null + elif [ "$kmod" = "rt61" -o "$kmod" = "rt2561" -o "$kmod" = "rt61pci" ]; then + modprobe -q rt61pci 2>/dev/null + elif [ "$kmod" = "rt73" -o "$kmod" = "rt73usb" ]; then + modprobe -q rt73usb 2>/dev/null + elif [ "$kmod" = "bcm43xx" -o "$kmod" = "broadcom" ]; then + modprobe -q bcm43xx 2>/dev/null + else + modprobe -q $kmod 2>/dev/null + fi + done + log_end_msg 0 +fi + +# get list of network interfaces +TCOS_NET_ACTIVE="eth0" +TCOS_NET_WIFI=0 +TCOS_NET_WIFI_ESSID="" +TCOS_NET_WIFI_KEYMODE="" +TCOS_NET_DEVS=$(ls /sys/class/net/ |grep -v -e lo -e sit0 -e wmaster -e pan) +TCOS_NET_LINK="" +TCOS_NET_LINK_NUMBER=0 + + +# search for network interfaces with link ok status +for dev in $TCOS_NET_DEVS; do + # need to up iface + ifconfig $dev up >> /tmp/initramfs.debug 2>&1 + # have link ??? + if [ -e /sys/class/net/$dev/carrier ]; then + if [ "$(cat /sys/class/net/$dev/carrier 2>/dev/null)" != "1" ]; then + # some gigabit cards take some time to negotiate network link + log_begin_msg "Waiting for netlink in $dev" + sleep 10 + log_end_msg + fi + if [ "$(cat /sys/class/net/$dev/carrier 2>/dev/null)" = "1" ]; then + _log "05NETWORK found carrier link in $dev iface" + TCOS_NET_LINK="$TCOS_NET_LINK $dev" + TCOS_NET_LINK_NUMBER=$(($TCOS_NET_LINK_NUMBER+1)) + fi + fi +done + +if [ $(read_cmdline_var 'wifi' '0') = "1" ]; then + #force wireless, read some vars + TCOS_NET_WIFI_ESSID=$(read_cmdline_var "essid" "") + for dev in $TCOS_NET_DEVS; do + # is wireless???? + if [ -e /sys/class/net/$dev/wireless ]; then + TCOS_NET_WIFI=1 + TCOS_NET_LINK=$dev + # stop searching + break + fi + done +fi + + +if [ $TCOS_NET_WIFI = 1 ]; then + # one iface wireless + TCOS_NET_ACTIVE=$TCOS_NET_LINK + +elif [ $TCOS_NET_LINK_NUMBER -gt 1 ]; then + # we have some ifaces with link + _log "05NETWORK various net ifaces have link" + +elif [ $TCOS_NET_LINK_NUMBER = 1 ]; then + # one iface + TCOS_NET_ACTIVE=$TCOS_NET_LINK + +else + # not link !!! + panic "ERROR: No link network detected, check cable." +fi + + # break for wireless + maybe_break wireless + + if [ $TCOS_NET_WIFI = 1 ]; then + + #ifconfig $TCOS_NET_ACTIVE down + #ifconfig $TCOS_NET_ACTIVE up + + [ -z $TCOS_NET_WIFI_KEYMODE ] && TCOS_NET_WIFI_KEYMODE="restricted" + # scan wireless + log_begin_msg "Scanning wireless networks" + iwlist $TCOS_NET_ACTIVE scan | grep ESSID | awk -F ":" '{print $2}' | sed s/\"//g >> /tmp/initramfs.debug 2>&1 + log_end_msg $? + + log_begin_msg "Wireless associating with $TCOS_NET_WIFI_ESSID" + iwconfig $TCOS_NET_ACTIVE essid "$TCOS_NET_WIFI_ESSID" + log_end_msg $? + + # associate if ap cmdline var is set + if [ "$TCOS_NET_WIFI_ESSID" != "" ]; then + if [ "$TCOS_WIRELESS_ENC" = "WPA" ]; then + modprobe -q michael_mic + modprobe -q blkcipher + modprobe -q aes + modprobe -q ieee80211_crypt_tkip + modprobe -q ieee80211_crypt_ccmp + log_begin_msg "Wireless WPA mode" + /sbin/start-wpa.sh "${TCOS_NET_ACTIVE}" + log_end_msg $? + fi + + if [ "$TCOS_WIRELESS_ENC" = "WEP" ]; then + modprobe -q ieee80211_crypt_wep + log_begin_msg "Wireless WEP mode setting key" + if [ ! -z $TCOS_WIRELESS_KEY ];then + iwconfig $TCOS_NET_ACTIVE key $TCOS_NET_WIFI_KEYMODE $TCOS_WIRELESS_KEY + fi + log_end_msg $? + fi + else + log_begin_msg "Wireless associating with any" + iwconfig $TCOS_NET_ACTIVE essid any + log_end_msg $? + fi + #else + # # wired network + # ifconfig $TCOS_NET_ACTIVE down + # ifconfig $TCOS_NET_ACTIVE up + fi + + + log_begin_msg "Sending DHCP request on $TCOS_NET_LINK" + _log "DHCLIENT $TCOS_NET_LINK" + if [ -x /sbin/udhcpc ]; then + /sbin/udhcpc -i $TCOS_NET_LINK -s /bin/udhcpc-script >> /tmp/initramfs.debug 2>&1 + else + busybox udhcpc -i $TCOS_NET_LINK -s /bin/udhcpc-script -O swapsrv >> /tmp/initramfs.debug 2>&1 + fi + myip=$(awk -F"=" '/^ip=/ {print $2}' /tmp/net.data) + dhcpserver=$(awk -F"=" '/^serverid=/ {print $2}' /tmp/net.data) + hostname=$(awk -F"=" '/^hostname=/ {print $2}' /tmp/net.data) + netmask=$(awk -F"=" '/^netmask=/ {print $2}' /tmp/net.data) + gateway=$(awk -F"=" '/^gateway=/ {print $2}' /tmp/net.data) + TCOS_NET_ACTIVE=$(awk -F"=" '/^interface=/ {print $2}' /tmp/net.data) + xserver=$(awk -F"=" '/^swapsrv=/ {print $2}' /tmp/net.data) + log_end_msg 0 + + +if [ -n ${TCOS_DEBUG} ]; then + _log "NETWORK data: ip=${myip} server=${dhcpserver} hostname=${hostname}" +fi + +# count number of ":" in hostname string +if [ $(echo $hostname | awk '{print split($1, A, ":")}') -gt 1 ]; then + if [ -x /bin/hex2ascii ]; then + # got an hexadecimal hostname + hostname2=$(hex2ascii $hostname) + _log "NETWORK HEX hostname \"$hostname\"=\"$hostname2\"" + hostname=$hostname2 + fi +fi + +if [ -z $hostname ] || [ "x{$hostname}" = "x " ]; then + panic "ERROR: DHCP server don't give me a hostname !!! Edit /etc/hosts in dhcp server" +fi + +# search for other hosts +TCOS_TFTP_SERVER=$(read_cmdline_var 'tftpserver' "${dhcpserver}") + +if [ "$xserver" != "" ]; then + TCOS_SERVER=$(read_cmdline_var 'server' "${xserver}") + TCOS_XDMCP_SERVER=$(read_cmdline_var 'xserver' "${xserver}") + TCOS_FONT_SERVER=$(read_cmdline_var 'fontserver' "${xserver}") + TCOS_RDESKTOP_SERVER=$(read_cmdline_var 'rdesktop' "${xserver}") + TCOS_NFS_SERVER=$(read_cmdline_var 'nfsserver' "${xserver}") +else + TCOS_SERVER=$(read_cmdline_var 'server' "${dhcpserver}") + TCOS_XDMCP_SERVER=$(read_cmdline_var 'xserver' "${dhcpserver}") + TCOS_FONT_SERVER=$(read_cmdline_var 'fontserver' "${dhcpserver}") + TCOS_RDESKTOP_SERVER=$(read_cmdline_var 'rdesktop' "${dhcpserver}") + TCOS_NFS_SERVER=$(read_cmdline_var 'nfsserver' "${dhcpserver}") +fi + + +# Setup the hostname +log_begin_msg "Setting hostname to ${hostname}" + echo $hostname > /etc/hostname + echo $hostname > /proc/sys/kernel/hostname + cat <<EOF > /etc/hosts +127.0.0.1 localhost.localdomain localhost +127.0.1.1 ${hostname} +${myip} ${hostname} +${TCOS_SERVER} tcos-server +${TCOS_TFTP_SERVER} tftp-server +${TCOS_XDMCP_SERVER} xdmcp-server +${TCOS_RDESKTOP_SERVER} rdesktop-server +${TCOS_NFS_SERVER} nfs-server +${TCOS_FONT_SERVER} font-server +EOF + +hostname $hostname +export HOSTNAME=$hostname +log_end_msg + +# start portmap || rcpbind (for NFS) +[ -x /sbin/portmap ] && /sbin/portmap >/tmp/portmap.log 2>&1 & +[ -x /sbin/rpcbind ] && /sbin/rpcbind >/tmp/rpcbind.log 2>&1 & + + +exit 0 diff --git a/scripts/tcos-top/20mountnfs b/scripts/tcos-top/20mountnfs new file mode 100755 index 0000000..1f528cf --- /dev/null +++ b/scripts/tcos-top/20mountnfs @@ -0,0 +1,103 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +quiet=n + +# if break=mountnfs STOP here +maybe_break mountnfs + + +# read /tmp/less_ram +if [ "$(cat /tmp/less_ram)" = "0" ]; then + # have more than TCOS_MIN_RAM + exit 0 +fi + + + +# if use NFS try to mount: +# +# SERVER_IP:/var/lib/tcos/fs-$(uname -r) +# + + +MNTOPT="ro,nolock,rsize=2048,wsize=2048,retrans=10" +NFS_RO=/mnt/nfs +NFS_RW=/root + + +mkdir -p /root +mkdir -p /mnt/nfs + +# NFS or NBD ? +NFS_MODE=$(read_cmdline_var "nfsmode" "nfs") + + +if [ "${NFS_MODE}" = "nbd" ]; then + # mount root-$(uname -r).squashfs as /dev/nbd0 + log_begin_msg "Mounting remote squashfs with NBD" + + NBD_PORT=$(read_cmdline_var "nbdport" "2001") + + # load 1 nbd devices + modprobe nbd nbds_max=1 + + # wait for device + while [ ! -e /dev/nbd0 ]; do + sleep 1 + done + + nbd-client tcos-server $NBD_PORT /dev/nbd0 + sleep 1 + + mount /dev/nbd0 /mnt/nfs + + log_end_msg $? + +else + log_begin_msg "Trying to mount NFS" + nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/fs-$(uname -r) ${NFS_RO} 2>/dev/null + + + # try again + if [ $? -ne 0 ]; then + log_begin_msg "Second retry to mount NFS" + nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/fs-$(uname -r) ${NFS_RO} 2> /dev/null + fi + + if [ $? -ne 0 ]; then + panic "Unable to mount NFS, check NFS service in server and ${TCOS_VAR}/fs-$(uname -r) dir" + fi + log_end_msg $? + +fi # end of NFS_MODE + + +# remount /root in RW mode + + +log_begin_msg "Remounting root in RW mode" + + mount_unionfs /mnt/ram /mnt/nfs /root + +log_end_msg $? + + +maybe_break move_mnt + +# Set browseable NFS and RAM dirs +mkdir -p /root/.dirs/nfs +mkdir -p /root/.dirs/ram +mount -o move /mnt/nfs /root/.dirs/nfs +mount -o move /mnt/ram /root/.dirs/ram + + +exit 0 diff --git a/scripts/tcos-top/50fstab b/scripts/tcos-top/50fstab new file mode 100755 index 0000000..aaed4df --- /dev/null +++ b/scripts/tcos-top/50fstab @@ -0,0 +1,128 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + +quiet=n +. /scripts/functions +# if break=fstab STOP here +maybe_break fstab + +. /conf/tcos.conf +. /conf/tcos-run-functions + + +cat <<EOF > /etc/fstab +# /etc/fstab: static file system information. +# +# <file system> <mount point> <type> <options> <dump> <pass> +proc /proc proc defaults 0 0 +sys /sys sysfs defaults 0 0 +none /dev/pts devpts gid=5,mode=620 0 0 +EOF + +if [ ! -d /dev/pts ]; then + _log "FSTAB Mount /dev/pts" + mkdir -p /dev/pts + mount /dev/pts >> /tmp/initramfs.debug 2>&1 +fi + +# mount usbfs +if [ "$(grep -c usbfs /proc/filesystems)" != "0" ] && [ ! -e /proc/bus/usb/devices ]; then + log_begin_msg "Mounting /proc/bus/usb" + mount -t usbfs procbususb /proc/bus/usb/ 2>/dev/null + log_end_msg $? +fi + + +# DOCUMENTME uselocal | enable use of local disks +uselocal=$(read_cmdline_var "uselocal" "1") +if [ ${uselocal} = 0 ]; then + _log "FSTAB uselocal disabled from cmdline" + exit 0 +fi + + +if [ "$NO_UDEV" = "" ]; then + # don't call udev again with NFS + # wait for devices + [ -x /sbin/udevtrigger ] && /sbin/udevtrigger --subsystem-match=ide --subsystem-match=block + [ -x /sbin/udevsettle ] && /sbin/udevadm settle +fi + + +# To avoid fsck +#touch ${rootmnt}/fastboot + +# +# Search local disks partitions +# +get_partitions () +{ + echo $(ls /dev/[sh]d[a-z]?* 2>/dev/null) +} + + +# +# Search for CD/DVDs +# +get_cdroms () +{ + echo $(head -3 /proc/sys/dev/cdrom/info 2>/dev/null | tail -1 | cut -f 3-) +} + +# +# Create fstab +# +create_fstab () +{ + defaults=" defaults,noauto 0 2" + + partitions=$(get_partitions) + for part in $partitions; do + # get_filesystem is a script in /bin + entry=$(get_filesystem $part) + dev=$(echo $entry | awk '{print $1}' ) + fs=$(echo $entry | awk '{print $2}' ) + if [ "$fs" = "swap" ] ; then + entry="${dev} none swap sw 0 0" + elif [ "$fs" = "extended" ] ; then + # extended partition + continue + else + mntpoint="/mnt/${dev#/dev/}" + mkdir -p $mntpoint + if [ "$fs" = "ntfs" ]; then + defaults=" defaults,ro,noauto 0 2" + fi + entry="${dev} ${mntpoint} ${fs} ${defaults}" + fi + echo $entry >> /etc/fstab + done + num=0 + cdroms=$(get_cdroms) + for cd in $cdroms; do + entry="/dev/${cd} /mnt/cdrom${num} udf,iso9660 ro,noauto 0 0" + mkdir -p /mnt/cdrom${num} >> /var/log/initramfs.debug 2>&1 + num=$(($num+1)) + echo $entry >> /etc/fstab + done +} + + +[ "$NO_MSG" = "" ] && log_begin_msg "Searching local disks (fstab)" + create_fstab + rm -f /etc/mtab + cat /proc/mounts > /etc/mtab + + # force boot without swap + if [ "$(read_cmdline_var 'noswap' '0')" = 0 ]; then + swapon -a >> /tmp/initramfs.debug 2>&1 + fi + + _log "FSTAB done" +[ "$NO_MSG" = "" ] && log_end_msg 0 + +exit 0 + diff --git a/scripts/tcos-top/60make_init b/scripts/tcos-top/60make_init new file mode 100755 index 0000000..a6c2d29 --- /dev/null +++ b/scripts/tcos-top/60make_init @@ -0,0 +1,87 @@ +#!/bin/sh +# +if [ "$1" = "prereqs" ]; then + exit 0 +fi + + +. /scripts/functions +. /conf/tcos.conf +. /conf/tcos-run-functions + +quiet=n + +# if break=make_init STOP here +maybe_break make_init + +# read /tmp/less_ram +if [ "$(cat /tmp/less_ram)" = "0" ]; then + # have more than TCOS_MIN_RAM + exit 0 +fi + + +if grep -q bootchartd /proc/cmdline ; then + # stop bootchart + /sbin/tcos-bootchartd stop + mkdir -p /root/tmp/bootchart + mv /tmp/bootchart/* /root/tmp/bootchart +fi + +UDEV_SCRIPT=/scripts/init-premount/udev +[ -e /scripts/init-top/udev ] && UDEV_SCRIPT=/scripts/init-top/udev + + +rm -f /root/sbin/init +cat << EOF > /root/sbin/init +#!/bin/sh + +. /scripts/functions + +. /conf/initramfs.conf +. /conf/tcos.conf + +quiet=n + +if grep -q bootchartd /proc/cmdline ; then + /sbin/daemonize.sh /sbin/tcos-bootchartd start +fi + + +/scripts/tcos-top/01busybox >/dev/null 2>&1 + +# start udev again +log_begin_msg "Re-Discovering hardware" +$UDEV_SCRIPT +find / -type f >/dev/null 2>&1 +log_end_msg \$? + + +run_scripts /scripts/tcos-bottom/ + +EOF +chmod +x /root/sbin/init + + + + +mkdir -p /root/proc /root/dev /root/sys +mkdir -p /root/var/run /root/var/www /root/var/log /root/tmp + +#mkdir -p /root/var/lib/dhcp +#cat /var/lib/dhcp/dhclient.leases > /root/var/lib/dhcp/dhclient.leases +cat /tmp/net.data > /root/tmp/net.data +cat /etc/hostname > /root/etc/hostname +cat /etc/hosts > /root/etc/hosts +cat /etc/resolv.conf > /root/etc/resolv.conf +cat /etc/modules > /root/etc/modules +cat /tmp/initramfs.debug > /root/tmp/initramfs.debug +cat /var/log/messages > /root/var/log/messages +cat /tmp/less_ram > /root/tmp/less_ram + +touch /etc/mtab +cat /etc/mtab > /root/etc/mtab + +[ -e /etc/console/boottime.kmap.gz ] && cat /etc/console/boottime.kmap.gz > /root/etc/console/boottime.kmap.gz + +exit 0 |