You are not logged in.

#1 2010-03-01 20:40:57

ould
Member
Registered: 2007-05-22
Posts: 124

Help with auto starting gnu screen

Hi everyone,

Second question. :-)

I like to have my gnu screen session start up at boot and tried to write an RC.D script which does start up screen with no problems but it can't seem to kill screen at shutdown. I know the solution must be fairly simple but I can't seem to get it to work properly.

Here is my screend script:

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting screen"
    su - kevin -c 'screen -dm' &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon screend
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping screen"
    killall -s 2 'SCREEN -dm'  &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon screend
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

I have tried various iterations of the "killall" line in the above script i.e. screen, SCREEN, etc. Shutdown always fails. Should I be instead killing the programs that are running inside of screen? rtorrent, sickbeard and htop, plus the 3 bash shells?

Here is the output of "ps aux | grep SCREEN":

root      3866  0.0  0.0   4540  1588 ?        Ss   Feb26   0:02 SCREEN -dm

Here is my .screenrc if needed:

activity ""
altscreen on
autodetach on
defbce on
deflogin on
defflow off
defscrollback 2048
defutf8 on
msgwait 1
nonblock on
vbell on
vbell_msg "   Wuff  ----  Wuff!!  "
# terminfo and termcap for nice 256 color terminal
termcapinfo xterm*|rxvt-* 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
termcapinfo xterm*|rxvt-* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'
termcapinfo xterm*|rxvt-* ti@:te=\E[3J
termcapinfo xterm*|rxvt-* hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l
termcapinfo xterm*|rxvt-* hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l
attrcolor b ".I"        # allow bold colors - necessary for some reason
term 'xterm-256color'   # 256 terminal for xterm
#term screen-256color   #By default, screen uses an 8-color terminal emulator. Use the following line to enable more colors, more-capable terminal emulator:
#termcapinfo xterm* ti@:te@
startup_message off
#remove some stupid / dangerous key bindings
bind ^k
#bind L
bind ^\
#make them better
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history


hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][ %{B}%Y-%m-%d %{W}%c %{g}]'
term screen-256color
bind c screen 1
bindkey -k k8 next
bindkey -k k7 prev
bindkey -k k9 detach

screen -t bash        1
screen -t bash        2
screen -t bash        3
screen -t rtorrent    4 rtorrent
screen -t sickbeard   5 sickbeard
screen -t htop        6 htop

Any help would be appreciated.

Thanks,

Kevin

Offline

#2 2010-03-01 21:31:50

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: Help with auto starting gnu screen

i dont see why you need to start screen from an rc script.

as far as i know, screen should run as the user.

what i did is add this to the end of ~/.bashrc

# start screen (wheee!!)
if [ $TERM != "screen-256color" ] ; then
   screen -d -R
fi

Offline

#3 2010-03-01 21:48:28

ould
Member
Registered: 2007-05-22
Posts: 124

Re: Help with auto starting gnu screen

I could give that a try. I like to have screen just start detached on my local machine and have it auto attach if I connect by SSH, I guess I could use your method and have it start detached locally. I just thought it more "correct" to have it start from an RC script for some reason, mainly as I want to make sure "rtorrent" and "sickbeard" are running at startup as I need them running all the time.

Kevin

Offline

#4 2010-03-01 22:03:31

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: Help with auto starting gnu screen

ould wrote:

I could give that a try. I like to have screen just start detached on my local machine and have it auto attach if I connect by SSH, I guess I could use your method and have it start detached locally. I just thought it more "correct" to have it start from an RC script for some reason, mainly as I want to make sure "rtorrent" and "sickbeard" are running at startup as I need them running all the time.

Kevin

hmmm, from what you posted, screen is being owned by root. you should try and fix that.

your script shouldnt need to kill screen, since it will be killed during shutdown anyway.

Offline

Board footer

Powered by FluxBB