My favorites | Sign in
Project Home Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/sh
#
# Copyright (c) 2007-2009 The PureDarwin Project.
# All rights reserved.
#
# @LICENSE_HEADER_START@
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @LICENSE_HEADER_END@
#

#
# aladin <aladin@puredarwin.org>
#

#
# PureDarwin install (wrapper) script
#
# Usage: pd_installer
#
# This script should not be run manually but by launchd via its respective plist.
#
# Based on the "OpenDarwin install script" by kvv
# $Id: rc.cdrom,v 1.30 2005/04/28 20:06:46 kevin Exp $
#
# Based on the "PureDarwin boot installer" (pd_installer_1) by Stuart Crook
# v1.0 31/03/09 Initial release

###############################################################################
# GLOBAL VARIABLES AND SETTINGS
###############################################################################

# Redirecting stdin (/dev/stdin -> /dev/fd/0)
exec 0</dev/console
# Redirecting stdout (/dev/stdout -> /dev/fd/1)
exec 1>/dev/console
# Redirecting stderr (/dev/stderr -> /dev/fd/2)
exec 2>/dev/console

# File creation mask
umask 022 # all files created are -rw-r--r--

# Env
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/libexec:/System/Library/CoreServices
export MANPATH=/usr/share/man:/usr/local/man
export EDITOR=/usr/bin/vi
export TERM=xterm-color

# Setting hostname
sysctl -w kern.hostname="PureDarwin.local"

# Populating /dev/fd/ with mount_fdesc
/bin/df | /usr/bin/grep fdesc
if [ ! $? -eq 0 ]; then
/sbin/mount -t fdesc -o union stdin /dev
fi

# Workaround read-write
#/sbin/mount -uw /

# Find out where this script lives
DIRNAME=$(cd $(dirname $0) && pwd)

###############################################################################
# FUNCTIONS
###############################################################################

add_user () {

TARGET="$1"
MOUNT="/Volumes/$2"

# The mount point must exist (prior) without ramdisk
#mkdir -p "$MOUNT"
# FIXME s1 is static.
/sbin/mount -t hfs "${TARGET}s1" "$MOUNT"

chroot $MOUNT /usr/local/share/puredarwin/scripts/pd_injectuser /
# Alternative: FIXME add dscl / pd_adduser

/sbin/umount -f $MOUNT
}

welcome() {

clear

#echo
#echo "Welcome to PureDarwin!" # /etc/motd
#echo
#echo " Darwin (c) 1999-2009 Apple, Inc. (opensource.apple.com)"
#echo " Purity (c) 2007-2009 The PureDarwin Project (puredarwin.org)"
#echo

# Above replaced by `pd_xkp' built on PureDarwin (D9, i386) displaying the same message as above.
/usr/local/share/puredarwin/projects/pd_xkp/pd_xkp

#if [ -f "/Release Notes.txt" ]; then
# echo ""
# echo "Welcome to the installation of" `grep 'Darwin [0-9.-]*' /Release\ Notes.txt | head -1 | awk '{print $1" "$2}'`
# echo ""
#fi
#if [ -f "/Important Notice.txt" ]; then
# cat "/Important Notice.txt"
#fi
}

###############################################################################
# INTRO
###############################################################################

welcome

echo
echo "Enter 's' to drop into a shell."
echo

###############################################################################
# DISK DEVICE
###############################################################################

# Get the device the user wants to install onto.
INSTALLDEV="novalue"
until [[ ${INSTALLDEV} != "" && -b ${INSTALLDEV} ]]
do
echo
echo "The following devices are available for installation:"
until [[ ! -z "${FOO}" ]]
do
FOO=`$DIRNAME/../setup/pd_setup_files/iofindwholemedia`
done
$DIRNAME/../setup/pd_setup_files/iofindwholemedia
printf "Which device would you like to install PureDarwin onto? "
read INSTALLDEV

if [ "${INSTALLDEV}" == "s" ]; then
# Drop into a shell (resume at exit)
/bin/sh
else
# Check and retrieve the disk device node (e.g., /dev/disk1)
T_INSTALLDEV="$INSTALLDEV"
INSTALLDEV=`$DIRNAME/../setup/pd_setup_files/iofindwholemedia ${INSTALLDEV}`

if [ ! -b "${INSTALLDEV}" ]; then
echo
echo "\"${T_INSTALLDEV}\" doesn't exist, please enter one of the listed devices."
fi
fi
done

###############################################################################
# SETUP BASE
###############################################################################

PUREDARWIN_RELEASE=""
until [ ! : ]
do
echo
echo "The following releases are available for installation: "
echo "1. PureDarwin"
echo "2. Puredarwin boostrap"
echo "3. PureDarwin nano"
printf "Your Choice: "
read CHOICE
case ${CHOICE} in
s) /bin/sh
;;
1) PUREDARWIN_RELEASE="" /usr/local/share/puredarwin/setup/pd_setup "$INSTALLDEV" PureDarwin
break
;;
2) PUREDARWIN_RELEASE="bootstrap"
PUREDARWIN_RELEASE="bootstrap" /usr/local/share/puredarwin/setup/pd_setup "$INSTALLDEV" PureDarwin
break
;;
3) PUREDARWIN_RELEASE="nano"
PUREDARWIN_RELEASE="nano" /usr/local/share/puredarwin/setup/pd_setup "$INSTALLDEV" PureDarwin
break
;;
*) echo
echo "\"${CHOICE}\" doesn't exist, please enter one of the listed releases."
;;
esac
done

echo
echo "Installation of the base system should now be complete."

###############################################################################
# POST CONFIG
###############################################################################

# FIXME: needed? where?
# Unpopulating /dev
#/sbin/umount /dev

until [ ! : ]
do
echo
echo "You may: "
echo "1. Reboot"
echo "2. Spawn a shell"
if [ "$PUREDARWIN_RELEASE" = "" ]; then
echo "3. Add a user"
fi
printf "Your Choice: "
read CHOICE
echo
case ${CHOICE} in
s) /bin/sh
;;
1) break
;;
2) /bin/sh
;;
3) if [ "$PUREDARWIN_RELEASE" = "" ]; then
add_user "$INSTALLDEV" PureDarwin
fi
;;
*) echo "\"${CHOICE}\" doesn't exist, please enter one of the listed choice."
;;
esac
done


###############################################################################
# REBOOT
###############################################################################

echo
echo "Installation should now be complete. Press 'enter' to restart"
read RESTART
echo ""
reboot

# bash interactive
#/bin/bash -i

# zsh interactive
#/bin/zsh -i

Change log

1ede87dc1f2f by Aladin Quet <ala...@puredarwin.org> on Jan 11, 2010   Diff
Fixed fdesc mount in `pd_installer' (each
time `launchd' respawned `pd_installer',
an additional fdesc was mounted in /dev).
Disabled load/unload of
diskarbitrationd.plist in case the file is
not present.
Added -u (--update) for gnutar: only
append files that are newer than the
existing in archive.
Minor cosmectic.
Go to: 
Project members, sign in to write a code review

Older revisions

656529322b14 by Aladin Quet <ala...@puredarwin.org> on Jan 10, 2010   Diff
Added PureDarwin releases choice.
Fixed adduser choice.
66adcccf82c1 by Aladin Quet <ala...@puredarwin.org> on Dec 29, 2009   Diff
Minor updates, temporarly removed "add
user".
e9dfe71c9222 by Aladin Quet <ala...@puredarwin.org> on Dec 13, 2009   Diff
Added bash and/or zsh choice.
Minor fixes.
All revisions of this file

File info

Size: 7326 bytes, 260 lines
Powered by Google Project Hosting