obs-api.postrm 2.11 KB
Newer Older
1
#!/bin/sh -e
2 3 4 5 6 7 8 9 10 11 12

set -e
#set -x

if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
fi
if [ -f /usr/share/dbconfig-common/dpkg/postrm.mysql ]; then
    . /usr/share/dbconfig-common/dpkg/postrm.mysql
    dbc_go obs-api $@
fi
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

pathfind() {
    OLDIFS="$IFS"
    IFS=:
    for p in $PATH; do
        if [ -x "$p/$*" ]; then
            IFS="$OLDIFS"
            return 0
        fi
    done
    IFS="$OLDIFS"
    return 1
}

reload_apache()
{
    if apache2ctl configtest 2>/dev/null; then
        if `pathfind defoma-font`; then
            invoke-rc.d apache2 $1 3>/dev/null || true
        else
            /etc/init.d/apache2 $1 3>/dev/null || true
        fi
    else
        echo "Your Apache 2 configuration is broken, so we're not restarting it for you."
    fi
}

40
if [ "$1" = "purge" ]; then
41
    # ucf follows the symlink under /etc
42
    #rm -f /etc/obs/api/config/database.yml
43
    if which ucf >/dev/null 2>&1; then
44
	ucf --purge /etc/obs/api/config/database.yml
45
    fi
46
    rm -rf /etc/obs/api
47 48
    rm -rf /usr/share/obs/api
    rm -rf /usr/share/obs/overview
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    rm -rf /var/cache/obs
    # Remove log files
    rm -f /var/log/obs/apache_access_log*
    rm -f /var/log/obs/apache_error_log*
    rm -f /var/log/obs/access.log*
    rm -f /var/log/obs/backend_access.log*
    rm -f /var/log/obs/db_setup.log*
    rm -f /var/log/obs/delayed_job.log*
    rm -f /var/log/obs/error.log*
    rm -f /var/log/obs/lastevents.access.log*
    rm -f /var/log/obs/production.log*
    rm -f /var/log/obs/production.searchd.log*
    rm -f /var/log/obs/production.searchd.query.log*
    rm -f /var/log/obs/production.sphinx.pid
    rm -f /var/log/obs/clockworkd.clock.output*
    rmdir /var/log/obs 2> /dev/null || true
65 66 67 68 69
    # Test whether a2dissite is available (and thus also apache2ctl).
    if `pathfind a2dissite`; then
    # Disable the obs site if not already disabled
        a2dissite obs.conf	> /dev/null || true
    fi
70 71 72
    # Delete obsapi user and group
    deluser --system --quiet obsapi || true
    delgroup --system --quiet obsapi || true
73 74
    # Restart Apache to really unload obs.conf
    reload_apache restart
75 76 77
fi

#DEBHELPER#