summaryrefslogtreecommitdiff
path: root/SETUP
blob: f684396e741f198abaa7d8552d94661c731e2da2 (plain)
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
#!/bin/bash
#
# Setup initial hurd translators
#
# This script tries to setup a reasonable set of translators for a newly
# untarred hurd filesystem (since tar currently isn't able to do it).
#
# By passing in a value in the environment variable ROOT, an alternate root
# filesystem may be setup.
#

# A list of likely mach devices to try
DISK_DEVS="`eval echo {s,h}d{0,1,2,3,4}{a,b,c,d,e,f,g,h}`"
NET_DEVS="`eval echo {eth,ne,wd,ul}{0,1,2,3,4}`"

ROOT=${ROOT:-/}
case "$ROOT" in
  /)  PFX="";;
  *)  PFX="$ROOT";;
esac

DEV=${DEV:-/dev}
SERVE=${SERVE:-$PFX/servers}

PDEV=$PFX$DEV
SOCK=$SERVE/socket

function st {
  /bin/settrans -c "$@"
}
function gt {
  /bin/showtrans 2>/dev/null "$@"
}

# Test to see whether a node has a translator
function tp {
  /bin/showtrans -s 2>/dev/null "$@"
}

# Make a device (MAKEDEV uses $_CWD as the device directory)
function md {
 (cd $PDEV && _CWD=$DEV $PDEV/MAKEDEV "$@")
}

function devs {
  /bin/devprobe "$@"
}

PATH=/bin

echo '(For most prompts, `none'\'' is also a valid input)'

# Setup pflocal first, since the shell wants to use it
if tp $SOCK/1; then
  echo "PFLOCAL translator present."
else
  echo "Setting PFLOCAL translator..."
  st $SOCK/1 /hurd/pflocal
fi

if tp $PDEV/console && tp $PDEV/null && tp $PDEV/fd; then
  echo "Standard devices already present."
else
  echo "Making standard devices..."
  md std
fi

# See which disk devices might need creating
DISK_DEVS="`devs $DISK_DEVS`"
if test "$DISK_DEVS"; then
  echo "Mach disk devices found: `echo $DISK_DEVS`"
else
  echo "No mach disk devices found!"
fi

ALREADY=''
MAYBE=''
for D in $DISK_DEVS; do
  if tp $PDEV/r$D; then
    ALREADY="${ALREADY:+$ALREADY }$D"
  else
    MAYBE="${MAYBE:+$MAYBE }$D"
  fi
done
if test "$ALREADY"; then 
  echo "Disk devices with nodes in $PDEV: $ALREADY"
fi
if test "$MAYBE"; then
  echo -n "Create device nodes in $PDEV for: [$MAYBE] "; read CREATE
  if [ "$CREATE" != none ]; then
    md ${CREATE:-$MAYBE}
  fi
fi

NET_DEVS="`devs $NET_DEVS`"
if test "$NET_DEVS"; then
  echo "Mach network devices found: $NET_DEVS"
else
  echo "No mach network devices found."
fi

NET_TRANS="`gt $SOCK/2`"
if test "$NET_TRANS"; then
  echo "PFINET translator present: $NET_TRANS"
  echo -n "Change PFINET translator? [n] "; read yn
  case "$yn" in
    [Yy]*)
      read dummy DEF_NET_ADDR DEF_NET_DEV <<EOF
$NET_TRANS
EOF
      ;;
    *)
      DEF_NET_DEV=skip;;
  esac
else
  DEF_NET_DEV="`devs -first $NET_DEVS`"
  DEF_NET_DEV="${DEF_NET_DEV:-none}"
  DEF_NET_ADDR="none"
fi

if [ "$DEF_NET_DEV" != skip ]; then
  echo -n "Network device: [$DEF_NET_DEV] "; read NET_DEV
  NET_DEV="${NET_DEV:-$DEF_NET_DEV}"
  if [ "$NET_DEV" != none ]; then
    echo -n "Network address: [$DEF_NET_ADDR] "; read NET_ADDR
    NET_DEV="${NET_DEV:-$DEF_NET_DEV}"
    if [ "$NET_ADDR" != none ]; then
      st $SOCK/2 /hurd/pfinet $NET_ADDR $NET_DEV
    else
      echo "PFINET translator not set."
    fi
  fi
fi