dot.profile revision 1.2.16.1       1  1.2.16.1  bouyer # $NetBSD: dot.profile,v 1.2.16.1 2009/01/15 22:22:07 bouyer Exp $
      2       1.1     leo #
      3       1.1     leo # Copyright (c) 1995 Jason R. Thorpe
      4       1.1     leo # Copyright (c) 1994 Christopher G. Demetriou
      5       1.1     leo # All rights reserved.
      6       1.1     leo # 
      7       1.1     leo # Redistribution and use in source and binary forms, with or without
      8       1.1     leo # modification, are permitted provided that the following conditions
      9       1.1     leo # are met:
     10       1.1     leo # 1. Redistributions of source code must retain the above copyright
     11       1.1     leo #    notice, this list of conditions and the following disclaimer.
     12       1.1     leo # 2. Redistributions in binary form must reproduce the above copyright
     13       1.1     leo #    notice, this list of conditions and the following disclaimer in the
     14       1.1     leo #    documentation and/or other materials provided with the distribution.
     15       1.1     leo # 3. All advertising materials mentioning features or use of this software
     16       1.1     leo #    must display the following acknowledgement:
     17       1.1     leo #          This product includes software developed for the
     18       1.2    salo #          NetBSD Project.  See http://www.NetBSD.org/ for
     19       1.1     leo #          information about NetBSD.
     20       1.1     leo # 4. The name of the author may not be used to endorse or promote products
     21       1.1     leo #    derived from this software without specific prior written permission.
     22       1.1     leo # 
     23       1.1     leo # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24       1.1     leo # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1     leo # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1     leo # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27       1.1     leo # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28       1.1     leo # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29       1.1     leo # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30       1.1     leo # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31       1.1     leo # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32       1.1     leo # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1     leo # 
     34       1.1     leo # <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
     35       1.1     leo 
     36       1.1     leo PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
     37       1.1     leo export PATH
     38       1.1     leo TERM=vt220
     39       1.1     leo export TERM
     40       1.1     leo HOME=/
     41       1.1     leo export HOME
     42       1.1     leo OBLOCKSIZE=1k
     43       1.1     leo export BLOCKSIZE
     44       1.1     leo EDITOR=ed
     45       1.1     leo export EDITOR
     46       1.1     leo 
     47       1.1     leo umask 022
     48       1.1     leo 
     49       1.1     leo makerootwritable() {
     50       1.1     leo 	if [ ! -e /tmp/.root_writable ]; then
     51  1.2.16.1  bouyer 		# note, only handles up to partition 'j'
     52  1.2.16.1  bouyer 		rootdev=/dev/$(sysctl -n kern.root_device)$(sysctl -n kern.root_partition | sed y/0123456789/abcdefghij/)
     53  1.2.16.1  bouyer 		if ! mount $rootdev / ; then
     54  1.2.16.1  bouyer 		    echo "Unable to mount $rootdev read-write"
     55  1.2.16.1  bouyer 		    exit 1
     56       1.1     leo 		fi
     57       1.1     leo 		cp /dev/null /tmp/.root_writable
     58  1.2.16.1  bouyer 		echo "Mounted $rootdev read-write"
     59       1.1     leo 	fi
     60       1.1     leo }
     61       1.1     leo 
     62       1.1     leo if [ "X${DONEPROFILE}" = "X" ]; then
     63       1.1     leo 	DONEPROFILE=YES
     64       1.1     leo 	export DONEPROFILE
     65       1.1     leo 
     66       1.1     leo 	# set up some sane defaults
     67       1.1     leo 	echo 'erase ^H, werase ^W, kill ^U, intr ^C'
     68       1.1     leo 	stty newcrt werase ^W intr ^C kill ^U erase ^H 9600
     69       1.1     leo 
     70       1.1     leo 	# mount root read write
     71       1.1     leo 	makerootwritable
     72       1.1     leo 
     73       1.1     leo 	# If supported: Select a keyboard map
     74       1.1     leo 	/usr/sbin/loadkmap > /dev/null 2>&1
     75       1.1     leo 	if [ $? -eq 0 ]; then
     76       1.1     leo 		_maps=`ls /usr/share/keymaps/atari | sed 's/\.map//g'`
     77       1.1     leo 	fi
     78       1.1     leo 	while [ ! -z "$_maps" ]; do
     79       1.1     leo 		echo "The available keyboard maps are:"
     80       1.1     leo 		_num=0
     81       1.1     leo 		for i in $_maps; do
     82       1.1     leo 			echo "	$_num  $i"
     83       1.1     leo 			_num=`expr $_num + 1`
     84       1.1     leo 		done
     85       1.1     leo 		echo
     86       1.1     leo 		echo -n "Select the number of the map you want to activate: "
     87       1.1     leo 		read _ans
     88       1.1     leo 
     89       1.1     leo 		# Delete all non-nummeric characters from the users answer
     90       1.1     leo 		if [ ! -z "$_ans" ]; then
     91  1.2.16.1  bouyer 			_ans=`echo $_ans | sed 's/[^0-9]//g'`
     92       1.1     leo 		fi
     93       1.1     leo 
     94       1.1     leo 		# Check if the answer is valid (in range). Note that an answer
     95       1.1     leo 		# < 0 cannot happen because the sed(1) above also removes the
     96       1.1     leo 		# sign.
     97       1.1     leo 		if [ -z "$_ans" -o "$_ans" -ge $_num ]; then
     98       1.1     leo 		    echo "You entered an invalid response, please try again."
     99       1.1     leo 		    continue
    100       1.1     leo 		fi
    101       1.1     leo 
    102       1.1     leo 		# Got a valid answer, activate the map...
    103       1.1     leo 		set -- $_maps
    104       1.1     leo 		shift $_ans
    105       1.1     leo 		/usr/sbin/loadkmap -f /usr/share/keymaps/atari/$1.map
    106       1.1     leo 		break
    107       1.1     leo 	done
    108       1.1     leo 
    109  1.2.16.1  bouyer 	sysinst
    110       1.1     leo fi
    111