forked from alexreinert/piVCCU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_pivccu3.sh
executable file
·107 lines (72 loc) · 3.76 KB
/
create_pivccu3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
CCU_VERSION=3.67.10
CCU_DOWNLOAD_SPLASH_URL="https://www.eq-3.de/service/downloads.html"
CCU_DOWNLOAD_URL="https://www.eq-3.de/downloads/software/firmware/ccu3-firmware/ccu3-$CCU_VERSION.tgz"
CCU_DOWNLOAD_URL="https://homematic-ip.com/sites/default/files/downloads/ccu3-$CCU_VERSION.tgz"
PKG_BUILD=78
CURRENT_DIR=$(pwd)
WORK_DIR=$(mktemp -d)
PKG_VERSION=$CCU_VERSION-$PKG_BUILD
TARGET_DIR=$WORK_DIR/pivccu3-$PKG_VERSION
CNT_ROOT=$TARGET_DIR/var/lib/piVCCU3
CNT_ROOTFS=$CNT_ROOT/rootfs
cd $WORK_DIR
# download firmware image
wget -O /dev/null --save-cookies=cookies.txt --keep-session-cookies $CCU_DOWNLOAD_SPLASH_URL
wget -O ccu3.tar.gz --load-cookies=cookies.txt --referer=$CCU_DOWNLOAD_SPLASH_URL $CCU_DOWNLOAD_URL
tar xzf ccu3.tar.gz
gunzip rootfs.ext4.gz
mkdir $WORK_DIR/image
fuse2fs -o ro,fakeroot rootfs.ext4 $WORK_DIR/image
mkdir -p $CNT_ROOTFS
cp -p -P -R $WORK_DIR/image/* $CNT_ROOTFS
umount $WORK_DIR/image
cd $CNT_ROOTFS
patch -E -l -p1 < $CURRENT_DIR/pivccu/firmware3.patch
sed -i "s/@@@pivccu_version@@@/$PKG_VERSION/g" $CNT_ROOTFS/www/config/cp_maintenance.cgi
sed -i "s/@@@pivccu_version@@@/$PKG_VERSION/g" $CNT_ROOTFS/www/webui/webui.js
mkdir -p $CNT_ROOTFS/firmware/HM-MOD-UART
wget -q -O $CNT_ROOTFS/firmware/HM-MOD-UART/dualcopro_si1002_update_blhm.eq3 https://raw.githubusercontent.com/eq-3/occu/abc3d4c8ee7d0ba090407b6b4431aeca42aeb014/firmware/HM-MOD-UART/dualcopro_si1002_update_blhm.eq3
wget -q -O $CNT_ROOTFS/firmware/HM-MOD-UART/fwmap https://raw.githubusercontent.com/eq-3/occu/abc3d4c8ee7d0ba090407b6b4431aeca42aeb014/firmware/HM-MOD-UART/fwmap
mkdir -p $CNT_ROOTFS/firmware/HmIP-RFUSB
wget -q -P $CNT_ROOTFS/firmware/HmIP-RFUSB https://raw.githubusercontent.com/eq-3/occu/77f5f55eb456e9974355d645e2005a1d355063af/firmware/HmIP-RFUSB/dualcopro_update_blhmip-4.4.18.eq3
mkdir -p $CNT_ROOTFS/etc/piVCCU3
cp -p $CURRENT_DIR/pivccu/container3/* $CNT_ROOTFS/etc/piVCCU3
mkdir -p $CNT_ROOT/userfs
mkdir -p $TARGET_DIR/etc/piVCCU3
cp -p $CURRENT_DIR/pivccu/host3/lxc.config $TARGET_DIR/etc/piVCCU3
mkdir -p $TARGET_DIR/etc/default
cp -p $CURRENT_DIR/pivccu/host3/default.config $TARGET_DIR/etc/default/pivccu3
mkdir -p $TARGET_DIR/etc/udev/rules.d
cp -p $CURRENT_DIR/pivccu/host3/*.rules $TARGET_DIR/etc/udev/rules.d
cp -p $CURRENT_DIR/pivccu/host3/*.sh $CNT_ROOT
cp -p $CURRENT_DIR/pivccu/host3/*.inc $CNT_ROOT
mkdir -p $TARGET_DIR/lib/systemd/system/
cp -p $CURRENT_DIR/pivccu/host3/*.service $TARGET_DIR/lib/systemd/system/
mkdir -p $TARGET_DIR/DEBIAN
cp -p $CURRENT_DIR/package/pivccu3/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
sed -i "s/{CCU_VERSION}/$CCU_VERSION/g" $file
sed -i "s/{PKG_ARCH}/armhf/g" $file
done
cd $WORK_DIR
dpkg-deb --build -Zxz pivccu3-$PKG_VERSION
cp pivccu3-$PKG_VERSION.deb $CURRENT_DIR/pivccu3-$PKG_VERSION-armhf.deb
wget -O openjdk-8-jre.deb http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jre_8u332-ga-1~deb9u1_armhf.deb
wget -O openjdk-8-jre-headless.deb http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jre-headless_8u332-ga-1~deb9u1_armhf.deb
dpkg-deb -x openjdk-8-jre.deb .
dpkg-deb -x openjdk-8-jre-headless.deb .
mv usr/lib/jvm/java-8-openjdk-armhf/jre $CNT_ROOTFS/opt/openjdk
rm -f $CNT_ROOTFS/opt/java
ln -s /opt/openjdk $CNT_ROOTFS/opt/java
rm -rf $TARGET_DIR/DEBIAN/*
cp -p $CURRENT_DIR/package/pivccu3/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
sed -i "s/{CCU_VERSION}/$CCU_VERSION/g" $file
sed -i "s/{PKG_ARCH}/arm64/g" $file
done
dpkg-deb --build -Zxz pivccu3-$PKG_VERSION
cp pivccu3-$PKG_VERSION.deb $CURRENT_DIR/pivccu3-$PKG_VERSION-arm64.deb
echo "Please clean-up the work dir temp folder $WORK_DIR, e.g. by doing rm -R $WORK_DIR"