make the script much more readable
This commit is contained in:
parent
622c3d6fa3
commit
2ca3e29ef8
1 changed files with 21 additions and 9 deletions
|
@ -10,18 +10,30 @@ if ! [ $# -ge 1 ]; then
|
|||
exit 1
|
||||
fi
|
||||
[ $1 -ge 1 ] || exit 1
|
||||
#if ! ps -C wesnothd-1.3-prev>/dev/null; then
|
||||
|
||||
DEV_VERSION=1.3
|
||||
NEW_VERSION=$DEV_VERSION.$1
|
||||
PREV_VERSION=$DEV_VERSION.$(($1-1))
|
||||
PPREV_VERSION=$DEV_VERSION.$(($1-2))
|
||||
NEXT_VERSION=$DEV_VERSION.$(($1+1))
|
||||
DEV_SERVER_CONFIG=$HOME/servers/$DEV_VERSION/wesnothd.cfg
|
||||
PREV_SERVER_CONFIG=$HOME/servers/$DEV_VERSION-prev/wesnothd.cfg
|
||||
|
||||
#if ! ps -C wesnothd-$DEV_VERSION-prev>/dev/null; then
|
||||
# echo "Previous server isn't running!"
|
||||
# exit 1
|
||||
#fi
|
||||
$echo sed -i -e "s/\(versions_accepted=.*\)1\.3\.$(($1-2))/\11.3.$(($1-1))/g" ~/servers/1.3-prev/wesnothd.cfg
|
||||
$echo sed -i -e "s/motd=\(.*\)1\.3\.$(($1-1))/motd=\11.3.$1/g" ~/servers/1.3-prev/wesnothd.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-1.3-prev || exit 1
|
||||
$echo sed -i -e "s/\(versions_accepted=.*\)1\.3\.$(($1-1))/\11.3.$(($1+1))/g" ~/servers/1.3/wesnothd.cfg
|
||||
$echo sed -i -e "s/motd=\(.*\)1\.3\.$(($1-1))/motd=\11.3.$1/g" ~/servers/1.3/wesnothd.cfg
|
||||
$echo killall -SIGHUP wesnothd-$DEV_VERSION-prev || exit 1
|
||||
# check if we currently allow the previous version
|
||||
$echo [ grep "versions_accepted=.*$PREV_VERSION" ] || exit 1
|
||||
$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;s/\(version=.*\)1\.3\.$(($1-2))/\11.3.$(($1-1))/g" ~/servers/1.3/wesnothd.cfg
|
||||
$echo sed -i -e "/\[redirect\]/N;/version=/s/$PPREV_VERSION/$PREV_VERSION/" $DEV_SERVER_CONFIG
|
||||
# reload the config
|
||||
$echo killall -SIGHUP wesnothd-1.3 || exit 1
|
||||
$echo send_server_command 1.3 msg Version 1.3.$1 released! New users with the previous version will be redirected to a temporary server that will run until binaries for all major OSs are out.
|
||||
$echo killall -SIGHUP wesnothd-$DEV_VERSION || exit 1
|
||||
$echo send_server_command $DEV_VERSION msg Version $NEW_VERSION released! New users with the previous version will be redirected to a temporary server that will run until binaries for all major OSs are out.
|
||||
|
|
Loading…
Add table
Reference in a new issue