aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/start-sim
diff options
context:
space:
mode:
authorDavid Walter Seikel2011-11-28 04:53:09 +1000
committerDavid Walter Seikel2011-11-28 04:53:09 +1000
commit554583496a2fdd3b9399c73a7fc526f99956e5bc (patch)
treeac2bb5d813f39b239179560855a15eceb4cf8682 /start-sim
parentNo need to deal with ownership and perms, the install script does that now. (diff)
downloadIGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.zip
IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.gz
IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.bz2
IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.xz
Backup sim regularly.
Rest don't work, screen would be better even if it did work. New scripts for stopping the sim, backing up the sim, and showing the console. Monit script works now.
Diffstat (limited to 'start-sim')
-rwxr-xr-xstart-sim83
1 files changed, 40 insertions, 43 deletions
diff --git a/start-sim b/start-sim
index dbb1beb..ea77553 100755
--- a/start-sim
+++ b/start-sim
@@ -1,12 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Pick one of these depending on how you want your access.
4# NOTE - REST does not work. B-(
5#NeedARest=" -console=rest"
6NeedARest=""
7Screaming="true"
8#Screaming=""
9
10USER=$(whoami) 3USER=$(whoami)
11console_name="OpenSim_console" 4console_name="OpenSim_console"
12screen_session=opensim/${console_name} 5screen_session=opensim/${console_name}
@@ -32,7 +25,7 @@ fi
32 25
33if [ "x$tgt" = "x" ]; then 26if [ "x$tgt" = "x" ]; then
34 echo "usage:" 27 echo "usage:"
35 echo " $ start-sim-in-rest <sim>" 28 echo " $ $(basename $0) <sim>"
36 echo "where <sim> is one of: " robust sim[0-9][0-9] 29 echo "where <sim> is one of: " robust sim[0-9][0-9]
37 exit 1 30 exit 1
38fi 31fi
@@ -49,15 +42,10 @@ export MONO_PATH=${bindir}
49# Then we would not have to do this, and subsequently write all over the damn bin directory. 42# Then we would not have to do this, and subsequently write all over the damn bin directory.
50cd ${bindir} 43cd ${bindir}
51 44
52if [ "x$Screaming" = "xtrue" ] 45if ($screen_check | grep -q ${console_name}); then
53then 46 true
54 if ($screen_check | grep -q ${console_name}); then 47else
55 echo "INFO: Screen already running" 48 $SUDO screen -d -m -S ${console_name}
56 true
57 else
58 echo "DEBUG: Starting screen"
59 $SUDO screen -d -m -S ${console_name}
60 fi
61fi 49fi
62 50
63if [ "x$tgt" = "xrobust" ]; then 51if [ "x$tgt" = "xrobust" ]; then
@@ -67,33 +55,42 @@ else
67fi 55fi
68 56
69inidir=/opt/opensim/config/${tgt} 57inidir=/opt/opensim/config/${tgt}
70cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" 58# Grab the first line of the sim.ini file, it should be the sim name in square brackets.
71title=$(head -n 1 ${inidir}/Regions/sim.ini ) 59title=$(head -n 1 ${inidir}/Regions/sim.ini )
60# Strip off spaces at either end.
61shopt -s extglob
62title=${title##*( )}
63title=${title%%*( )}
64shopt -u extglob
65# Strip off the square brackets at either end.
66title=${title:1:$(( ${#title} - 2 ))}
72 67
73# Check if it's already running. 68case $(basename $0) in
74if [ ! -e /var/run/opensim/${tgt}.pid ] 69 "start-sim")
75then 70 cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config"
76 if [ "x$Screaming" = "xtrue" ]
77 then
78 echo "INFO: start process and connect to screen (opensim) $title"
79 $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd}
80 else
81 $cmd
82 fi
83fi
84 71
85if [ "x$quiet" = "x" ] 72 # Check if it's already running.
86then 73 if [ ! -e /var/run/opensim/${tgt}.pid ]
87 # Either way, need to start up the console after. 74 then
88 if [ "x$Screaming" = "xtrue" ] 75 $SUDO screen -r ${screen_session} -p "-" -X screen -t "[${title}]" ${cmd}
89 then 76 fi
90 echo "Starting screen client." 77 ;&
91 screen -r ${screen_session} -A 78
92 elif [ "x$NeedARest" != "x" ] 79 "sim-console")
93 then 80 if [ "x$quiet" = "x" ]
94 echo "Starting rest client." 81 then
95 cd ${inidir} 82 screen -r ${screen_session} -p "[${title}]" -A
96 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config 83 fi
97 fi 84 ;;
98fi 85
86 "backup-sim")
87 # Substitute underscores for spaces in the title, then add the full date and time to create the OAR file name.
88 cmd="save oar ${inidir}/../../backups/${title// /_}-$(date '+%F_%T').oar"
89 sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "${cmd}$(/bin/echo -ne '\015')"
90 ;;
91
92 "stop-sim")
93 sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "shutdown$(/bin/echo -ne '\015')"
94 ;;
95esac
99 96