add version update tool

This commit is contained in:
Joe 2019-12-26 11:10:58 -06:00
parent 6eff67b701
commit f2827470be
No known key found for this signature in database
GPG Key ID: 8595A3F8F2CE1B74

34
tools/vupdate.sh Executable file
View File

@ -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