#! /bin/sh # Copyright (C) 2005 Nick Urbanik # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. function usage { local prog=$(basename $0) cat <<"EOF" $prog groupname new_time_played where: groupname is a game group such as silly or educational new_time_played is a new amount of time played for that group, such as 1800 For example, you could have the group educational have already had 1800 seconds playing time with: $prog educational 1800 To reduce the time played to minimum (i.e., allow the maximum playing time), do $prog educational 0 This will also take care of changing the date to today, to make that limit current. Better to use change-game-time-left.sh, since it is more user friendly. EOF } if [ "$#" -ne "2" ] then usage exit 1 fi if $(echo $2|egrep -q '^[0-9]+$') then echo psql games --command "update times set group_playing_time = $2, date = 'today' where groupname = '$1';" if psql games --command "update times set group_playing_time = $2, date = 'today' where groupname = '$1';" | grep 'UPDATE 1' then psql games --command "select * from times;" fi else echo Need to call this script with a number of seconds to set the group_playing_time to. usage exit 1 fi