Project

General

Profile

Download (2.14 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
# postrm script for cdmserver
3
#
4
# see: dh_installdeb(1)
5

    
6
set -e
7

    
8
#
9
# variables
10
#
11
CDM_HOME="/opt/cdmserver/"
12
CDM_CONFIG_TEMPLATE="/opt/cdmserver/templates/.cdmLibrary"
13
CDM_LOG="/var/log/cdmserver/"
14

    
15
INIT_SCRIPT="cdmserver"
16
ETC_CDMSERVER="/etc/cdmserver/"
17

    
18
CDM_USER=cdm
19
CDM_GROUP=cdm
20

    
21
CDM_USER_HOME=$CDM_HOME
22

    
23
#
24
# functions
25
#
26
userExist(){
27
    grep $1 /etc/passwd > /dev/null
28
    [ $? -eq 0 ] && return $TRUE || return $FALSE
29
}
30

    
31
groupExist(){
32
    grep $1 /etc/group > /dev/null
33
    [ $? -eq 0 ] && return $TRUE || return $FALSE
34
}
35

    
36

    
37
# summary of how this script can be called:
38
#        * <postrm> `remove'
39
#        * <postrm> `purge'
40
#        * <old-postrm> `upgrade' <new-version>
41
#        * <new-postrm> `failed-upgrade' <old-version>
42
#        * <new-postrm> `abort-install'
43
#        * <new-postrm> `abort-install' <old-version>
44
#        * <new-postrm> `abort-upgrade' <old-version>
45
#        * <disappearer's-postrm> `disappear' <overwriter>
46
#          <overwriter-version>
47
# for details, see http://www.debian.org/doc/debian-policy/ or
48
# the debian-policy package
49

    
50
do_remove(){
51

    
52
    echo "... do_remove()"
53

    
54
    #stopping the server
55
    if [ -x /etc/init.d/$INIT_SCRIPT ]
56
    then
57
      echo "stopping server ..."
58
      /etc/init.d/$INIT_SCRIPT stop
59
    fi
60

    
61
    echo "now removing server from rc.d ..."
62
    update-rc.d -f $INIT_SCRIPT remove
63

    
64
    rm -f $CDM_USER_HOME.cdmLibrary
65

    
66
    return 0
67
}
68

    
69
do_purge(){
70

    
71
    echo "... do_purge()"
72

    
73
    # removing the user and group
74
    if ( userExist $CDM_USER  )
75
    then
76
      userdel $CDM_USER
77
    fi
78

    
79
    if ( groupExist $CDM_GROUP  )
80
    then
81
      groupdel $CDM_GROUP
82
    fi
83

    
84
    #
85
    # remove log files
86
    #
87
    rm -rf $CDM_LOG
88

    
89
    #
90
    # remove all configuration files
91
    #
92
    if [ -d $ETC_CDMSERVER ]
93
    then
94
      rm -r $ETC_CDMSERVER
95
    fi
96

    
97
    return 0
98
}
99

    
100
case "$1" in
101
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
102
        do_remove
103
    ;;
104
    purge)
105
        do_purge
106
    ;;
107
    *)
108
        echo "postrm called with unknown argument \`$1'" >&2
109
        exit 1
110
    ;;
111
esac
112

    
113
# dh_installdeb will replace this with shell code automatically
114
# generated by other debhelper scripts.
115

    
116
#DEBHELPER#
117

    
118
exit 0
119

    
120

    
(6-6/6)