made script more portable and removed bash requirement
This commit is contained in:
parent
7c61088e82
commit
e24d0012c3
1 changed files with 13 additions and 19 deletions
|
@ -1,15 +1,12 @@
|
|||
#!/bin/bash
|
||||
if [ "$1" == "-n" ]; then
|
||||
echo=echo
|
||||
shift
|
||||
else
|
||||
echo=""
|
||||
fi
|
||||
if ! [ $# -ge 1 ]; then
|
||||
echo "Syntax: $0 [-n] <new minor version>" >&2
|
||||
exit 1
|
||||
fi
|
||||
[ $1 -ge 1 ] || exit 1
|
||||
#!/bin/sh
|
||||
die() { echo >&2 "$@"; exit 1; }
|
||||
[ $# -ge 1 ] || die "Syntax: $0 [-n] <new minor version>"
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
echo=""
|
||||
[ "$1" = "-n" ] && { echo=echo; shift; }
|
||||
[ $1 -ge 1 ] || die "New version must be greater than 1!"
|
||||
|
||||
DEV_VERSION=1.5
|
||||
NEW_VERSION=$DEV_VERSION.$1
|
||||
|
@ -28,17 +25,14 @@ PREV_SERVER_REDIRECT=$HOME/servers/$DEV_VERSION-prev/redirect.cfg
|
|||
$echo sed -i -e "/versions_accepted=/s/$PPREV_VERSION/$PREV_VERSION/" $PREV_SERVER_CONFIG
|
||||
$echo sed -i -e "/motd=/s/$PREV_VERSION/$NEW_VERSION/g" $PREV_SERVER_CONFIG
|
||||
# reload the config
|
||||
$echo killall -SIGHUP wesnothd-$DEV_VERSION-prev || exit 1
|
||||
$echo killall -HUP wesnothd-$DEV_VERSION-prev
|
||||
# check if we currently allow the previous version to prevent announcing the same version twice
|
||||
if ! [ $(grep "versions_accepted=.*$PREV_VERSION" $DEV_SERVER_CONFIG) ]; then
|
||||
echo "Previous version $PREV_VERSION currently not allowed. Announcing the right version? Aborting..." >&2
|
||||
exit 1
|
||||
fi
|
||||
grep "versions_accepted=.*$PREV_VERSION" $DEV_SERVER_CONFIG || die "Previous version $PREV_VERSION currently not accepted. Announcing the right version? Aborting..."
|
||||
$echo sed -i -e "/versions_accepted=/s/$PREV_VERSION/$NEXT_VERSION/" $DEV_SERVER_CONFIG
|
||||
$echo sed -i -e "/motd=/s/$PREV_VERSION/$NEW_VERSION/g" $DEV_SERVER_CONFIG
|
||||
# update previous version redirect
|
||||
$echo sed -i -e "/\[redirect\]/N;/version=/s/$PPREV_VERSION/$PREV_VERSION/" $PREV_SERVER_REDIRECT
|
||||
$echo sed -i -e "s,#\({./$DEV_VERSION-prev-redirect.cfg}\),\1," $DEV_SERVER_CONFIG
|
||||
# reload the config
|
||||
$echo killall -SIGHUP wesnothd-$DEV_VERSION wesnothd-trunk || exit 1
|
||||
$echo $HOME/bin/send_server_command $DEV_VERSION msg Version $NEW_VERSION has been released! New users with the previous version will now get redirected to a temporary server that will run until binaries for all major OSes are out.
|
||||
$echo killall -HUP wesnothd-$DEV_VERSION wesnothd-trunk
|
||||
$echo $HOME/bin/send_server_message $DEV_VERSION "Version $NEW_VERSION has been released! New users with the previous version will now get redirected to a temporary server that will run until binaries for all major OSes are out."
|
||||
|
|
Loading…
Add table
Reference in a new issue