Browse Source

ajout de la gestion de la mise à jour

Emmanuel Garette 5 months ago
parent
commit
569cf1f242
5 changed files with 131 additions and 2 deletions
  1. 2
    1
      Dockerfile
  2. 0
    0
      captive/configure_captive.sh
  3. 2
    1
      make_ipk.sh
  4. 3
    0
      management/config.sh
  5. 124
    0
      management/do_upgrade.sh

+ 2
- 1
Dockerfile View File

@@ -4,7 +4,8 @@ RUN apt update -y && apt install git build-essential libssl-dev libncurses5-dev
4 4
 RUN /usr/bin/git clone git://git.openwrt.org/project/usign.git /srv/usign && mkdir -p /srv/usign/build && cd /srv/usign/build && cmake .. && make
5 5
 RUN mkdir -p /srv/cadoles
6 6
 COPY make_ipk.sh /srv/cadoles
7
-COPY configure_captive.sh /srv/cadoles
7
+COPY captive/configure_captive.sh /srv/cadoles
8
+COPY management /srv/cadoles
8 9
 COPY server-linux-arm.tar.gz /srv/cadoles
9 10
 
10 11
 CMD ["/srv/cadoles/make_ipk.sh"]

configure_captive.sh → captive/configure_captive.sh View File


+ 2
- 1
make_ipk.sh View File

@@ -20,9 +20,10 @@ fi
20 20
 # build package
21 21
 cd /srv/cadoles
22 22
 rm -rf depot/* tmp
23
-mkdir -p tmp/src/opt/quid
23
+mkdir -p tmp/src/opt/quid tmp/src/opt/cadoles
24 24
 tar zxf $SRC --strip-components 1 --one-top-level=tmp/src/opt/quid
25 25
 cp -a configure_captive.sh tmp/src/opt/quid
26
+cp -a management/* tmp/src/opt/cadoles
26 27
 cd tmp/src/
27 28
 tar zcf ../data.tar.gz ./
28 29
 cd ..

+ 3
- 0
management/config.sh View File

@@ -0,0 +1,3 @@
1
+REPO=eolebase.cadoles.lan
2
+VERSION='18.06.1'
3
+

+ 124
- 0
management/do_upgrade.sh View File

@@ -0,0 +1,124 @@
1
+#!/bin/ash
2
+set -e
3
+KEY_SIG_NAME='f0f341195f9883c1'
4
+KEY_SIG='RWTw80EZX5iDwRMjIR4qYh1M7dnHYXnXo3jtrzyC0bRbGi0lRX/h/jte'
5
+
6
+CADOLES_DIR=/opt/cadoles
7
+TYPE=$1
8
+if [ -f $CADOLES_DIR/config.sh ]; then
9
+    . $CADOLES_DIR/config.sh
10
+fi
11
+if [ -z $REPO ] || [ -z $VERSION ]; then
12
+    echo "REPO or VERSION is not defined"; exit 1 || true
13
+fi
14
+
15
+# configure sysupgrade
16
+echo "/etc/ssl/certs/
17
+/etc/opkg/distfeeds.conf
18
+/etc/opkg/keys/$KEY_SIG_NAME
19
+# After upgrade, retrieve script
20
+$CADOLES_DIR
21
+" > /etc/sysupgrade.conf
22
+
23
+. /etc/openwrt_release
24
+if [ -z $TYPE ] && [ $VERSION = $DISTRIB_RELEASE ]; then
25
+    # Same version, install packages if needs and upgrade installed package
26
+    if [ ! "$(opkg info libustream-openssl | grep ^'Status: ')" = "Status: install user installed" ]; then
27
+        # if libustream-openssl is not installed
28
+        echo "src/gz openwrt_base http://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/base" > /etc/opkg/distfeeds.conf 
29
+        opkg update
30
+        opkg install libustream-openssl
31
+        # remove luci
32
+        opkg remove luci uhttpdd luci-mod-admin-full luci-base luci-lib-nixio luci-lib-jsonc luci-proto-ppp luci-app-firewall luci-theme-bootstrap luci-lib-ip luci-proto-ipv6 liblucihttp-lua liblucihttp
33
+    fi
34
+    echo "src/gz openwrt_core https://$REPO/releases/$VERSION/targets/mvebu/cortexa9/packages
35
+src/gz openwrt_base https://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/base
36
+src/gz openwrt_luci https://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/luci
37
+src/gz openwrt_packages https://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/packages
38
+src/gz openwrt_routing https://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/routing
39
+src/gz openwrt_telephony https://$REPO/releases/$VERSION/packages/arm_cortex-a9_vfpv3/telephony
40
+src/gz cadoles_quid https://$REPO/quid" > /etc/opkg/distfeeds.conf
41
+    if [ ! "$(opkg info quid | grep ^'Status: ')" = "Status: install user installed" ]; then
42
+        # if quid is not installed
43
+        echo "untrusted comment: Key for Cadoles repositories
44
+$KEY_SIG"> /etc/opkg/keys/$KEY_SIG_NAME
45
+        opkg update
46
+        opkg install quid
47
+    else
48
+        opkg update
49
+    fi
50
+    opkg upgrade zlib libopenssl libustream-openssl quid
51
+else
52
+    # New subversion
53
+    opkg update
54
+    opkg install gpgv coreutils-base64
55
+    if [ ! -f $CADOLES_DIR/keyring.gpg ]; then
56
+        # populate keyring if not already exists
57
+        mkdir -p $CADOLES_DIR
58
+        # pour faire ce base64 :
59
+        # gpg --keyring ~/keyring.gpg --no-default-keyring --keyserver hkp://pool.sks-keyservers.net --recv-keys 17E1CE16
60
+        # cat ~/keyring.gpg | base64 
61
+        echo "mQINBFr8KBIBEACua2CjanTmQN6z03u78RiNStHIMmBpykxZK7bbJDMIDwE7ewuWL2HYbDR4Ls+b
62
+fB/ER9CP2wxQQMUGibbCaJQ+wsxnuQfzjazaBcupXbFfZwu79gzoCtdBGFcbULjRBQKoF0gF8hYA
63
+8nJssMoXLPtxIUmQL4tP2dM5szpZ7F9M6ZgTnHCZeyUVhRS+aX2e8usfu1mdLqQIwWXaDTT70anJ
64
+MRtHmjCEE6hf0MFYqLooqjVUFTTUfZj65ZSF+PsHwj2uUPXG0lh0jx1jhSnIFOn9Doek/LGPPvKW
65
+l43xs/R/axR/RejhOsh8HwBsVeo6xJeVDOSl6icch949cId1BKGcC2p4DyRJMYYymRBv5XTp1MfS
66
+ecDIWd8uN+ilBSSkTEnNfxZ/b/G88hXKsAh1UigeWyGg/PrYnkD3gWeejOOihmG2Ckreg9Stoidx
67
++oDVVhH8Y5IiqZrfv4lB2UcEJ1G9+EUZC7uGUz3fcxHdWZjuaOxiWL3yydQrBSGpPv+DDt2HtDhg
68
+3gjZi9XCvbIEeGeeqPWwWzBCK6Yum2KzdtmpaZr88LVn4SR9qtyQ1FrGsXoZJRRwa5hlw05I1m24
69
+kNIY+NUNX8fT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IiyIKxbPxEqfZqARnefLHKZY/7Ja6SXab0sAcNruwMKcxpiFPJfGs5pdDPfPJnaDhZA22oW
97
+Ovyy99yE/PKPnV24gRN5fHGCCwBa6MQoBb5FnCb/0Lo/d2a+6dvHnwq0RzGK6fA+HW6nU4nQvv2n
98
+Jpae5sv0Cus6XpotlUVNE9oL3/4L7q1qciX4KepncRhoBwkI3Kmlt3++jAEe0/pECk/IsvoBiLeV
99
+6Vveo5RHXbWruw/yhllirDlFyogLtkeb6Sw5fifRhjGxgeo9Cnalh2xQpQmGWI5ZZtCzANgqMRMk
100
+tJiBBt3lA7eJUeftdXa2VzrC3w6gnTUlyREWFelc87VTz3kr+mlCQTZnZ2T4jyxftEa6lg1USTfW
101
+IwpIdqEO+0845jh0jIZH0iFNwMCwsAIAAw==" | base64 -d > $CADOLES_DIR/keyring.gpg
102
+    fi
103
+    cd /tmp
104
+    
105
+    rm -rf d_cadoles
106
+    mkdir d_cadoles
107
+    cd d_cadoles
108
+    
109
+    if [ "$1" = "full" ]; then
110
+        IMG_NAME="openwrt-$VERSION-mvebu-cortexa9-linksys-wrt1200ac-squashfs-factory.img"
111
+        SYSOPT="-F"
112
+    else
113
+        IMG_NAME="openwrt-$VERSION-mvebu-cortexa9-linksys-wrt1200ac-squashfs-sysupgrade.bin"
114
+    fi
115
+    
116
+    wget https://$REPO/releases/$VERSION/targets/mvebu/cortexa9/$IMG_NAME
117
+    wget https://$REPO/releases/$VERSION/targets/mvebu/cortexa9/sha256sums
118
+    wget https://$REPO/releases/$VERSION/targets/mvebu/cortexa9/sha256sums.asc
119
+    gpgv --keyring $CADOLES_DIR/keyring.gpg sha256sums.asc sha256sums
120
+    
121
+    grep $IMG_NAME sha256sums | sha256sum -c
122
+    
123
+    sysupgrade -v $SYSOPT $IMG_NAME
124
+fi