#!/bin/bash

DepPkgDir=/tmp/omc-dep-pkg
lines=22 #这个值是指这个脚本的行数加1，指向程序所在开始行
tail +$lines $0 >/tmp/omc-dep-pkg.tar.gz # 利用tail命令把脚本指定行出到文件，$0表示脚本本身名称，$0是环境变量，这个命令用来把从$lines开始的内容写入一个/tmp目录的tar.gz文件里。
echo -n "Decompressing omc depend package ..."
echo "done"
tar xvfz /tmp/omc-dep-pkg.tar.gz -C /tmp 1>/dev/null
if [ ! -e ${DepPkgDir} ]; then
        echo "${DepPkgDir}: Not such file or directory"
        exit 1
fi
echo -n "Installing omc depend package ..."
for pkgdir in ${DepPkgDir}/*; do
        #echo "Installing ${pkgdir} depend package ..."
        cd ${pkgdir};
        dpkg -i --ignore-depends *.deb 1>/tmp/${pkgdir}.log 2>&1;
done
echo "done"
rm -rf /tmp/omc-dep-pkg*
exit 0