From 4c343d4eeb1c1d76e86ed9c7a127c3f97ddbea80 Mon Sep 17 00:00:00 2001 From: Daniel Frank Date: Thu, 30 Dec 2021 23:16:26 +0100 Subject: [PATCH] Initial commit --- generic-sign.sh | 21 +++++++++++++++ stable_sign.sh | 52 ++++++++++++++++++++++++++++++++++++ sync-firmware.sh | 19 ++++++++++++++ update-manifests.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++ update-mirror.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 219 insertions(+) create mode 100755 generic-sign.sh create mode 100755 stable_sign.sh create mode 100755 sync-firmware.sh create mode 100755 update-manifests.sh create mode 100755 update-mirror.sh diff --git a/generic-sign.sh b/generic-sign.sh new file mode 100755 index 0000000..968802c --- /dev/null +++ b/generic-sign.sh @@ -0,0 +1,21 @@ +#!/bin/bash -e + +if [ -z "$1" ]; then + echo Usage: $0 '' >&2 + exit 1 +fi + +echo +echo Starting the signature process. +read -sp 'Please enter your private key (hidden) and press enter: ' privkey +echo + +echo +echo Signing manifest "$1" ... +# check if the separator is already in the file +if ! fgrep -q -- --- "$1"; then + echo --- >> "$1" +fi +ecdsasign <( awk '/^BRANCH/,/^---/' "$1" | egrep -v ^--- ) <<< "$privkey" >> "$1" +echo 'Last 10 lines of the signed manifest:' +tail -10 "$1" diff --git a/stable_sign.sh b/stable_sign.sh new file mode 100755 index 0000000..3d49566 --- /dev/null +++ b/stable_sign.sh @@ -0,0 +1,52 @@ +#!/bin/bash -e + +BASEPATH=~/firmware + +cat <> $m + fi + # generate the signature + ecdsasign <( awk '/^BRANCH/,/^---/' $m | egrep -v ^--- ) <<< "$privkey" >> $m +done diff --git a/sync-firmware.sh b/sync-firmware.sh new file mode 100755 index 0000000..1f38596 --- /dev/null +++ b/sync-firmware.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e + +while [ $# -gt 0 ]; do + case "$1" in + -n) + DRYRUN=--dry-run + ;; + *) + echo "Unknown option: $1" >&2 + exit 1 + ;; + esac + shift +done + +echo '############################# Uploading to srv01...' +rsync --recursive --delete-before --links --hard-links --times --partial --verbose --progress $DRYRUN ~/firmware/update-mirror/. ffupdates@srv01.hamburg.freifunk.net:updates/ +echo '############################# Uploading to srv03...' +rsync --recursive --delete-before --links --hard-links --times --partial --verbose --progress $DRYRUN ~/firmware/update-mirror/. ffupdates@srv03.hamburg.freifunk.net:/var/www/updates/ diff --git a/update-manifests.sh b/update-manifests.sh new file mode 100755 index 0000000..83b1441 --- /dev/null +++ b/update-manifests.sh @@ -0,0 +1,64 @@ +#!/bin/bash -e + +BASEPATH=~/firmware + +cat < "${m}" +done diff --git a/update-mirror.sh b/update-mirror.sh new file mode 100755 index 0000000..c14bb81 --- /dev/null +++ b/update-mirror.sh @@ -0,0 +1,63 @@ +#!/bin/bash -e + +LOCAL_BASE="${HOME}/firmware/update-mirror" + +show_usage() { +cat < + -r Release the firmware by changing the branch specific link to point to the new firmware + -n Set the rsync dry-run flag (WARNING: does not prevent the release link!) + -u rsync update-mirror to the update servers. use sync-firmware.sh if you want to do that later. + firmware: The directory created by the site-ffhh/build.sh script + for example: /home/gluon/firmware/0.8.5+exp20171028 + Must contain a single subdirectory named stable or experimental. +EOF +} + +while [ $# -gt 0 ]; do + case "$1" in + -r) + RELEASE=1 + ;; + -n) + DRYRUN=--dry-run + ;; + -u) + UPLOAD=1 + ;; + *) + FIRMWARE="$1" + if [ ! -d "$FIRMWARE" ]; then + show_usage + exit 1 + fi + ;; + esac + shift +done + +if [ ! -d "$FIRMWARE" ]; then + show_usage + exit 1 +fi + +pushd "$FIRMWARE" 2>/dev/null +VERSION="$(basename -- $(pwd -P))" +branch=$(ls | head -1) +pushd "$branch" 2>/dev/null +echo '############################# Updating the local mirror...' +TARGET="${LOCAL_BASE}/multi/archive/${VERSION}" +mkdir -p "${TARGET}" +rsync --verbose --progress --stats --recursive --hard-links --links --perms --times $DRYRUN . "${TARGET}" +if [ "${RELEASE}" == "1" ]; then + rm -f "${LOCAL_BASE}/multi/${branch}" + ln -s "archive/${VERSION}" "${LOCAL_BASE}/multi/${branch}" +fi + +if [ "${UPLOAD}" == "1" ]; then + echo '############################# Uploading to servers...' + rsync --recursive --delete-before --links --hard-links --times --partial --verbose --progress $DRYRUN $EXCLUDES "${LOCAL_BASE}/." ffupdates@srv01.hamburg.freifunk.net:updates/ + rsync --recursive --delete-before --links --hard-links --times --partial --verbose --progress $DRYRUN $EXCLUDES "${LOCAL_BASE}/." ffupdates@srv03.hamburg.freifunk.net:/var/www/updates/ +fi