File: postinst

package info (click to toggle)
phalanx 12-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 664 kB
  • ctags: 504
  • sloc: ansic: 6,094; makefile: 76; sh: 50
file content (46 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -e

LEARNFILE=/var/lib/games/phalanx.learn

if ! test -f $LEARNFILE ; then
  cat <<EOF
Learning file not found.
Phalanx can use learning file for improving its strength.
Its size is determined by number of 8 B hashing items.

EOF
  ANSWERED=0
  DEFAULT=32768
  until [ "$ANSWERED" -eq 1 ]; do
    echo -n "Number of items in the learning file [default $DEFAULT] "
    read ITEMS
    if [ -n "$ITEMS" ]; then
      OLDTEST=""
      TEST="$ITEMS"
      while [ "$TEST" != "$OLDTEST" ]; do
        OLDTEST="$TEST"
	TEST=${TEST##[0-9]}
      done
      if [ -z "$TEST" ]; then
	if [ ${#ITEMS} -gt 6 ] || [ "$ITEMS" -lt 1 ]; then
	  echo "Please use number in the range 1-999999."
	else
	  ANSWERED=1
	fi
      fi
    else
      ITEMS=$DEFAULT
      ANSWERED=1
    fi
    
  done
  echo "Creating learning file of the size $((ITEMS*8)) B ..."
  dd if=/dev/zero of="$LEARNFILE" bs=8 count=$ITEMS >/dev/null
  chown root.games "$LEARNFILE"
  chmod 664 "$LEARNFILE"
fi

if test -x /usr/bin/update-menus; then update-menus; fi