#!/bin/sh


`which pkg_add > /dev/null`
if [ $? -ne 0 ];then
    rm -f /usr/local/etc/pkg/repos/cloud_storage-repo.conf
    pkg info
    if [ $? -eq 0 ];then
        mkdir -p /usr/local/etc/pkg
        mkdir -p /usr/local/etc/pkg/repos

		OS=`uname -r | cut -c1-2 | bc`
		if [ $OS -eq 12 ];then
			cat <<EOF > /usr/local/etc/pkg/repos/cloud_storage-repo.conf
cloud_storage: {
 URL:http://skbb:skbb@svc1-pkg.solbox.com:21721/FB12
 ENABLED: true
 MIRROR_TYPE: none
}
EOF
		else
			cat <<EOF > /usr/local/etc/pkg/repos/cloud_storage-repo.conf
cloud_storage: {
 URL:http://skbb:skbb@svc1-pkg.solbox.com:21721
 ENABLED: true
 MIRROR_TYPE: none
}
EOF
		fi
    fi
else 
    ROOT_RPOFILE="/root/.cshrc"
    PKG_SITE="http://skbb:skbb@svc1-pkg.solbox.com:21721/"
    
    grep "PACKAGESITE" $ROOT_RPOFILE 2>&1 > /dev/null
    if [ $? -ne 0 ]; then
        echo "" >> $ROOT_RPOFILE
        echo "#### FHS package site #### " >> $ROOT_RPOFILE
        echo "setenv PACKAGESITE $PKG_SITE" >> $ROOT_RPOFILE
        echo "#### FHS package site #### " >> $ROOT_RPOFILE
        exec  "$SHELL"
    fi
fi
