#!/bin/bash

# 检查是否提供了版本号参数
#if [ $# -eq 0 ]; then
#    echo "错误：请提供版本号参数"
#    echo "用法: $0 <版本号>"
#    exit 1
#fi

VERSION=2.1.3
sh install.sh

thispwd=$(pwd)
#cd /home/pi/

DebDirectory=DebpackTowerSif

mkdir $DebDirectory
cd $DebDirectory/

mkdir -p ./home/pi/bin
cd home/pi/bin/
cp /home/pi/bin/* .

cd ../../..
mkdir DEBIAN
cd DEBIAN
#echo "Package: TowerSif
#Version: $VERSION
#Architecture: armhf
#Maintainer: rlx, tc
#Description: test" > control
cp ../../dpkg/* ./
echo "Version:${VERSION}"
echo "Version:${VERSION}" >> ./control
echo "echo \"V${VERSION}\" > /home/data/version" >> ./postinst
chmod +x ./post*
chmod +x ./control
cd ../
#复制root文件
mkdir -p ./root
cp ../root/* ./root/
chmod +x ./root/*.sh
#复制html文件
mkdir -p ./var/www/html/
cp -r ../html/* ./var/www/html/
chmod +x ./var/www/html/php/*.sh
mkdir -p ./home/data/
cp ../ChangeLog.md ./home/data/ChangeLog.md



#cd /home/pi/
cd $thispwd
sudo dpkg -b $DebDirectory TowerSif_V${VERSION}.deb
mkdir -p DEB
cp TowerSif_V${VERSION}.deb DEB/
rm -r $DebDirectory

#sudo dpkg -r TowerSif

