home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenStep 3.3J
/
os33j.iso
/
private
/
etc
/
rc.swap
< prev
next >
Wrap
Text File
|
1993-08-23
|
4KB
|
115 lines
#!/bin/sh -u
#
# This script mounts and initializes the internal swapdisk which we mount
# on /tmp.
#
# Copyright (C) 1992 by NeXT Computer, Inc. All rights reserved.
#
# This script is invoked automatically when booted from a CD-ROM.
# Trying to run it directly will probably not do what you expect.
NEWSWAPDIR=/private/swapdisk/vm
NEWSWAPFILE=$NEWSWAPDIR/swapfile
# Find out which devices to check. The result of this command will
# be a list of the SCSI disks installed (specifically, the A partitions
# of all these disks).
DRIVES=`echo /dev/sd?a | sed -e 's/\/dev\///g'`
useswap=0
for SWAPDEV in $DRIVES
do
# checkswap looks to see if a swapdisk is there. In the cases for
# 1 and 2, below, the echos are commented out because these are
# normal conditions (especially case 2).
/usr/etc/checkswap -f /dev/r${SWAPDEV}
swapstatus=$?
case $swapstatus in
0)
# No such disk was actually connected.
# break;
;;
1)
# Disk was there, but didn't have any label.
# (echo "No valid label on ${SWAPDEV}.") >/dev/console
;;
2)
# Disk was there, it had a label, and it's not a swapdisk
# (echo "/dev/$SWAPDEV is not a swapdisk!") >/dev/console
;;
3)
# We have a swapdisk (or, a disk labeled swapdisk).
if [ $1x = autobootx ]; then
# If we did a normal boot, do an fsck on the swapdisk
fbshow -B -I "Checking swapdisk" -z 20
(echo "Checking swapdisk ${SWAPDEV}") > /dev/console
/usr/etc/fsck -p /dev/r${SWAPDEV} >/dev/console 2>&1 \
&& useswap=1
else
useswap=1
fi
break
;;
*)
# swapdisk said something unintelligible.
(echo "Unknown error from checkswap, error=$swapstatus") \
>/dev/console
;;
esac
done
# We have a swap disk, set things up to use it.
if [ $useswap -eq 1 ]; then
# Mount the swapdisk on /private/swapdisk
fbshow -B -I "Mounting swapdisk" -z 21
/usr/etc/mount -o rw,noquota,noauto /dev/${SWAPDEV} /private/swapdisk \
>/dev/console 2>&1
# Set up swapping on it. We need the SWAPDIR and the SWAPFILE.
# If we make the file anew, we turn on its sticky bit, and ensure
# that only root can read it.
if [ ! -d $NEWSWAPDIR ]; then
(echo "Creating vm directory on swapdisk") >/dev/console
mkdir $NEWSWAPDIR
chmod 755 $NEWSWAPDIR
fi
if [ ! -f $NEWSWAPFILE ]; then
(echo "Creating swapfile on swapdisk") >/dev/console
touch $NEWSWAPFILE
chmod 1600 $NEWSWAPFILE
fi
# Turn on paging to the swapdisk. Note the high water mark (hiwat):
# this helps ensure the swapdisk doesn't get full.
/usr/etc/mach_swapon -v -o prefer,lowat=16777216,hiwat=31457280 \
$NEWSWAPFILE >/dev/console 2>&1
# Make sure there is a tmp directory. Note the sticky bit, which
# is critical for security.
if [ ! -d /private/swapdisk/tmp ]; then
(echo "Creating tmp directory on swapdisk") >/dev/console
mkdir /private/swapdisk/tmp
chmod 1777 /private/swapdisk/tmp
fi
# Point /private/tmp to the swapdisk's tmp directory. We assume
# that if /private/tmp is a symlink, then either it references
# the swapdisk already or the user who modified it knew what
# he or she was doing.
if [ ! -h /private/tmp ]; then
(echo "Linking /private/tmp to /private/swapdisk/tmp") \
>/dev/console
rm -rf /private/tmp
(cd /private; ln -s swapdisk/tmp)
fi
else
# No swapdisk; ensure /private/tmp is a directory.
if [ ! -d /private/tmp ]; then
(echo "Creating /private/tmp directory") >/dev/console
rm -f /private/tmp
mkdir /private/tmp
chmod 1777 /private/tmp
fi
fi
exit 0