File: preinst

package info (click to toggle)
wanpipe 2.1.1-2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,348 kB
  • ctags: 713
  • sloc: ansic: 6,182; sh: 2,522; cpp: 2,488; makefile: 116
file content (39 lines) | stat: -rwxr-xr-x 898 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
#!/usr/bin/ksh
#
# wanpipe preinst
########################################
set -o errexit
OLD_CONF_FILES=FALSE

if [[ -n "$2" ]] ; then
   VERS=$2
   UPSTREAM_REL=${VERS%%-*} 
   DEBIAN_REL=${VERS##*-}

   if [ "$UPSTREAM_REL" = "2.0.1" ]
   then
      OLD_CONF_FILES=TRUE
   elif [ "$UPSTREAM_REL" = "2.0.3" ]
   then
      if (( DEBIAN_REL < 3 ))
      then
         OLD_CONF_FILES=TRUE
      fi
   fi   
fi

if [[ "$1" = "upgrade" && "$OLD_CONF_FILES" = "TRUE" ]] ||
   [[ "$1" = "install" && "$OLD_CONF_FILES" = "TRUE" ]]
then
   NEW_CONFDIR=/etc/wanpipe
   mkdir -p /etc/wanpipe/interfaces
   [ -f /etc/router.conf ] && cp -p /etc/router.conf /etc/wanpipe/router.conf
   [ -f /etc/router.cf ] && cp -p /etc/router.cf /etc/wanpipe/router.cf
   for file in $(ls /var/wanpipe)
   do
      cfile=/var/wanpipe/${file}
      [ -f $cfile ] && cp -p $cfile /etc/wanpipe/interfaces
   done
fi

exit 0