GNU screen with bash init script

I am sure that there is an answer to the screen in this manual, but I cannot find it! I want the bash shell spawned by the GNU screen to be the source in the file in addition to the already running .bashrc.

I can’t put the call into a file in .bashrc because on our site .bashrc files are automatically restored at login.

Any ideas?

EDIT:

I created this little script (screen_bash.sh):

bash --rcfile ~/.screen_bashrc

Then added

shell $HOME/screen_bash.sh

In my .screenrc

The file ~ / .screen_bashrc was

<my_setup_stuff>
export SHELL=bash

SHELL = bash is required so that programs such as vim can run sub-shells correctly.

+5
source share
3 answers

, , ? , shell , ( $SHELL), script , .

+4
screen bash --rcfile yourfile.rc

yourfile.rc .bashrc.

EDIT: , , , , , , , .

+2

, , . script . , ebuild Gentoo. github.

start() {

for SCREENRC in /etc/screen.d/* ; do 

    SESSION="$(basename $SCREENRC)"

    ## I don't think there may be a security issue,
    ## provided that users will not be have write
    ## permission in /etc/screen.d/ and if anyone
    ## gained access to mod the session file, they
    ## are in already anyhow!
    BELONGS="$(stat $SCREENRC --printf=%U)"

    MYSHELL="$(getent passwd $BELONGS | cut -d: -f7)"


    COMMAND="/usr/bin/screen -- -U -D -m -c ${SCREENRC} -S ${SESSION} -t ${SESSION}"

    ## Why on earth would one write this ???
    #HOMEDIR="$(getent passwd $BELONGS | cut -d: -f6)"

    ebegin "Starting screen session ${SESSION} for ${BELONGS}"

    PIDFILE="/var/run/screen.${BELONGS}.${SESSION}.pid"

    start-stop-daemon \
        --env TERM="rxvt" \
        --env HOME="~${BELONGS}" \
        --env SCREEN_SESSION=${SESSION} \
        --user $BELONGS \
        --chdir "~${BELONGS}" \
        --make-pidfile \
        --background \
        --pidfile=${PIDFILE} \
        --exec ${COMMAND}
    eend $?
done

}




stop() {

## Perhaps we should determin this by pidfiles ...
## but this way is not bad either!
for SCREENRC in /etc/screen.d/* ; do 

    SESSION="$(basename $SCREENRC)"
    BELONGS="$(stat $SCREENRC --printf=%U)"

    PIDFILE="/var/run/screen.${BELONGS}.${SESSION}.pid"
    PROCESS="$(cat ${PIDFILE})"

    if [ -e /proc/${PROCESS}/status ]; then

    grep -i "Name:" /proc/${PROCESS}/status | grep -iq "screen" || continue

    ebegin "Stopping screen session ${SESSION} for ${BELONGS} (PID: ${PROCESS})"

    ## There other things we can try here ...
    ## perhaps add /etc/screen.d/$SESSION.stop

    ## It will CERTAINly kill the righ screen!
    CERTAIN="${PROCESS}.${SESSION}"
    env TERM="urxvt" \
        start-stop-daemon \
            --user ${BELONGS} \
            --exec /usr/bin/screen -- -S $CERTAIN -X quit
    eend $?

    fi

    rm -f $PIDFILE

done
}
0

All Articles