source: src-sh/pc-thinclient/resources/scripts/tcsinstall.sh @ 47c920b

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 47c920b was 47c920b, checked in by Kris Moore <kris@…>, 6 months ago

Update to pc-thinclient:

Add a method of listing MAC addresses in a blacklist file:

/installscripts/macblacklist

If a system with a MAC address in this file connects, the client
will display an error and refuse to continue.

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#!/bin/sh
2# Script to provide menu-driven installation of systems
3
4do_installwiz() {
5
6  installChoices=""
7  for i in `ls /installscripts/*.cfg`
8  do
9     installChoices="$installChoices $i $i"
10  done
11
12  dialog --menu 'Select install script' 15 55 10 'back' 'Go back' ${installChoices} 2>/tmp/ans
13  ANS=`cat /tmp/ans`
14  case $ANS in
15       back) return ;;
16        *) echo "Ready to begin installation using command:"
17           echo "/usr/local/sbin/pc-sysinstall -c /installscripts/${ANS}" 
18           echo -e "Continue? (y/n) \c"
19           read tmp
20           if [ "$tmp" = "y" -o "$tmp" = "Y" ] ; then
21              /usr/local/sbin/pc-sysinstall -c /installscripts/${ANS}
22           fi
23           ;;
24  esac
25}
26
27# Function which determines if a nic is active / up
28is_nic_active()
29{
30  ifconfig ${1} | grep -q "status: active" 2>/dev/null
31  if [ $? -eq 0 ] ; then
32    return 0
33  else
34    return 1
35  fi
36}
37
38# Find the active nic
39get_active_nic()
40{
41  for i in $(ifconfig -l); do
42    case "${i%%[0-9]*}" in
43      lo|fwe|fwip|plip|pfsync|pflog|tun)
44      continue
45      ;;
46    esac
47    is_nic_active "${i}"
48    if [ $? -eq 0 ] ; then
49       echo "$i"
50       return 0
51    fi
52  done
53  return 1
54}
55
56# Get the mac address of a target NIC
57get_nic_mac()
58{
59  FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
60  echo $FOUNDMAC
61}
62
63# Check for MAC address config file
64NIC=$(get_active_nic)
65MAC=$(get_nic_mac "$NIC")
66
67# Check if the mac address is in the blacklist
68# Create this file with a line-by-line list of MACs to blacklist
69if [ -e "/installscripts/macblacklist" ] ; then
70   grep -q "^${MAC}" /installscripts/macblacklist
71   if [ $? -eq 0 ] ; then
72      echo "ERROR: This MAC address listed in the /installscripts/macblacklist file!"
73      echo "To install this system, remove the address: ${MAC}"
74      echo ""
75      echo "Installation HALTED!"
76      echo "[Press Enter to shutdown]"
77      shutdown -p now
78   fi
79fi
80
81# Detect auto-install scripts
82ASCRIPT=""
83if [ -e "/installscripts/unattended.cfg" ] ; then
84   ASCRIPT="/installscripts/unattended.cfg"
85fi
86if [ -e "/installscripts/${MAC}.cfg" ] ; then
87   ASCRIPT="/installscripts/${MAC}.cfg"
88fi
89
90# Are we doing an automated install?
91if [ -n "${ASCRIPT}" ] ; then
92
93  echo "Preparing to install using: ${ASCRIPT}"
94  echo "Will automatically continue in 30 seconds."
95  echo "Press ENTER to cancel"
96
97  read -t30s ans
98  if [ $? -eq 1 ] ; then
99    pc-sysinstall -c ${ASCRIPT}
100    if [ $? -eq 0 ] ; then
101      echo "Install finished! Shutting down system now!"
102      halt -p
103      exit 0
104    fi
105
106    echo "Install failed! Full log of installation: /tmp/.pc-sysinstall/pc-sysinstall.log" 
107    echo "Press ENTER to continue"
108    read tmp
109  fi
110fi
111
112# Run the interactive menu
113while :
114do
115  dialog --menu 'Select install option' 15 55 10 'install' 'Start install wizard' 'shell' 'Run emergency shell' 'close' 'Close and Reboot' 2>/tmp/ans
116  ANS=`cat /tmp/ans`
117  case $ANS in
118   install) do_installwiz
119            echo "[Press Enter to Continue]"
120            read tmp
121            ;;
122     shell) /bin/csh
123            echo "[Press Enter to Continue]"
124            read tmp
125            ;;
126     close) reboot
127            exit
128            ;;
129         *) ;;
130   esac
131done
132
133
Note: See TracBrowser for help on using the repository browser.