File: netenv_setup

package info (click to toggle)
netenv 0.94.3-21
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 444 kB
  • ctags: 66
  • sloc: sh: 879; ansic: 136; makefile: 30
file content (103 lines) | stat: -rwxr-xr-x 3,320 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
#******************************************************************
#ident /etc/netenv/netenv_setup Time-stamp: <03/03/11 21:33:34 bav>
#******************************************************************
#                            Gerd Bavendiek  bav@epost.de  98-04-17
#
# If there is a variable NETENV_SCRIPT pointing to this executable
# file, netenv will source this script during boot. The following is
# what makes sense for me. Take it as a starting point.
#
# Let op: This will be run as root !
#------------------------------------------------------------------
###set -x
#---   Some functions   -------------------------------------------
print_action() 
{
   echo -e netenv: $* " ... \c"  
}
print_status() 
{
   if [ $? -eq 0 ]; then
      echo done
   else
      echo failed
   fi
}
#---   End of functions   -----------------------------------------

#---   Do everything needed when working at home   ----------------
PROFILE=$1
print_action Using PROFILE $PROFILE
echo

if [ "$PROFILE" = "default" ]; then
   print_action linking /dev/pilot
   rm -f /dev/pilot; ln -s /dev/ttyS0 /dev/pilot
   print_status
   print_action calling ptal-init start
   /usr/sbin/ptal-init start 
   print_status
else
   # When there is no docking station, start irattach appropiately and
   # link /dev/pilot to ircomm0.
   print_action running irattach
   /usr/sbin/irattach /dev/ttyS3 -s
   print_status
   print_status linking /dev/pilot
   rm -f /dev/pilot; ln -s /dev/ircomm0 /dev/pilot
   print_status
fi

#---   Set defaultgateway   ---------------------------------------
if [ ! -z "$GATEWAY" ]; then
   print_action Defaultgateway setting to $GATEWAY, see /etc/sysconfig/network/routes
   (
      echo "# routs autogenerated by netenv "`date`
      echo "default $GATEWAY - -"
   ) > /etc/sysconfig/network/routes
   print_status done
fi

#---   Set up /etc/resolv.conf   ----------------------------------
if [ ! -z "$DNS_1" ]; then 
    rm -f /etc/resolv.conf
    (
    echo "# resolv.conf autogenerated by netenv "`date`
    if [ ! -z "$DOMAIN" ]; then echo domain $DOMAIN; fi
    if [ ! -z "$SEARCH" ]; then echo search $SEARCH; fi
    echo nameserver $DNS_1
    if [ ! -z "$DNS_2" ]; then echo nameserver $DNS_2; fi
    ) > /etc/resolv.conf.netenv
    chmod 644 /etc/resolv.conf.netenv
    print_action setting up new /etc/resolv.conf
    ln -s /etc/resolv.conf.netenv /etc/resolv.conf
    print_status
fi

#---   Edit /etc/hosts   -------------------------------------------

if [ -n "$NETENV_HOST_ENTRIES" ]; then
   if egrep '^# netenv hosts begin$' /etc/hosts > /dev/null 2>&1; then
      (
      awk 'NR==1,/^# netenv hosts begin$/' /etc/hosts
      echo $NETENV_HOST_ENTRIES | awk -F':' '{ for ( j=1; j<=NF; j++ ) print $j }'
      awk '/^# netenv hosts end$/,/*/' /etc/hosts
      ) > /etc/hosts.netenv
      print_action modifying /etc/hosts
      mv -f /etc/hosts.netenv /etc/hosts
      chmod 644 /etc/hosts
      print_status
   fi
else
   if egrep '^# netenv hosts begin$' /etc/hosts > /dev/null 2>&1; then
      (
      awk 'NR==1,/^# netenv hosts begin$/' /etc/hosts
      awk '/^# netenv hosts end$/,/*/' /etc/hosts
      ) > /etc/hosts.netenv
      print_action cleaning up /etc/hosts
      mv -f /etc/hosts.netenv /etc/hosts
      chmod 644 /etc/hosts
      print_status 
   fi
fi