From f2827470bebc00355819d468cf7a42fc3012becb Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 26 Dec 2019 11:10:58 -0600 Subject: [PATCH] add version update tool --- tools/vupdate.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tools/vupdate.sh diff --git a/tools/vupdate.sh b/tools/vupdate.sh new file mode 100755 index 0000000..8711c7f --- /dev/null +++ b/tools/vupdate.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +UserInput() { + read -r -p "$(echo -e 'New version: ')" version + read -e -r -p "$(echo -e 'File: ')" file +} + +SedFindReplace() { + local rex='([0-9]{1,}\.[0-9]{1,}\.[0-9]{1,})' + sed -i -E "s/$rex/$1/g" "$2" +} + +BashFindReplace() { + in=$2 + rex='[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' + while [[ $in =~ $rex ]]; do + in=${BASH_REMATCH[1]}${BASH_REMATCH[2]} + done +} + +main() { + UserInput + SedFindReplace "$version" "$file" +# BashFindReplace "$version" "$file" +} + +while getopts a option +do + case "$option" in + a ) SedFindReplace "$2" "matrix-synapse_purge-remote-media.sh"; exit 0;; + esac +done + +main