aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xscripts/backup-inventories.sh17
-rwxr-xr-xscripts/backup-sims.sh21
-rwxr-xr-xscripts/common.sh76
-rwxr-xr-xscripts/gitAR.sh23
-rwxr-xr-xscripts/start-sim20
5 files changed, 89 insertions, 68 deletions
diff --git a/scripts/backup-inventories.sh b/scripts/backup-inventories.sh
index 30f8ac6..1d753eb 100755
--- a/scripts/backup-inventories.sh
+++ b/scripts/backup-inventories.sh
@@ -1,20 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Figure out where we are, most of this mess is to troll through soft links. 3source common.sh
4PRG="$0" 4getPrgDir
5while [ -h "${PRG}" ] ; do
6 ls=$(ls -ld "${PRG}")
7 link=`expr "${ls}" : '.*-> \(.*\)$'`
8 if expr "${link}" : '.*/.*' > /dev/null; then
9 PRG="${link}"
10 else
11 PRG=$(dirname "${PRG}")/"${link}"
12 fi
13done
14PRGDIR=$(dirname "${PRG}")
15pushd ${PRGDIR} >/dev/null
16PRGDIR=$(pwd)
17popd >/dev/null
18 5
19# Get the database credentials. 6# Get the database credentials.
20declare -A creds 7declare -A creds
diff --git a/scripts/backup-sims.sh b/scripts/backup-sims.sh
index fb18c18..2d174b1 100755
--- a/scripts/backup-sims.sh
+++ b/scripts/backup-sims.sh
@@ -1,25 +1,12 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Figure out where we are, most of this mess is to troll through soft links. 3source common.sh
4PRG="$0" 4getPrgDir
5while [ -h "${PRG}" ] ; do
6 ls=$(ls -ld "${PRG}")
7 link=`expr "${ls}" : '.*-> \(.*\)$'`
8 if expr "${link}" : '.*/.*' > /dev/null; then
9 PRG="${link}"
10 else
11 PRG=$(dirname "${PRG}")/"${link}"
12 fi
13done
14PRGDIR=$(dirname "${PRG}")
15pushd ${PRGDIR} >/dev/null
16PRGDIR=$(pwd)
17popd >/dev/null
18 5
19for i in $(seq 99) 6for i in $(seq 99)
20do 7do
21 j=$(printf "sim%02d" $i) 8 j=$(num2name ${i})
22 if [ -e "${PRGDIR}/../config/$j" ] 9 if [ -e "${PRGDIR}/../config/${j}" ]
23 then 10 then
24 cd ${PRGDIR}/../config/$j 11 cd ${PRGDIR}/../config/$j
25 ./backup-sim 12 ./backup-sim
diff --git a/scripts/common.sh b/scripts/common.sh
new file mode 100755
index 0000000..2ec19ce
--- /dev/null
+++ b/scripts/common.sh
@@ -0,0 +1,76 @@
1#!/bin/echo Don't run this file, it's for common functions."
2
3
4# Figure out where we are, most of this mess is to troll through soft links.
5# PRGDIR=$(getPrgDir)
6getPrgDir()
7{
8 PRG="$0"
9 while [ -h "${PRG}" ] ; do
10 ls=$(ls -ld "${PRG}")
11 link=`expr "${ls}" : '.*-> \(.*\)$'`
12 if expr "${link}" : '.*/.*' > /dev/null; then
13 PRG="${link}"
14 else
15 PRG=$(dirname "${PRG}")/"${link}"
16 fi
17 done
18 PRGDIR=$(dirname "${PRG}")
19 pushd ${PRGDIR} >/dev/null
20 export PRGDIR=$(pwd)
21 popd >/dev/null
22}
23
24
25# Convert number to sim name
26# name=$(num2name 1)
27num2name()
28{
29 # Using a string format, coz using a number format ends with an octal error, coz 08 isn't a valid octal number.
30 # Why isn't octal dead already?
31 printf 'sim%02s' "$1"
32}
33
34
35# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows.
36# name=$(sanitize "the name")
37sanitize()
38{
39 echo "$1" | sed -e 's/[\\/:\*\?"<>\|@#$%&\0\x01-\x1F\x27\x40\x60\x7F. ]/_/g' -e 's/^$/NONAME/'
40}
41
42
43# Grab the first Section line of the sims .xml file, cut it down to the name.
44# name=$(getSimName 1)
45getSimName()
46{
47 grep "<Section " ${PRGDIR}/../../config/$(num2name $1)/*.xml | head -n 1 | cut -d '"' -f 2
48}
49
50
51# Calculate size of the sleep @ one second per megabyte of combined I/OAR file sizes.
52# sleepPerSize o "the name"
53# sleepPerSize i "the name"
54sleepPerSize()
55{
56 type="$1"
57 name=$(sanitize "$2")
58
59 rm -f ${PRGDIR}/../../backups/${name}-sleepPerSize
60 for file in ${PRGDIR}/../../backups/${name}-*.${type}ar; do
61 if [ -f ${file} ]; then
62 # We only loop through them coz bash sucks, we can find the total size now and jump out of the loop.
63 echo $(du -c -BM ${PRGDIR}/../../backups/${name}-*.${type}ar | tail -n 1 | cut -f 1 | cut -d 'M' -f 1)
64 touch ${PRGDIR}/../../backups/${name}-sleepPerSize
65 break
66 fi
67 done
68
69 # Sleep 200 instead if we can't find any files.
70 if [ -f ${PRGDIR}/../../backups/${name}-sleepPerSize ]; then
71 rm -f ${PRGDIR}/../../backups/${name}-sleepPerSize
72 else
73 echo 200
74 fi
75}
76
diff --git a/scripts/gitAR.sh b/scripts/gitAR.sh
index 2a067be..25cab48 100755
--- a/scripts/gitAR.sh
+++ b/scripts/gitAR.sh
@@ -11,31 +11,16 @@
11 11
12# Not really meant to be called by users, so don't bother validating the input and such. 12# Not really meant to be called by users, so don't bother validating the input and such.
13 13
14source common.sh
15getPrgDir
16
14type=$1 17type=$1
15title=$2 18title=$2
16
17# Figure out where we are, most of this mess is to troll through soft links.
18PRG="$0"
19while [ -h "${PRG}" ] ; do
20 ls=$(ls -ld "${PRG}")
21 link=`expr "${ls}" : '.*-> \(.*\)$'`
22 if expr "${link}" : '.*/.*' > /dev/null; then
23 PRG="${link}"
24 else
25 PRG=$(dirname "${PRG}")/"${link}"
26 fi
27done
28PRGDIR=$(dirname "${PRG}")
29pushd ${PRGDIR} >/dev/null
30PRGDIR=$(pwd)
31popd >/dev/null
32
33date=$(date '+%F_%T') 19date=$(date '+%F_%T')
34 20
35# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows.
36name=$(echo "${title}" | sed -e 's/[\\/:\*\?"<>\|@#$%&\0\x01-\x1F\x27\x40\x60\x7F. ]/_/g' -e 's/^$/NONAME/')
37# Convert the type to uppercase. 21# Convert the type to uppercase.
38gar="_git$(echo -n ${type} | tr '[:lower:]' '[:upper:]')AR" 22gar="_git$(echo -n ${type} | tr '[:lower:]' '[:upper:]')AR"
23name=$(sanitize "${title}")
39 24
40if [ -d ${PRGDIR}/../../backups/temp_backup${type}_${name} ]; then 25if [ -d ${PRGDIR}/../../backups/temp_backup${type}_${name} ]; then
41 echo "WARNING - Mess left over from last backup, not gonna run!" 26 echo "WARNING - Mess left over from last backup, not gonna run!"
diff --git a/scripts/start-sim b/scripts/start-sim
index ed2b07f..72bb9ba 100755
--- a/scripts/start-sim
+++ b/scripts/start-sim
@@ -1,21 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Figure out where we are, most of this mess is to troll through soft links. 3source common.sh
4PRG="$0" 4getPrgDir
5while [ -h "${PRG}" ] ; do
6 ls=$(ls -ld "${PRG}")
7 link=`expr "${ls}" : '.*-> \(.*\)$'`
8 if expr "${link}" : '.*/.*' > /dev/null; then
9 PRG="${link}"
10 else
11 PRG=$(dirname "${PRG}")/"${link}"
12 fi
13done
14PRGDIR=$(dirname "${PRG}")
15pushd ${PRGDIR} >/dev/null
16PRGDIR=$(pwd)
17popd >/dev/null
18
19 5
20USER=$(whoami) 6USER=$(whoami)
21console_name="OpenSim_console" 7console_name="OpenSim_console"
@@ -78,7 +64,7 @@ if [ "x$tgt" = "xROBUST" ]; then
78elif [ "x$inventory" = "x" ]; then 64elif [ "x$inventory" = "x" ]; then
79 exe="OpenSim" 65 exe="OpenSim"
80 # Grab the first Section line of the sims .xml file, cut it down to the name. 66 # Grab the first Section line of the sims .xml file, cut it down to the name.
81 title=$(grep "<Section " ../config/${tgt}/*.xml | head -n 1 | cut -d '"' -f 2 ) 67 title=$(getSimName ${num})
82fi 68fi
83 69
84case $(basename $0) in 70case $(basename $0) in