Server Scripts

This is a collection of scripts to help people administrate their Untìl Uru servers. Please give me feedbacks so I can add features upon requests <knoumkhouefoui AT hotmail DOT com>.

NOTE: you HAVE to keep database name with their prefix (vault..., pls..., auth...) in order for these scripts to work.

First script is the common library used by all scripts.

uulib

This is the common library used by all scripts. Edit only first two parameters to reflect your untiluru installation.

# IMPORTANT: please make sure your database names keep their prefix (vault*,pls*,auth*).

UUDIR="/home/untiluru"          # UntilUru installation directory
BCKDIR="/home/backups"          # Backups directory

# Don't edit from this point on
TMPF="/tmp/`basename $0`.$$"

INI="$UUDIR/etc/PlasmaServers.ini"

UUDBUSER=`grep DbUserName $INI | awk -F= '{ print $2 }'`
UUDBPASS=`grep DbPassword $INI | awk -F= '{ print $2 }'`
UUDBHOST=`grep DbHost $INI | awk -F= '{ print $2 }'`
UUDBVAULT=`grep "db.dbname=vault" $INI | awk -F= '{ print $2 }'` 
UUDBAUTH=`grep "db.dbname=auth" $INI | awk -F= '{ print $2 }'` 
UUDBPLS=`grep "db.dbname=pls" $INI | awk -F= '{ print $2 }'` 
UUDBS=`grep db.dbname $INI | awk -F= '{ print $2 }'`

# Node Types
NODE_PLAYER=2
NODE_AGE=3
NODE_GAME=4
NODE_ADMIN=5
NODE_VAULT=6
NODE_FOLDER=22
NODE_PLAYERINFO=23
NODE_SYSTEM=24
NODE_IMAGE=25
NODE_TEXTNOTE=26
NODE_SDL=27
NODE_LINK=28                    # ->NODE_AGEINFO
NODE_CHRONICLE=29
NODE_PLAYERINFOLIST=30          # same as NODE_FOLDER
NODE_MARKER=32
NODE_AGEINFO=33                 #
NODE_MARKERLIST=35                      # same as NODE_FOLDER but holds FLDR_BUDDYLIST

# Folder Types
FLDR_LINK0=0                    # FLDR_*->self ?????    (Unlocked LINK)
FLDR_LINK=1                     # FLDR_*->self          (Locked LINK)
FLDR_BUDDYLIST=2                # from nodetype=NODE_MARKERLIST
FLDR_PEOPLEIKNOWABOUT=4         # NODE_AGE->self
FLDR_IGNORELIST=3               # NODE_PLAYERINFO->self
FLDR_CHRONICLE=6                # NODE_PLAYERINFO->self->NODE_CHRONICLE
FLDR_AVATAROUTFIT=7             # NODE_PLAYERINFO->self->NODE_SDL
FLDR_AGETYPEJOURNAL=8           # FLDR_AGEJOURNAL->self-> ?
FLDR_SUBAGES=9                  # NODE_AGE->self
FLDR_DEVICEINBOX=10             # NODE_TEXTNOTE->self->NODE_IMAGE(m)
FLDR_ALLPLAYERS=12              # root->self->NODE_PLAYERINFO(m)
FLDR_AGEJOURNAL=14              # NODE_PLAYERINFO->self->FLDR_AGETYPEJOURNAL(m)
FLDR_AGEDEVICES=15              # NODE_AGE->self->NODE_TEXTNOTE->FLDR_DEVICEINBOX->NODE_IMAGE(m)
FLDR_CANVISIT=18                # NODE_AGEINFO->self->NODE_PLAYERINFO(m)
FLDR_AGEOWNERS=19               # NODE_AGEINFO->self->NODE_PLAYERINFO(m)
FLDR_AGESIOWN=23                # NODE_PLAYERINFO->self->NODE_LINK(m)
FLDR_AGESICANVISIT=24           # NODE_PLAYERINFO->self->NODE_LINK(m)
FLDR_AVATARCLOSET=25            # NODE_PLAYERINFO->self->NODE_SDL(m)
FLDR_PLAYERINVITE=28            # NODE_PLAYER->self-> ?
FLDR_GLOBALINBOX=30             # NODE_SYSTEM->self->NODE_TEXTNOTE
FLDR_CHILDAGES=31

. $UUDIR/etc/functions

Functions library

This file called 'functions' holds basic sql requests to help script creation.

getplayer()
{
  USER=`echo $1 | sed "s/'/\\\\\'/g"` # backslash quotes for mysql
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE NodeType=$NODE_PLAYER AND LOWER(IString64_1) = LOWER('$USER') LIMIT 1;
EOF
`
  echo $res
}

getplayerinfo()
{
  USER=`echo $1 | sed "s/'/\\\\\'/g"` # backslash quotes for mysql
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE NodeType=$NODE_PLAYERINFO AND LOWER(IString64_1) = LOWER('$USER') LIMIT 1;
EOF
`
echo $res
}

getagesiown()
{
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE OwnerIdx=$1 AND NodeType=$NODE_FOLDER AND Int32_1=$FLDR_AGESIOWN LIMIT 1;
EOF
`
echo $res
}

getagefromplayer()
{
  playid=`getplayer "$1"`
  age=`echo $2 | sed "s/'/\\\\\'/g"` # backslash quotes for mysql
  parent=$3
  [ -z "$playid" -o -z "$age" -o -z "$parent" ] && return
  case $parent in
    P) parent="ParentIdx" ;;
    C) parent="ChildIdx" ;;
    *) echo "Bad parent parameter"; return ;;
  esac
  agesiown=`getagesiown $playid`
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT ChildIdx FROM NodeRefs WHERE ParentIdx=$agesiown;
EOF
`
  inarg=`echo $res | sed 's/ /,/g'`
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT $parent FROM NodeRefs LEFT JOIN Nodes ON Nodes.Idx=ChildIdx WHERE ParentIdx IN ($inarg) AND String64_1='$age';
EOF
`
  echo $res
}

getneighbname()
{
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT String64_3 FROM Nodes WHERE Idx=$1 LIMIT 1;
EOF
`
  echo $res
}

blobtopath()
{
  dbasev=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT DatabaseGuid FROM DatabaseVersion LIMIT 1
EOF
`
  path=`echo $1 | sed 's/\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)/\1\/\2\/\3\/\4\/\5\/\6\/\7\/\8.blob/'`
  echo $UUDIR/var/VaultBlobs/$dbasev/$path
}

getplayerfolder()
{
  playid=`getplayer $1`
  [ -z "$playid" ] && return
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE OwnerIdx=$playid AND NodeType=$NODE_FOLDER AND Int32_1=$2 LIMIT 1;
EOF
`
  echo $res
}

getplayerchronicle()
{
  playid=`getplayer $1`
  [ -z "$playid" ] && return
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE OwnerIdx=$playid AND NodeType=$NODE_CHRONICLE AND LOWER(String64_1)=LOWER('$2') LIMIT 1;
EOF
`
  echo $res
}

getblobfromidx()
{
  blob=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Blob1Guid FROM Nodes WHERE Idx=$1 LIMIT 1;
EOF
`
  res=`blobtopath $blob` 
  echo $res
}

getfieldfromidx()
{
  res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT $2 FROM Nodes WHERE Idx=$1 LIMIT 1;
EOF
`
  echo $res
}

showusers()
{
mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT IString64_1 FROM Nodes WHERE NodeType=$NODE_PLAYERINFO AND OwnerIdx !=0
ORDER BY IString64_1 ASC;
EOF
}

Backup

Performs a complete backup of Game data. Il will find out exact databases to be backuped from ini file. It will also do a 'once and for all' backup and binary installation. Just edit DIR and UUDIR variables to match your configuration. Finally add a crontab entry such as:

0 5 * * * /home/untiluru/etc/backup

which means launch backup process every day at 5am. Feel free to change it and add some nice information on your DRC imager and/or global Ki message to let people know your server will experience a downtime so that users aren't suprised when server suddenly stops

modified script to wait and kill leftover processes. Thanks for the idea Markie!

!/bin/sh

UUDIR=/home/untiluru
. $UUDIR/etc/uulib

DATE=`date +%d%m%H%M`
[ -f $UUDIR/etc/getmaxplayers ] && $UUDIR/etc/getmaxplayers A
$UUDIR/rc.d/plasma-servers.sh stop
count=0
while [ `eval ps -fuuntiluru | wc -l` > 1 -a $count -lt 10 ]; do sleep 1; count=`expr $count + 1`; done
if [ $count -eq 10 ]; then
  echo "Killing leftover processes..."
  ps -fuuntiluru | tail -n +2 |
  while read LINE; do
    echo "Killing processs `echo $LINE | awk '{ print $8}'`"
    kill -9 `echo $LINE | awk '{ print $2 }'` # >/dev/null 2>1&
  done
fi
[ ! -f $BCKDIR/uubin.tar.gz ] && tar -cpz --exclude="var/*" -f $BCKDIR/uubin.tar.gz $UUDIR >/dev/null 2>&1
mysqldump -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS -a --databases $UUDBS | gzip -9 >$BCKDIR/mysql-$DATE.gz
tar cpfz $BCKDIR/uu-$DATE.tar.gz $UUDIR/var/Vault* >/dev/null 2>&1
rm -rf $UUDIR/var/log/*
$UUDIR/rc.d/plasma-servers.sh start

Restore from backup

This procedure automagically restore mysql databases and Vault files from backup made with previous backup script. Asks for date to restore, then clear logs, drop previous databases, delete Vault files, then restore mysql & Vault. Restart servers at end.

MODE=$1

UUDIR=/home/untiluru
. $UUDIR/etc/uulib

# MODE=A then restore automagically last backup set (non-interactivelly)
if [ "$MODE" != "A" ]; then
  echo "****************************************************************"
  echo -n "WARNING: are you *sure* you want to completly restore UntilUru [yes/no] ? "
  read ans
  [ "$ans" != "yes" ] && echo "Exiting..." && exit

  echo "Available backups:"
  ls $BCKDIR | grep "uu-" | sed 's/.*\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*/\1/'
  echo -n "Please specify date to restore from available ones: "
  read DATE
  [ ! -f "$BCKDIR/uu-$DATE.tar.gz" ] && echo "Specified backup set not available, exiting" && exit
else
  DATE=`ls -tr $BCKDIR | tail -n -1 | grep "uu-" | sed 's/.*\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*/\1/'`
  echo "Auto-restoring from $DATE"
fi

$UUDIR/rc.d/plasma-servers.sh stop
for DB in $UUDBS; do
  echo "Dropping database $DB"
  mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS <<EOF >$TMPF 2>&1
  drop database $DB
EOF
  RES=`tail -n 1 $TMPF | grep ERROR`
  [ -n "$RES" ] && echo $RES
done
echo "Dropping Vault files"
rm -rf $UUDIR/var/Vault*
echo "Restoring database from $DATE"
gunzip -c $BCKDIR/mysql-$DATE.gz | mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS 
echo "Restoring Vault files"
( cd / ; tar xpfz $BCKDIR/uu-$DATE.tar.gz )
echo "Cleaning log directory"
rm -rf $UUDIR/var/log/*
$UUDIR/rc.d/plasma-servers.sh start

zapall

This script will *completly* reset your vault.

UUDIR=/home/untiluru
. $UUDIR/etc/uulib

echo "****************************************************************"
echo -n "WARNING: are you *sure* you want to initialize UntilUru [yes/no] ? "
read ans
[ "$ans" != "yes" ] && echo "Exiting..." && exit

$UUDIR/rc.d/plasma-servers.sh stop
for DB in $UUDBS; do
  echo "Dropping database $DB"
  mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS <<EOF >$TMPF 2>&1
  drop database $DB
EOF
  RES=`tail -n 1 $TMPF | grep ERROR`
  [ -n "$RES" ] && echo $RES
done
echo "Dropping Vault files"
rm -rf $UUDIR/var/Vault*
echo "Cleaning log directory"
rm -rf $UUDIR/var/log/*
echo "Cleaning SavesGames"
rm -rf $UUDIR/var/SavedGames
echo "Cleaning vnode_cache"
rm -rf $UUDIR/var/vnode_cache
echo "Cleaning resMgrMemLeaks"
rm -rf $UUDIR/var/resMgrMemLeaks.txt 
echo "Restart untiluru to have clean install"

giveright : Adding Permissions for users

This script is used mainly to add special permissions for users, such as admin state, kline or private status. Usage is: giveright username right where right = P (private), A (admin) or K (Klined)

USER=$1
RIGHT=$2

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

[ -z "$USER" ] && echo "Missing username" && exit 1
[ -z "$RIGHT" ] && echo "Missing right" && exit 2

[ "$RIGHT" = "A" ] && RIGHT="ADMIN"
[ "$RIGHT" = "K" ] && RIGHT="KLINE"
[ "$RIGHT" = "P" ] && RIGHT="PRIVATE"

USER=`echo $USER | sed "s/'/\\\\\'/g"` # backslash quotes for mysql

if [ "$RIGHT" = "D" ]; then
  echo "Removing user '$USER' in $UUDBAUTH database on host $UUDBHOST"
  mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBAUTH >$TMPF 2>&1 <<EOF
  DELETE FROM Permissions WHERE AcctName = '$USER';
EOF
  RES=`tail -n 1 $TMPF | grep ERROR | awk '{ print $2 }'`
  [ "$RES" = "1062" ] && echo $RES
  exit
fi

echo "Setting user '$USER' as $RIGHT in $UUDBAUTH database on host $UUDBHOST"
mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBAUTH >$TMPF 2>&1 <<EOF
INSERT INTO Permissions VALUES ('$USER', '$RIGHT');
EOF

RES=`tail -n 1 $TMPF | grep ERROR | awk '{ print $2 }'`
if [ "$RES" = "1062" ]; then
  echo "User already exists, modifying it"
  mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBAUTH >$TMPF 2>&1 <<EOF
UPDATE Permissions SET AcctStatus = '$RIGHT' WHERE AcctName = '$USER';
EOF
  RES=`tail -n 1 $TMPF | grep ERROR`
  [ -n "$RES" ] && echo $RES
fi
rm -f $TMPF

Check Vault database

As for now only one check: find players who imported ToDni/POTS saved game. I'd need some help to extend this one to other checks.

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

echo "Checking for ToDni/POTS ages coming from bad saved gamed import"
mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT >$TMPF 2>&1 <<EOF
SELECT DISTINCT(CreatorIdx) FROM Nodes WHERE CreateAgeName IN ('spyroom','Descent','Personal02','DRC Neighborhood','Watcher''s Guild');
EOF

RES=`tail -n 1 $TMPF | grep ERROR`
[ -n "$RES" ] && echo $RES && exit
if [ -s $TMPF ]; then
  echo -n "SELECT IString64_1 FROM Nodes WHERE NodeType=23 AND OwnerIdx IN (" >$TMPF.2
  tail -n +2 $TMPF | while read cidx; do
     echo -n "$cidx," >>$TMPF.2
  done
  echo "0);" >>$TMPF.2
  mysql -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <$TMPF.2 >$TMPF 2>&1
  tail -n +2  $TMPF
else
  echo "none"
fi

rm -f $TMPF*

Check Neighborhood membership

This script will list all declared members for all Neighborhoods. First one should be the age creator, in order to track who's doing what on your shard. It prints also correct Node to be subscribed on VM in order to customize age. PLEASE COMMENT ON THIS ONE, BIG ASUMPTIONS HERE.

# FolderType
# 18 = CanVisitFolder
# 19 = AgeOwnersFolder
UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

echo "Checking for all Neighborhoods access rights (first should be age creator)"
mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT >$TMPF 2>&1 <<EOF
SELECT Idx,UInt32_1,String64_3 FROM Nodes WHERE nodetype= '33' AND String64_1 = 'Neighborhood';
EOF

RES=`tail -n 1 $TMPF | grep ERROR`
[ -n "$RES" ] && echo $RES && exit

tail -n +2 $TMPF | while read idx uint name; do
  echo "***** $name ($uint)" >$TMPF.2
  CANVFLDR=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT 2>&1 <<EOF | tail -n +2
SELECT Nodes.Idx FROM Nodes,NodeRefs WHERE Nodes.NodeType = 30 AND Nodes.Int32_1 = 18 AND NodeRefs.ParentIdx = $idx AND NodeRefs.ChildIdx = Nodes.Idx;
EOF
`
  mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT 2>&1 <<EOF | tail -n +2 >>$TMPF.2
SELECT IString64_1 FROM Nodes,NodeRefs WHERE NodeRefs.ParentIdx = $CANVFLDR AND NodeRefs.ChildIdx = Nodes.Idx;
EOF
  cat $TMPF.2
done
rm -f $TMPF*

showplayers

This scripts show Players Inside (I), players Outside (O), or All players (A) on your shard.

MODE=$1

[ -z "$MODE" ] && echo "Usage: $0 [I/O/A] (In, Out, All)" && exit
[ "$MODE" = "I" ] && cond="AND n1.Int32_1 = 1"
[ "$MODE" = "O" ] && cond="AND n1.Int32_1 = 0"
[ "$MODE" = "A" ] && cond=""

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT n1.Idx,n1.IString64_1,n2.IString64_2,n1.String64_1 FROM Nodes AS n1
LEFT JOIN Nodes AS n2 ON n1.OwnerIdx=n2.Idx
WHERE n1.NodeType=$NODE_PLAYERINFO $cond AND n1.OwnerIdx !=0
ORDER BY n2.IString64_2;
EOF

fixgz

As name says it, this script is used to fix GZ ownership as described in method 1 (ugly ? why ugly ? :) ). This one was created looking at debug SQL requests made on vault database.

Arg: username.

It will first find user's associated neighborhood, and will find into this neighborhood for GZ link presence. It can fix bad linking infos (only one link instead of 2) regenerating blob if needed, and will add user in GZ AgeOwnersFolder node if it's not already there.

Thus when a user says GZ disappear, you just have to call this script.

Caveats: user still needs to upload first 15 green markers in order for this script to complete succesfully. Otherwyse it will peacefully stop, lots of integrity checking is done to avoir messing things up.

As for other scripts, this one relies on 'uulib' and 'functions' files to be available in 'etc' directory under your untiluru installation.

USER=$1

GOODLINKPOINTS="Default:LinkInPointDefault:;Great Zero:BigRoomLinkInPoint:;"

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

[ -z "$USER" ] && echo "Missing User name" && exit 1

playidx=`getplayerinfo $USER`
neighbidx=`getagefromplayer $USER Neighborhood C`
neighbname=`getneighbname $neighbidx`

echo "Found neighborhood $neighbname for user $USER"

# Get Neighborhood associated ChildAgesFolder
chageidx=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE OwnerIdx=$neighbidx AND NodeType=$NODE_FOLDER AND Int32_1=$FLDR_CHILDAGES LIMIT 1;
EOF
`
# Get link
linkidx=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT ChildIdx FROM NodeRefs WHERE ParentIdx=$chageidx LIMIT 1;
EOF
`
[ -z "$linkidx" ] && echo "Error: no age link node, exiting..." && exit

# Get blobid from link
blobid=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Blob1Guid FROM Nodes WHERE Idx=$linkidx LIMIT 1;
EOF
`

# Get GZ
gzidx=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT ChildIdx FROM NodeRefs LEFT JOIN Nodes ON Nodes.Idx=ChildIdx WHERE ParentIdx=$linkidx AND String64_1='GreatZero' LIMIT 1;
EOF
`
[ -z "$gzidx" ] && echo "Error: GZ link is missing, exiting..." && exit

bpath=`blobtopath $blobid`
res=`cat $bpath`

if [ "$res" = "$GOODLINKPOINTS" ]; then
  echo "Linking points where correct, skipping..."
else
  echo "Fixing link points (old='$res')"
  echo "$GOODLINKPOINTS" >$bpath
fi

# Get AgeOwner
ageown=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE OwnerIdx=$gzidx AND NodeType=$NODE_PLAYERINFOLIST AND Int32_1=$FLDR_AGEOWNERS LIMIT 1;
EOF
`
# Sanity check if info isn't already there
res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF 
SELECT Idx FROM NodeRefs WHERE ParentIdx=$ageown AND ChildIdx=$playidx;
EOF
`
[ -n "$res" ] && echo "WARNING: link already exist, exiting..." && exit

# Create new chain
res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
INSERT INTO NodeRefs (AutoTime,ParentIdx,ChildIdx,SaverIdx) VALUES (NOW(),$ageown,$playidx,0);
EOF
`

sendglobalki

WORK IN PROGRESS! As for now this script is able to change title and text for the first global Ki message. This is only a proof of concept because this message won't be seen until a server restart. At least it shows how to reach a .blob on the VaultBlobs directory.

Args: title and filename where text will be taken from. Problem: modifications are not taken in real time. Need to find a way. Someone ?

TITLE=$1
FILE=$2

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

[ -z "$TITLE" ] && echo "Missing title" && exit 1
[ ! -f "$FILE" ] && echo "Missing file" && exit 2

dbasev=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT DatabaseGuid FROM DatabaseVersion LIMIT 1
EOF
`
ginbfldr=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Idx FROM Nodes WHERE NodeType=$NODE_FOLDER AND Int32_1=$FLDR_GLOBALINBOX AND String64_1='GlobalInboxFolder' LIMIT 1;
EOF
`
res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT Nodes.Idx,Blob1Guid FROM Nodes INNER JOIN NodeRefs ON Nodes.Idx = NodeRefs.ChildIdx AND NodeRefs.ParentIdx = $ginbfldr LIMIT 1;
EOF
`
eval `echo $res | sed 's/\(.*\) \(.*\)/idx="\1" b1guid="\2"/'`
path=`echo $b1guid | sed 's/\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)\([0-Z][0-Z]\)/\1\/\2\/\3\/\4\/\5\/\6\/\7\/\8.blob/'`
mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT 2>&1 <<EOF
UPDATE Nodes SET String64_1 = "$TITLE" WHERE Idx = $idx;
EOF
cat $FILE >$UUDIR/var/VaultBlobs/$dbasev/$path

viewplayer

This is another proof of concept, using a reetrant shell function to mimic VM functions. It takes a username as argument and displays a complete tree about this player, revealing all nodes, using a single function call. It may be of some help for people trying to build a VM replacement, but needs some extra work to display values upon node type.

getchild()
{
  parent=$1

  mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2 |
SELECT ChildIdx FROM NodeRefs WHERE ParentIdx = $parent;
EOF
  while read chidx; do
    res=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT NodeType,Int32_1 FROM Nodes WHERE Idx = $chidx;
EOF
`
    eval `echo $res | sed 's/\(.*\) \(.*\)/ntype="\1" int321="\2"/'` 
    case $LEVEL in
      1) echo -n "  " ;;
      2) echo -n "    " ;;
      3) echo -n "      " ;;
      4) echo -n "        " ;;
      5) echo -n "          " ;;
      6) echo -n "            " ;;
      7) echo -n "              " ;;
      8) echo -n "                " ;;
      9) echo -n "                  " ;;
      10) echo -n "                    " ;;
    esac
    case $ntype in
      $NODE_FOLDER|$NODE_LINK|$NODE_PLAYERINFOLIST)
        case $int321 in
          $FLDR_LINK0) echo -n "[LINK0]" ;;
          $FLDR_LINK) echo -n "[LINK]" ;;
          $FLDR_BUDDYLIST) echo -n "(BUDDYLIST)" ;;
          $FLDR_PEOPLEIKNOWABOUT) echo -n "(PEOPLEIKNOWABOUT)" ;;
          $FLDR_IGNORELIST) echo -n "(IGNORELIST)" ;;
          $FLDR_CHRONICLE) echo -n "(CHRONICLE)" ;;
          $FLDR_AVATAROUTFIT) echo -n "(AVATAROUTFIT)" ;;
          $FLDR_AGETYPEJOURNAL) echo -n "(AGETYPEJOURNAL)" ;;
          $FLDR_SUBAGES) echo -n "(SUBAGES)" ;;
          $FLDR_DEVICEINBOX) echo -n "(DEVICEINBOX)" ;;
          $FLDR_ALLPLAYERS) echo -n "(ALLPLAYERS)" ;;
          $FLDR_AGEJOURNAL) echo -n "(AGEJOURNAL)" ;;
          $FLDR_AGEDEVICES) echo -n "(AGEDEVICES)" ;;
          $FLDR_CANVISIT) echo -n "(CANVISIT)" ;;
          $FLDR_AGEOWNERS) echo -n "(AGEOWNERS)" ;;
          $FLDR_AGESIOWN) echo -n "(AGESIOWN)" ;;
          $FLDR_AGESICANVISIT) echo -n "(AGESICANVISIT)" ;;
          $FLDR_AVATARCLOSET) echo -n "(AVATARCLOSET)" ;;
          $FLDR_PLAYERINVITE) echo -n "(PLAYERINVITE)" ;;
          $FLDR_GLOBALINBOX) echo -n "(GLOBALINBOX)" ;;
          $FLDR_CHILDAGES) echo -n "(CHILDAGES)" ;;
          *) echo -n "f?$int321" ;;
        esac
        ;;
      $NODE_PLAYER) echo -n "*PLAYER*" ;;
      $NODE_AGE) echo -n "*AGE*" ;;
      $NODE_GAME) echo -n "*GAME*" ;;
      $NODE_ADMIN) echo -n "*ADMIN*" ;;
      $NODE_VAULT) echo -n "*VAULT*" ;;
      $NODE_PLAYERINFO) echo -n "*PLAYINFO*" ;;
      $NODE_SYSTEM) echo -n "*SYSTEM*" ;;
      $NODE_IMAGE) echo -n "*IMAGE*" ;;
      $NODE_TEXTNOTE) echo -n "*TEXTNOTE*" ;;
      $NODE_SDL) echo -n "*SDL*" ;;
      $NODE_CHRONICLE) echo -n "*CHRONICLE*" ;;
      $NODE_PLAYERINFOLIST) echo -n "*PLAYERINFOLIST*" ;;
      $NODE_MARKER) echo -n "*MARKER*" ;;
      $NODE_AGEINFO) echo -n "*AGEINFO*" ;;
      $NODE_MARKERLIST) echo -n "*MARKERLIST*" ;;
      *) echo -n "n?$ntype" ;;
    esac
    echo " $chidx"
    LEVEL=$((LEVEL+1)) 
    getchild $chidx
  done
  LEVEL=$((LEVEL-1)) 
}

USER=$1
LEVEL=1

[ -z "$USER" ] && echo "Usage: $0 username" && exit

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

playidx=`mysql -B -h$UUDBHOST -u$UUDBUSER -p$UUDBPASS $UUDBVAULT <<EOF | tail -n +2
SELECT OwnerIdx FROM Nodes WHERE NodeType=$NODE_PLAYERINFO AND LOWER(IString64_1) = LOWER('$USER') LIMIT 1;
EOF
`
getchild $playidx
echo

givemuseum

As the title says, this script gives museum access to named player, or all players. Usage: givemuseum username/All [S]

"givemuseum Khoufou" will give museum access to user Khoufou "givemuseum Khoufou S" will suppress museum access to user Khoufou "givemuseum All" will give museum access to all users "givemuseum All S" will suppress museum access to all users

USER=$1
DEL=$2

mode=U
[ "$USER" = "All" ] && mode=A

UUDIR='/home/untiluru'
. $UUDIR/etc/uulib

[ -z "$USER" ] && echo "Missing User name" && exit 1

[ "$mode" = "U" ] && echo "$USER" >$TMPF.2
[ "$mode" = "A" ] && showusers >$TMPF.2

cat $TMPF.2 | while read user; do
  echo -n "Museum for $user "
  age=`getagefromplayer "$user" city P`
  path=`getblobfromidx $age`
  res=`cat $path`
  # Sanity check
  isok=`cat $path | grep Ferry`
  [ -z "$isok" ] && echo "ERROR: was not a valid link file" && exit
  isok=`cat $path | grep Museum`
  if [ "$DEL" = "S" ]; then
    if [ -z "$isok" ]; then
      echo "ERROR: museum wasn't active"
    else
      cat $path | sed 's/Museum\:MuseumIntStart\:\;//' >$TMPF
      mv $TMPF $path
      rm -f $TMPF
      echo "suppressed"
    fi
  else
    if [ -n "$isok" ]; then
      echo "ERROR: museum already active"
    else
      new="Museum:MuseumIntStart:;$res"
      echo $new >$path
      echo "activated"
    fi
  fi
done

Iptables for dual-homed server

This iptable rule is necessary for users playing on a LAN behind a dual-homed untiluru server. CLIENT_LAN_IP is the IP of the client playing untiluru SERVER_PUBLIC_IP is the public ip adr of the untiluru server SERVER_LAN_IP is the private ip adr of the untiluru server

This trick is needed because untiluru server, even if using ExtAddr and IntAddr parameters, is using public IP adr when autenticating at the second place, just before getting to Relto.

Thx to Sjaak-de-Draak for this one :)

internet
   |
   |
 untiluru
  server
   |
   |
  client


/sbin/iptables -t nat -A PREROUTING -s $CLIENT_LAN_IP -p udp -d $SERVER_PUBLIC_IP -m mport
--dports 5000:6000 -j DNAT --to $SERVER_LAN_IP

ServerScripts (last edited 2008-12-27 16:35:29 by localhost)