File: postinst

package info (click to toggle)
ud 0.7.1-13
  • links: PTS
  • area: main
  • in suites: woody
  • size: 276 kB
  • ctags: 38
  • sloc: ansic: 704; sh: 522; makefile: 69
file content (90 lines) | stat: -rw-r--r-- 1,761 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
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
#!/bin/bash

set -e

#
# Force update of init.d/ud
#

if [ "`grep 'ARGS=.[^c]' /etc/init.d/ud`" ]; then
  perl -ne 'if (/ARGS="(.*)"/) { open F, ">/etc/ud/config"; print F $1; }' /etc/init.d/ud
  perl -pi -e 's#ARGS="(.*)"#ARGS=`cat /etc/ud/config`#' /etc/init.d/ud
fi

#
# Move record file to new location
#

if [ -f /etc/uptime.record ]; then
  if [ ! -d /var/lib/misc ]; then
    mkdir /var/lib/misc
  fi
  mv /etc/uptime.record /var/lib/misc/
fi

#
# Move template file to new location
#

if [ -f /etc/template.ud ]; then
  if [ ! -d /etc/ud ]; then
    mkdir /etc/ud
  fi
  mv /etc/template.ud /etc/ud/template.html
fi

#
# Create empty record file
#

if [ ! -f /var/lib/misc/uptime.record ]; then
  if [ ! -d /var/lib/misc ]; then
    mkdir /var/lib/misc
  fi
  cat >/var/lib/misc/uptime.record <<EOF
0.7.1
0.000000

0.000000

0.000000

EOF
  chmod 0644 /var/lib/misc/uptime.record
fi

#
# Upgrade old record file
#

if [ "$1" = "configure" ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 0.7.1; then
  cat <<EOF
The uptime.record file format has been changed. Your 
/var/lib/misc/uptime.record will be updated. The old version of this file is 
backed up as /var/lib/misc/uptime.record.old.

If you have other record files you can use ud-update(8) to update them.
EOF

  if [ -f /var/lib/misc/uptime.record.old ]; then
    read -p "/var/lib/misc/uptime.record.old exists. Ok to remove? [yN]: " AKEY
    case "$AKEY" in
      y|Y)
        rm -f /var/lib/misc/uptime.record.old
      ;;
      *)
        echo "Please move /var/lib/misc/uptime.record.old out of the way and reinstall ud."
        exit 1
      ;;
    esac
  fi
  
  /usr/sbin/ud-update /var/lib/misc/uptime.record
fi

#DEBHELPER#

echo
echo "Configure UD by using /usr/sbin/udconfig"
echo