Author: soliton
Date: Sat May 23 15:26:51 2009
New Revision: 35847
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35847&view=rev
Log:
made script more portable and removed bash requirement
Modified:
trunk/utils/mp-server/new_release
Modified: trunk/utils/mp-server/new_release
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/mp-server/new_release?rev=35847&r1=35846&r2=35847&view=diff
==============================================================================
--- trunk/utils/mp-server/new_release (original)
+++ trunk/utils/mp-server/new_release Sat May 23 15:26:51 2009
@@ -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 @@
$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."
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits