2009-06-12 14 views
5

Sono sicuro che c'è una risposta a questo nel manuale sullo schermo, ma non riesco a trovarlo! Voglio che la shell bash generata dallo schermo GNU sia inclusa in un file in aggiunta a .bashrc che già esegue.Schermo GNU con script inith bash

Non riesco a effettuare una chiamata al file in .bashrc perché sul nostro sito i file .bashrc vengono rigenerati automaticamente all'accesso.

Qualche idea?

EDIT:

Ho creato questo piccolo script (screen_bash.sh):

bash --rcfile ~/.screen_bashrc 

poi aggiunti

shell $HOME/screen_bash.sh 

Con mia .screenrc

Il ~/.screen_bashrc il file era

<my_setup_stuff> 
export SHELL=bash 

SHELL = bash è necessario affinché programmi come vim possano avviare correttamente i sub-shell.

+0

Se lo script di init personalizzato sembra essere '.bash_profile' (come nel mio caso), allora il contenuto di' screen_bash.sh' è meglio come: 'bash --login' – janos

risposta

4

Vuoi che questo file venga acquisito ogni volta che viene aperta una nuova finestra? In tal caso, il comando shell consente di sovrascrivere ciò che viene eseguito quando si crea una nuova finestra (per impostazione predefinita è solo $ SHELL). Puoi impostare che questo sia uno script di tua scelta che alla fine esegua la shell.

+0

Grazie - questa e l'altra risposta mi hanno risolto. –

+0

puoi pubblicare la risposta. Ho la stessa domanda e non sono ancora sicuro su come richiamare il mio ~/.bash_profile da .screenrc –

2
screen bash --rcfile yourfile.rc 

yourfile.rc dovrebbe fonte .bashrc.

EDIT: Questo in realtà non fare quello che vuoi, ho appena capito che probabilmente vuole che si applica a tutte le conchiglie iniziate da schermo.

+0

Grazie - Ho messo la tua suggerimento nel mio .screenrc usando il comando shell (come descritto sopra) e ha funzionato. –

0

Lo stavo facendo prima, ma ora mi sono reso conto che è meglio eseguire come servizio di inizializzazione di sistema. Puoi trovare il mio script allegato a this bug report. Speriamo che sarà disponibile come parte dello ebuild dello schermo in Gentoo. Lo terrò aggiornato su 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 
}