/usr/sbin/decnetconf is in dnet-common 2.65.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/sh
#
# Configure /etc/decnet.conf
#
# Use a temp file
if [ -x /bin/tempfile ]
then
CONFFILE="`tempfile`"
else
CONFFILE="/tmp/decnet.conf$$"
fi
REALFILE=/etc/decnet.conf
if [ -f "$REALFILE" ]
then
echo "The file $REALFILE already exists. Not overwriting it"
exit 0
fi
control_c()
{
rm -f $CONFFILE
echo
echo "DECnet configuration abandoned"
exit 1
}
trap "control_c" SIGINT
# Validate the DECnet node address
validate_addr()
{
if [ -z "$1" ]
then
return 0
fi
if [ `expr $1 : '[0-9]*\.[0-9]*'` -ne "`expr length $1`" ]
then
echo "The node address nust be in the format area.node"
return 0
fi
area=`echo $1|cut -d. -f1`
node=`echo $1|cut -d. -f2`
if [ "$area" -le 0 -o "$area" -ge 64 ]
then
echo 'Area must be between 1 and 63 inclusive'
fi
if [ "$node" -le 0 -o "$node" -ge 1024 ]
then
echo 'Node must be between 1 and 1024 inclusive'
fi
if [ "$node" -gt 0 -a "$node" -lt 1024 -a "$area" -gt 0 -a "$area" -lt 64 ]
then
return 1
fi
return 0
}
# Just check the name is 6 characters or less.
validate_name()
{
if [ "`expr length $1`" -gt 6 ]
then
echo "DECnet node names must be less than six characaters long"
return 0
else
return 1
fi
}
# Check the interface name is in /proc/net/dev
validate_iface()
{
grep -q "$1:" /proc/net/dev
if [ $? = 0 ]
then
return 1
else
echo "Can't find device $1 on your system. Choose one of the following:"
awk '/.*:/ { print substr($1,0,index($1,":")-1) }' < /proc/net/dev
return 0
fi
}
echo
echo "DECnet configuration."
echo "Press control/C to cancel."
echo
#
# Get the current host (executor) information
#
if [ -f $REALFILE ]
then
def_addr="`awk '/^executor/ { print $2 }' <$REALFILE`"
def_name="`awk '/^executor/ { print $4 }' <$REALFILE`"
def_iface="`awk '/^executor/ { print $6 }' <$REALFILE`"
else
def_name=`hostname -s|cut -b1-6`
def_addr="1.1"
def_iface="eth0"
fi
addr_valid=0
name_valid=0
iface_valid=0
while [ $addr_valid = "0" ]
do
echo -n "Enter your DECnet node address [$def_addr] : "
read addr
if [ -z "$addr" ]
then
addr=$def_addr
fi
validate_addr $addr
addr_valid=$?
done
while [ $name_valid = "0" ]
do
echo -n "Enter your DECnet node name [$def_name] : "
read name
if [ -z "$name" ]
then
name=$def_name
fi
validate_name $name
name_valid=$?
done
while [ $iface_valid = "0" ]
do
echo -n "Enter your Ethernet interface name [$def_iface] : "
read interface
if [ -z "$interface" ]
then
interface=$def_iface
fi
validate_iface $interface
iface_valid=$?
done
#
# Start generating the file with our local node information in it.
#
cat >$CONFFILE <<EOF
#
# DECnet hosts file
#
#Node Node Name Node Line Line
#Type Address Tag Name Tag Device
#----- ------- ----- ----- ----- ------
EOF
printf >>$CONFFILE "executor %-7s name %-6s line %s\n" $addr $name $interface
#-----------------------------------------------------------------------------
#
# Now add some nodes
#
echo
echo 'You may now add some other DECnet nodes on your network. When you have'
echo 'finished, press [ENTER] when prompted for the node address'
echo
while [ 1 ]
do
addr_valid=0
name_valid=0
while [ $addr_valid = "0" ]
do
echo -n "Enter the node's address: area.node (eg 1.1) : "
read addr
if [ -z "$addr" ]
then
break 2
fi
validate_addr $addr
addr_valid=$?
done
while [ $name_valid = "0" ]
do
echo -n "Enter it's node name : "
read name
validate_name $name
name_valid=$?
done
printf >>$CONFFILE "node %-7s name %-6s\n" $addr $name
echo
done
#
# Confirm copying the file to /etc
#
echo
cat $CONFFILE
echo
echo "This is your DECnet configuration file. Press [ENTER] to make it"
echo "live or Control/C to exit"
read dummy
cp $CONFFILE $REALFILE
if [ $? -ne 0 ]
then
echo
echo "Could not copy file to $REALFILE, you must be root to do this."
echo "This script will exit now, leaving your new file saved as"
echo "$CONFFILE"
echo
echo "su to root and copy this file to $REALFILE to complete installation"
echo
exit
fi
rm -f $CONFFILE
exit
|