summaryrefslogtreecommitdiff
path: root/i/pc104/initrd/conf/update_initrd.sh
blob: 1f99519e28c3d48671ec06452e49469b3d4552be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# The purpose of this script is to provide a system to update the PC104 in
# autonomous mode via the network.
# It is called by the linuxrc/init at boot in another process so it can be
# blocking. It should not be called by hand.

# PATH is not correctly set...
PATH=$PATH:/usr/sbin/
# Bring eth0 up
ifconfig eth0 up 
# Get the configuration of the network via dhcp
# TODO Check life time of this program and that it does not do stupid things
# after a while...
udhcpc -i eth0 -s /etc/udhcpc.script
# Wait here for a connection. I do not know if it is a feature or a bug, but
# when nc receive a connection, it is end here. Maybe it is because of the
# missing library (warmed by gcc at compiled time)
nc -l -p 1234

# From here, someone has connected to the 1234 port, we mount the real linux
# inside of the PC104 and start a ssh daemon, it is easier to use
#
# Mount the real system read only (security reason in case of hard reboot)
mount -r /mnt/localsys
# Chroot to the new_root
cd /mnt/localsys
# For the moment, I have seen it is compulsary to put the redirection
chroot . sh -c '/etc/init.d/mountvirtfs; /etc/init.d/ssh start; exit' \
<dev/console >dev/console 2>&1
# XXX I would like the previous command to end, and give back the hand to the
# next one. This way, I could have still a way to comunicate with the PC104 by
# the initrd and not by the chrooted mode.
# read 5