#!/bin/bash
case "$1" in
    configure)
	  if [ -d "/etc/apt/sources.list.d_old_by_installer" ];then
        # 不存在sources.list.d目录的场景
        if [ ! -d "/etc/apt/sources.list.d" ] ;then
            mv /etc/apt/sources.list.d_old_by_installer /etc/apt/sources.list.d || true
            exit 0
        fi
        # 存在sources.list.d目录的场景
        if [ ! -f "/etc/apt/sources.list.d/appstore.list" ];then
            cp /etc/apt/sources.list.d_old_by_installer/appstore.list /etc/apt/sources.list.d/ || true
        fi
        if [ ! -f "/etc/apt/sources.list.d/security.list" ];then
            cp /etc/apt/sources.list.d_old_by_installer/security.list /etc/apt/sources.list.d/ || true
        fi
        if [ ! -f "/etc/apt/sources.list.d/driver.list" ];then
            cp /etc/apt/sources.list.d_old_by_installer/driver.list /etc/apt/sources.list.d/ || true
        fi
        if [ ! -f "/etc/apt/sources.list.d/printer.list" ];then
            cp /etc/apt/sources.list.d_old_by_installer/printer.list /etc/apt/sources.list.d/ || true
        fi
        rm /etc/apt/sources.list.d_old_by_installer -rf || true
        exit 0
	  fi
    ;;
    abort-upgrade|abort-remove|abort-deconfigure)
    ;;
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac
exit 0
