Hauptinhalt

Text has to go here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
#
# for usage, run without arguments
#
# see ../README for setup instructions.
#
 
# Original code by Dave Coyle (http://coyled.com)
# Tweaks by Gwyneth Llewelyn (http://gwynethllewelyn.net/)
 
# Requires bash 4
 
# The original script assumed that you‘d be running one sim per instance,
#  and launch a different script per sim.
# These changes assume you have multiple instances with multiple sims,
#  and that instance names are launched all from the same place with
#  an unique identification for each
 
# List of valid instances. Make sure you add all of your instances here
declare -A instances
for index in <Region 1> <Region 2> <Region x>
do
        instances[$index]=1
done
 
show_help() {
    echo "Input: opensim {start|stop|open|restart|console} "
    echo -n "    for following Regions: "
    echo ${!instances[*]}
}
 
# Change <opensim_user> with your valid opensim user
check_user() {
    if [ $USER != '<opensim_user>' ]; then
        echo "Only <opensim_user> is allowed to use the script"
        exit 1
    fi
}
 
setup() {
    if [ ! $1 ]; then
        show_help
        exit 1
    else
        SIM=$1
    fi
 
# Change the directories inline with your installation directories
# The pid_dir must be set to the value, you used in OpenSim.exe.config
# within your regions path
if [[ ${instances[$SIM]} ]]; then
        MONO="mono"
        OPENSIM_DIR="/put/your/opensim_dir/here"
        PID="$OPENSIM_DIR/put/your/pid_dir/here${SIM}/${SIM}.pid"
        SCREEN="screen"
        GRID_DIR="./<grid_dir>"
        # set GRID_DIR to the subdirectory where your individual
        #  instance configuration is
    else
        echo "Region ${SIM} is unknown. Exit."
        exit 1;
    fi
}
 
do_start() {
    if [ ! $1 ]; then
        show_help
        exit 1
    else
        SIM=$1
    fi
 
    setup $SIM
    check_user
 
    cd ${OPENSIM_DIR}/bin && $SCREEN -S $SIM -d -m -l $MONO OpenSim.exe -hypergrid=true -inidirectory="$GRID_DIR/$SIM" -logconfig="$GRID_DIR/$SIM/OpenSim.exe.config"
}
 
do_kill() {
    if [ ! $1 ]; then
        show_help
        exit 1
    else
        SIM=$1
    fi
 
    setup $SIM
    check_user 
 
    if [ -f $PID ]; then
        kill -9 `cat $PID`
    else
        echo "Region ${SIM} PID not found."
        exit 1
    fi
}
 
do_console() {
    if [ ! $1 ]; then
        show_help
        exit 1
    fi
 
    setup $1
 
    cd ${OPENSIM_DIR}/bin && $SCREEN -S $SIM -d -m -l $MONO OpenSim.exe -hypergrid=true -inidirectory="$GRID_DIR/$SIM" -logconfig="$GRID_DIR/$SIM/OpenSim.exe.config"
}
 
do_open() {
if [ ! $1 ]; then
        show_help
        exit 1
    else
        SIM=$1
    fi
 
    setup $SIM
    check_user
 
    if [ -f $PID ]; then
        screen -r $SIM
    else
        echo "Region ${SIM} PID not found."
        exit 1
    fi
}
 
case "$1" in
    start)
        do_start $2
        ;;
    stop)
        do_kill $2
        ;;
    open)
    do_open $2
;;
    kill)
        do_kill $2
        ;;
    restart)
        do_kill $2
        do_start $2
        ;;
    console)
        do_console $2
        ;;
    *)
        show_help
        exit
        ;;
    esac