]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.diskless2
Define OPENSSL_DES_LIBDES_COMPATIBILITY so that Heimdal will build with
[FreeBSD/FreeBSD.git] / etc / rc.diskless2
1 # Copyright (c) 1999  Matt Dillon
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 # 1. Redistributions of source code must retain the above copyright
8 #    notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 #    notice, this list of conditions and the following disclaimer in the
11 #    documentation and/or other materials provided with the distribution.
12 #
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 # SUCH DAMAGE.
24 #
25 # $FreeBSD$
26 #
27
28 #
29 # rc.diskless2
30 #
31
32 # Provide a function for normalizing the mounting of memory
33 # filesystems.  This should allow the rest of the code here to remain
34 # as close as possible between 5-current and 4-stable.
35 #   $1 = size
36 #   $2 = mount point
37 #   $3 = md unit number (ignored in pre 5.0 systems)
38 #   $4 = (optional) bytes-per-inode
39 mount_md() {
40         if [ -n "$4" ]; then
41                 bpi="-i $4"
42         fi
43         /sbin/mdconfig -a -t malloc -s $1 -u $3
44         /sbin/disklabel -r -w md$3 auto
45         /sbin/newfs $bpi /dev/md$3c
46         /sbin/mount /dev/md$3c $2
47 }
48
49 # If there is a global system configuration file, suck it in.
50 #
51 if [ -r /etc/defaults/rc.conf ]; then
52         . /etc/defaults/rc.conf
53         source_rc_confs
54 elif [ -r /etc/rc.conf ]; then
55         . /etc/rc.conf
56 fi
57
58 # If we do not have a writable /var, create a memory
59 # filesystem for /var.  We don't have /usr yet so
60 # use mkdir instead of touch to test.  We want mount
61 # to record its mounts so we have to make sure /var/db
62 # exists before doing the mount -a.
63 #
64 if (/bin/mkdir /var/.diskless 2> /dev/null); then
65         rmdir /var/.diskless
66 else
67         echo "+++ mount_md of /var"
68         mount_md ${varsize:=32m} /var 1
69 fi
70
71 if [ ! -d /var/db ]; then
72         mkdir /var/db
73 fi
74
75 # Now we need the rest of our mounts, particularly /usr
76 #
77 mount -a       # chown and chgrp are in /usr
78
79 # Populate /var
80 #
81 echo "+++ populate /var using /etc/mtree/BSD.var.dist"
82 /usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
83 case ${sendmail_enable} in
84 [Nn][Oo][Nn][Ee])
85         ;;
86 *)
87         /usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
88         ;;
89 esac
90
91 echo "+++ create log files based on the contents of /etc/newsyslog.conf"
92 LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
93 if [ -n "$LOGFILES" ]; then
94         /usr/bin/touch $LOGFILES
95 fi
96
97 echo "+++ create lastlog"
98 /usr/bin/touch /var/log/lastlog
99
100 # Make sure our aliases database is uptodate, the aliases may have
101 # been overriden in /conf.
102 #
103 /usr/bin/newaliases
104
105 # XXX make sure to create one dir for each printer as requested by lpd
106 #
107 # If we do not have a writable /tmp, create a memory
108 # filesystem for /tmp.  If /tmp is a symlink (e.g. to /var/tmp,
109 # then it should already be writable).
110 #
111 if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
112         rmdir /tmp/.diskless
113 else
114         if [ -h /tmp ]; then
115                 echo "*** /tmp is a symlink to a non-writable area!"
116                 echo "dropping into shell, ^D to continue anyway."
117                 /bin/sh
118         else
119                 mount_md ${tmpsize:=20480} /tmp 2
120                 chmod 01777 /tmp
121         fi
122 fi
123
124 if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
125         # we have DEVFS, no worries...
126         true
127 elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
128         # if /dev is writable assume it has already been populated
129         # via rc.diskless1
130         #
131         rmdir /dev/.diskless
132 else
133         (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
134         mount_md 4096 /dev 3 512
135         (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
136         rm -f /tmp/dev.tmp
137 fi
138