#!/bin/bash

echo "96resetup-sourcelist start"
fifoName="96resetup-sourcelist-fifo"
if [ ! -e ${fifoName} ]; then
    mkfifo -m 666 ${fifoName}
fi
exec 6<>${fifoName}
echo "30" >&6

sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list

DISTRIB_RELEASE=$(grep -r PRETTY_NAME= /etc/os-release)
DISTRIB_RELEASE=${DISTRIB_RELEASE#*=}

case ${DISTRIB_RELEASE} in
    '"Kylin V10 SP1"')
        echo "
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.1 main restricted universe multiverse
deb http://archive.kylinos.cn/kylin/partner 10.1 main" >/etc/apt/sources.list
        ;;
    '"Kylin V10"')
        echo "
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.0 main restricted universe multiverse
" >/etc/apt/sources.list
        ;;
    '"openKylin 2.0"')
        echo "
deb http://archive.build.openkylin.top/openkylin/ nile main cross pty
" >/etc/apt/sources.list
        ;;        
    *)
	rm -f /etc/apt/sources.list.d/kylin.list ||true
        echo "
deb http://archive.build.openkylin.top/openkylin/ yangtze main cross pty
deb http://archive.build.openkylin.top/openkylin/ yangtze-security main cross pty
deb http://archive.build.openkylin.top/openkylin/ yangtze-updates main cross pty
" >/etc/apt/sources.list
        ;;
esac


echo "100" >&6
exec 6<&-
rm -f ${fifoName}
echo "96resetup-sourcelist success"
