grml-screen: do not use & for redirecting output since it is running inside dash.
[grml-scripts-core.git] / usr_bin / grml-screen
1 #!/bin/dash
2 # Filename:      grml-screen
3 # Purpose:       wrapper for screen to start with appropriate configuration
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 # export variable USER for use withing GNU screen:
10   export USER=`id -un`
11
12 # fix tty permissions
13   TTY=`tty`
14   sudo chmod 660       $TTY
15   sudo chown $USER.tty $TTY
16
17 # try to mitigate raceconditions from screen
18 SCREENDIR_="/var/run/screen"
19 if [ `id -u` = 0 ] ; then
20     mkdir -m 755 $SCREENDIR_ >/dev/null 2>& 1 && chgrp utmp $SCREENDIR_
21 fi
22 mkdir -m 700 "${SCREENDIR_}/S-$USER" >/dev/null 2>&1
23
24 # now run screen with config
25   cd $HOME     # important for e.g. hardcopy-feature
26
27   if [ `id -u` = 0 ] ; then
28     exec screen -U -c /etc/grml/screenrc
29   elif [ -r "$HOME/.screenrc" ] ; then
30     exec screen -U -c "$HOME/.screenrc"
31   else
32     exec screen -U -c /etc/grml/screenrc_grml
33   fi
34
35 ## END OF FILE #################################################################