~ubuntu-branches/ubuntu/quantal/aufs/quantal

« back to all changes in this revision

Viewing changes to sample/diskless/linuxrc

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2007-05-09 15:29:28 UTC
  • Revision ID: james.westby@ubuntu.com-20070509152928-4sywrmkifvz0bq02
Tags: upstream-0+20070509
ImportĀ upstreamĀ versionĀ 0+20070509

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# aufs sample -- diskless system
 
4
 
 
5
# Copyright (C) 2006, 2007 Junjiro Okajima
 
6
#
 
7
# This program, aufs is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 2 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program; if not, write to the Free Software
 
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 
 
21
# $Id: linuxrc,v 1.5 2007/04/23 00:59:51 sfjro Exp $
 
22
 
 
23
set -e
 
24
#echo here i am
 
25
trap "test \$? -ne 0 && sleep 3600" 0
 
26
 
 
27
#set
 
28
#echo $PATH
 
29
mount -nt proc proc /proc
 
30
f=/proc/sys/kernel/printk
 
31
echo 8 > $f
 
32
 
 
33
eval `bootpc | egrep '^(HOSTNAME|SERVER|BOOTFILE|DOMAIN|DNSSRVS)='`
 
34
test `cat /proc/sys/kernel/hostname` = $HOSTNAME
 
35
export HOSTNAME SERVER BOOTFILE
 
36
 
 
37
mount -t tmpfs tmp tmp
 
38
remote=`dirname $BOOTFILE`
 
39
for i in aufs.ko comount.sh exportfs.ko nfsd.ko
 
40
do
 
41
        tftp -g $SERVER -r $remote/$i -l tmp/$i > /dev/null 2>&1
 
42
        test -f tmp/$i
 
43
done
 
44
insmod tmp/exportfs.ko
 
45
insmod tmp/nfsd.ko
 
46
insmod tmp/aufs.ko brs=1
 
47
 
 
48
eval `tr ' ' '\n' < /proc/cmdline | grep '^dl_label='`
 
49
sh tmp/comount.sh $dl_label
 
50
#/bin/sh -i
 
51
rm tmp/comount.sh
 
52
 
 
53
d=/aufs/etc
 
54
f=$d/resolv.conf
 
55
mkdir -p $d
 
56
test -h $f || { echo domain $DOMAIN; echo nameserver $DNSSRVS; } > $f
 
57
 
 
58
#cat /proc/mounts; /bin/sh -i
 
59
echo 0x0100 > /proc/sys/kernel/real-root-dev
 
60
umount /proc
 
61
 
 
62
if [ "$initrd" = "initramfs.gz" ]
 
63
then
 
64
        # rm
 
65
        umount /branch
 
66
        mkdir -p aufs/branch
 
67
        #mount -t tmpfs none aufs/branch
 
68
        set -x
 
69
        for i in branch/* branch/loop/*
 
70
        do
 
71
                test -d $i || continue
 
72
                mkdir -p aufs/$i
 
73
                #/bin/mount -n --move $i aufs/$i || :
 
74
                /bin/mount -n --move $i aufs/$i 2> /dev/null || :
 
75
        done
 
76
 
 
77
        cd aufs
 
78
        /bin/mount -n --bind /tmp branch
 
79
        mount -nt proc proc /proc
 
80
        egrep -v ' (root|cram)fs ' /proc/mounts > etc/mtab
 
81
        umount /proc
 
82
        /bin/mount -n -o remount,ro aufsroot .
 
83
        /bin/mount -n --move . /
 
84
        test "$dl_label" = "knoppix" && mount -nt proc proc /proc
 
85
        #/bin/sh -i
 
86
        trap "" 0
 
87
        exec chroot . sbin/init < dev/console > dev/console 2>&1 dev/console
 
88
else
 
89
        cd aufs
 
90
        mkdir -p initrd
 
91
        pivot_root . initrd
 
92
        /initrd/bin/busybox mount -nt proc proc /proc
 
93
        /initrd/bin/busybox egrep -v ' (root|cram)fs ' /proc/mounts > etc/mtab
 
94
        /initrd/bin/busybox umount /proc
 
95
        /initrd/bin/busybox mount -o remount,ro .
 
96
        trap "" 0
 
97
fi