This file is indexed.

preinst is in likewise-open 6.1.0.406-0ubuntu5.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/sh

UPGRADEDIR4="/etc/likewise-open/4_1_upgrade"

# Not all daemons in the list were 'officially' released on Ubuntu. But it
# should not hurt to have them listed.
DAEMONS_TO_HALT="likewise-winbindd lwsmd lwregd netlogond lwiod dcerpcd eventlogd lsassd"

LOG=/var/log/likewise-open-install.log
TLOG=/tmp/likewise-open-install.txt

# Display to screen and log file with a blank line.
log()
{
    echo $@
    echo
    echo $@ >> $LOG
    echo >> $LOG
}

_log()
{
    echo $@
    echo $@ >> $LOG
}

# Display to file.
logfile()
{
    echo $@ >> $LOG
    echo >> $LOG
}

# Execute command.
# If successful, note in log file.
# If not successful, note on screen and log file.
exec_log()
{
    $@ > $TLOG 2>&1
    err=$?
    if [ $err -eq 0 ]; then
        echo "Success: $@" >> $LOG
        cat $TLOG >> $LOG
        echo >> $LOG
    else
        _log "Warning: $@ returned $err"
        _log `cat $TLOG`
        _log
    fi
    rm -f $TLOG > /dev/null 2>&1
    return $err
}

# Execute command.
# Log only to file.
exec_logfile()
{
    $@ > $TLOG 2>&1
    err=$?
    if [ $err -eq 0 ]; then
        echo "Success: $@" >> $LOG
    else
        echo "Warning: $@ returned $err" >> $LOG
    fi
    cat $TLOG >> $LOG
    echo >> $LOG
    rm -f $TLOG > /dev/null 2>&1
    return $err
}

# Execute command.
# If successful, note in log file.
# If not successful, note on screen and log file and then exit.
exec_log_exit()
{
    $@ > $TLOG 2>&1
    err=$?
    if [ $err -eq 0 ]; then
        echo "Success: $@" >> $LOG
        cat $TLOG >> $LOG
        echo >> $LOG
    else
        _log "Error: $@ returned $err"
        _log `cat $TLOG`
        _log
        rm -f $TLOG > /dev/null 2>&1
        exit 1
    fi
    rm -f $TLOG > /dev/null 2>&1
    return $err
}

rm_conffile() {
    CONFFILE="$1"

    if [ -e "$CONFFILE" ]; then
        md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
        old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status`"
        if [ "$md5sum" != "$old_md5sum" ]; then
            log "Obsolete conffile $CONFFILE has been modified by you."
            log "Saving as $CONFFILE.dpkg-bak ..."
            exec_log "mv -f $CONFFILE $CONFFILE.dpkg-bak"
        else
            log "Removing obsolete conffile $CONFFILE ..."
            exec_log "rm -f $CONFFILE"
        fi
    fi
}

save_4_1_files()
{
    if [ -f /etc/samba/lwiauthd.conf -a -f /etc/samba/secrets.tdb ]
    then
        exec_log_exit "mkdir -p ${UPGRADEDIR4}"
        exec_log_exit "cp /etc/samba/lwiauthd.conf ${UPGRADEDIR4}"
        exec_log_exit "cp /etc/samba/secrets.tdb ${UPGRADEDIR4}"
    fi
}

case "$1" in

    install)
    logfile "### likewise-open.preinst install"
    if [ -f /opt/likewise/data/VERSION ]; then
        log "Error: found /opt/likewise/data/VERSION"
        log "Please remove versions of Likewise Open and Likewise Enterprise not supported by Ubuntu before installing this package."
        exit 101
    fi

    #### AGGRESIVELY STOP LIKEWISE DAEMONS -- may be running from previous
    #### version that didn't kill them all
    # There are many user reports that indicate there is a
    # misbehaving daemon that interferes with installs/upgrades.
    logfile "Snapshot of processes before stopping daemons"
    exec_logfile "ps ax"

    # Shutdown old daemons nicely
    if [ -f /etc/init.d/lsassd ]
    then
        exec_log "/etc/init.d/lsassd stop"
    fi

    for daemon in $DAEMONS_TO_HALT
    do
        if [ -x /etc/init.d/$daemon ]; then
            exec_logfile "/etc/init.d/$daemon stop"
        fi
        exec_logfile "pkill -TERM -x $daemon"
        exec_logfile "pkill -KILL -x $daemon"
        exec_logfile "rm -f /var/run/$daemon.pid"
    done

    logfile "Snapshot of processes after stopping daemons"
    exec_logfile "ps ax"
    exit 0
    ;;

    abort-upgrade)
    logfile "### likewise-open.preinst abort-upgrade (doing nothing)"
    exit 0
    ;;

    upgrade)
    logfile "### likewise-open.preinst upgrade"

    if dpkg --compare-versions "$2" le "4.1.2982-0ubuntu3"; then

        exec_log "pam-auth-update --package --remove likewise-open"

        # Shutdown old daemons (if running)
        if [ -f /etc/init.d/likewise-open ]
        then
            exec_log "/etc/init.d/likewise-open stop"
        fi

        save_4_1_files

        if [ -x /usr/bin/domainjoin-cli ]; then
            exec_log "/usr/bin/domainjoin-cli leave"
        fi
    fi

    # remove obsolete conffiles from previous versions
    if dpkg --compare-versions "$2" lt-nl "5.4.0"; then
        # from 4.1
        rm_conffile /etc/samba/lwiauthd.conf
        rm_conffile /etc/security/pam_lwidentity.conf
        rm_conffile /etc/default/likewise-open
        rm_conffile /etc/init.d/likewise-open
        # from 5.0
        rm_conffile /etc/init.d/npcmuxd
    fi

    if dpkg --compare-versions "$2" lt-nl "6.0.0"; then
        # Shutdown old daemons nicely
        if [ -f /etc/init.d/lsassd ]
        then
            exec_log "/etc/init.d/lsassd stop"
        fi

        for daemon in $DAEMONS_TO_HALT
        do
            if [ -x /etc/init.d/$daemon ]; then
                exec_logfile "/etc/init.d/$daemon stop"
            fi
            exec_logfile "pkill -TERM -x $daemon"
            exec_logfile "pkill -KILL -x $daemon"
            exec_logfile "rm -f /var/run/$daemon.pid"
        done

        logfile "Snapshot of processes after stopping daemons"
        exec_logfile "ps ax"

    fi
    exit 0
    ;;

esac