#!/bin/sh

set -e

#if [ "$1" = "configure" ] ; then
#    PKILL=$(which pkill)
#    PGREP=$(which pgrep)
#
#    if [ -f '/usr/share/ubuntu-kylin-software-center/.uksc_self_upgrade' ] ; then
#        echo 'install by uksc'
#        rm /usr/share/ubuntu-kylin-software-center/.uksc_self_upgrade
#    else
#        echo 'install by apt'
#        FLAG=`$PGREP -f ubuntu-kylin-software-center.py`
#        if [ -n "$FLAG" ] ; then
#            $PKILL -f -9 ubuntu-kylin-software-center.py
#        fi

#        FLAG=`$PGREP -f ubuntu-kylin-software-center-daemon`
#        if [ -n "$FLAG" ] ; then
#            $PKILL -f -9 ubuntu-kylin-software-center-daemon
#        fi
#    fi
#fi

# Clean up the old database
for user in `ls /home/`
do
    path="/home/"$user"/.cache/uksc/uksc.db"
    if [ -f "$path" ]; then
        rm $path*
    fi
done

autostar="/etc/xdg/autostart/ubuntu-kylin-software-center-autostart.desktop"
if [ -f "$autostar" ]; then
    rm $autostar
fi

chmod 775 /usr/lib/python3/dist-packages/ubuntu_kylin_software_center_daemon/start_systemdbus.py
chmod 777 /usr/share/ubuntu-kylin-software-center/backend/service/password.txt

#DEBHELPER#

exit 0
