From 4a1156f2802bda785e67a58893ba74517b672cc6 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 26 Nov 2011 14:35:08 +1000 Subject: Added screen support, plus some tweaks. --- install_opensim.sh | 22 +++++++++++++--- opensim.screenrc | 20 +++++++++++++++ start-sim-in-rest | 73 ++++++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 opensim.screenrc diff --git a/install_opensim.sh b/install_opensim.sh index 0c8c659..14d7c42 100755 --- a/install_opensim.sh +++ b/install_opensim.sh @@ -26,8 +26,10 @@ FLUSH PRIVILEGES; zzzzEOFzzz echo "Setting up OpenSim" -sudo deluser opensim +sudo deluser opensim --remove-home sudo adduser --system --shell /bin/false --group opensim +sudo cp opensim.screenrc /home/opensim/.screenrc +sudo chmod 744 /home/opensim/.screenrc sudo mkdir -p /var/log/opensim sudo chown opensim:opensim /var/log/opensim sudo chmod 777 /var/log/opensim @@ -38,7 +40,10 @@ sudo mkdir -p /opt/opensim sudo chown $USER:$USER /opt/opensim cd /opt/opensim -wget https://github.com/downloads/infinitegrid/InfiniteGrid-Opensim/opensim-0.7.1.1-infinitegrid-03.tar.bz2 +if [ ! -e opensim-0.7.1.1-infinitegrid-03.tar.bz2 ] +then + wget https://github.com/downloads/infinitegrid/InfiniteGrid-Opensim/opensim-0.7.1.1-infinitegrid-03.tar.bz2 +fi tar xjf opensim-0.7.1.1-infinitegrid-03.tar.bz2 ln -s opensim-0.7.1.1-infinitegrid-03 current mkdir -p config @@ -56,7 +61,6 @@ mv NSLModules.Messaging.MuteList.dll ../../modules/ ln -s ../../modules/NSLModules.Messaging.MuteList.dll NSLModules.Messaging.MuteList.dll mv OpenSimProfile.Modules.dll ../../modules/ ln -s ../../modules/OpenSimProfile.Modules.dll OpenSimProfile.Modules.dll -#sudo chown -R opensim:opensim ../../modules ln -s ../../config config cat > OpenSim.ConsoleClient.ini << zzzzEOFzzzz @@ -86,5 +90,17 @@ sed -i 's@; StorageProvider = "OpenSim.Data.MySQL.dll"@StorageProvider = "OpenSi sed -i "s@; ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=\*\*\*\*;\"@ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=$MYSQL_PASSWORD;\"@" GridCommon.ini cd ../../.. + +# Setting screen to be suid. EWWWWWW!!! Security hole!! +#ImReallyParanoid="true" +if [ "x$ImReallyParanoid" = "x" ] +then + sudo chmod u+s /usr/bin/screen + sudo chmod g+s /usr/bin/screen + sudo chmod 755 /var/run/screen + sudo chown root:utmp /var/run/screen +fi + #sudo chown -R opensim:opensim opensim-0.7.1.1-infinitegrid-03 +#sudo chown -R opensim:opensim modules diff --git a/opensim.screenrc b/opensim.screenrc new file mode 100644 index 0000000..01a4f26 --- /dev/null +++ b/opensim.screenrc @@ -0,0 +1,20 @@ +# C-a :source .screenrc + +termcapinfo xterm* ti@:te@ +startup_message off +vbell off +autodetach on +altscreen on +shelltitle "$ |bash" +defscrollback 10000 +defutf8 on +nonblock on + +hardstatus alwayslastline +hardstatus string '%{= kw}[ %{= kb}%H%{= kw} ][%= %{= kw}%?%-Lw%?%{= kW}%n*%f %t%?%?%{= kw}%?%+Lw%?%?%= ][ %{r}%l%{w} ]%{w}[%{r} %d/%m/%y %C %A %{w}]%{w}' + +bind 'q' quit + +multiuser on +acladd root + diff --git a/start-sim-in-rest b/start-sim-in-rest index d6aac2c..4738c2e 100755 --- a/start-sim-in-rest +++ b/start-sim-in-rest @@ -1,40 +1,87 @@ #!/bin/bash -osversion="current" -NeedARest=" -console=rest" +# Pick one of these depending on how you want your access. +# NOTE - REST does not work. B-( +#NeedARest=" -console=rest" NeedARest="" +Screaming="true" +#Screaming="" + +USER=$(whoami) + +console_name=screen_console +if [ "$USER" = "opensim" ] +then + screen_session=opensim/${console_name} + screen_check="screen -ls opensim/" +else + screen_session=${console_name} + screen_check="screen -ls" +fi +osversion="current" -if [ x$1 = x ]; then +if [ "x$1" = "x" ]; then pathname=$(pwd) tgt=$(basename $pathname) -elif [ -d ./$1 ]; then +elif [ -d "./$1" ]; then tgt=$1 -elif [ -d ./sim$1 ]; then +elif [ -d "./sim$1" ]; then tgt=sim$1 fi - -if [ x$tgt = x ]; then + +if [ "x$tgt" = "x" ]; then echo "usage:" echo " $ start-sim-in-rest " echo "where is one of: " robust sim[0-9][0-9] exit 1 fi -inidir=/opt/opensim/config/${tgt} -bindir=/opt/opensim/${osversion}/bin -if [ x$tgt = xrobust ]; then +if [ "x$Screaming" = "xtrue" ] +then + if ($screen_check | grep -q ${console_name}); then + echo "INFO: Screen already running" + true + else + echo "DEBUG: Starting screen" + screen -d -m -S ${console_name} + fi +fi + +if [ "x$tgt" = "xrobust" ]; then exe="Robust" else exe="OpenSim" fi +inidir=/opt/opensim/config/${tgt} +bindir=/opt/opensim/${osversion}/bin +cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" +# Check if it's already running. if [ ! -e /var/run/opensim/${tgt} ] then - cd ${bindir} - /usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest + if [ "x$Screaming" = "xtrue" ] + then + tmpfile=`mktemp` + echo "chdir ${bindir}" > ${tmpfile} + echo "screen -t ${tgt} ${cmd}" >> ${tmpfile} + chmod a+r ${tmpfile} + rm -f ${inidir}/start.screen + cp ${tmpfile} ${inidir}/start.screen + rm ${tmpfile} + # echo "INFO: start process and connect to screen (opensim)" + screen -r ${screen_session} -p "-" -X source ${inidir}/start.screen + else + cd ${bindir} + $cmd + fi fi -if [ "x$NeedARest" = x } +# Either way, need to start up the console after. +if [ "x$Screaming" = "xtrue" ] +then + echo "Starting screen client." + screen -r ${screen_session} -A +elif [ "x$NeedARest" != "x" ] then echo "Starting rest client." cd ${inidir} -- cgit v1.1