Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
..continuare uno script dopo il chroot?? [risolto]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Sat Apr 02, 2005 11:23 pm    Post subject: ..continuare uno script dopo il chroot?? [risolto] Reply with quote

ciao a tutti...
mi chiedevo come e se è possibile continuare uno script dopo essere entrato in chroot...


Last edited by Tiro on Sun Apr 03, 2005 2:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
neryo
Veteran
Veteran


Joined: 09 Oct 2004
Posts: 1292
Location: Ferrara, Italy, Europe

PostPosted: Sun Apr 03, 2005 12:11 am    Post subject: Re: ..continuare uno script dopo il chroot?? Reply with quote

Tiro wrote:
ciao a tutti...
mi chiedevo come e se è possibile continuare uno script dopo essere entrato in chroot...


cioe' cosa intendi dire??
_________________
cache: a safe place for hiding or storing things..

D-link DWL-G650 AirPlus
Apache Php Mysql
Back to top
View user's profile Send private message
codadilupo
Advocate
Advocate


Joined: 05 Aug 2003
Posts: 3135

PostPosted: Sun Apr 03, 2005 12:38 am    Post subject: Re: ..continuare uno script dopo il chroot?? Reply with quote

neryo wrote:
Tiro wrote:
ciao a tutti...
mi chiedevo come e se è possibile continuare uno script dopo essere entrato in chroot...


cioe' cosa intendi dire??


siccome sa perfettamente cosa vuole fare per l'installazione, vorrebbe scrivere un script che la automatizzi, ma si trova davanti l'ostacolo che, dopo il chroot, lo script non continua finché non ne esci.... giusto ;-) ?

Coda
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Sun Apr 03, 2005 2:44 am    Post subject: Reply with quote

quando chrootti dovrebbe esegure .bashrc o .rc prova!
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
xchris
Advocate
Advocate


Joined: 10 Jul 2003
Posts: 2824

PostPosted: Sun Apr 03, 2005 7:51 am    Post subject: Reply with quote

ai tempi avevo risolto con un sistema poco elegante ma funzionante.
Lo script lo copi/metti anche nella dir di chroot.

Prima di fare chroot crei un file "chroot.in" oppure usa un qualsiasi altro controllo.

Quando entri in chroot gli fai startare lo script subito.

Rilevi questo fantomatico file (o quello che vuoi tu) e capisci di essere nella parte di chroot.

mi sono spiegato male eh? scusa ma sono sveglio da poco :)
_________________
while True:Gentoo()
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Sun Apr 03, 2005 10:53 am    Post subject: Reply with quote

si è il .bashrc.. ;)
non ho capito bene come faccio a fargli eseguire chroot.in..oltre che a metterlo dentro il .bashrc ;)
il fatto è che non è un'installazione bensì una prigione dove faccio girare apache ed mldonkey e quando avvio la macchina vorrei mettere uno script in /etc/conf.d/local.start in modo che mi inizializzi anche i servizi dentro il chroot...quindi mi suggerite di fare:

Code:

#echo "chroot /mnt/hardened /bin/bash" >> /etc/conf.d/local.start
#echo "bash /chroot.in" >> /mnt/hardened/root/.bashrc


dove chroot.in è il mio script all'interno del quale ci metto tutto quello che voglio:

Quote:

source /etc/profile
env-update
/etc/init.d/apache2 start
/etc/init.d/mldonkey start
echo "last chroot"`date` > chroot.date
ecc..
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Sun Apr 03, 2005 11:54 am    Post subject: Reply with quote

in realtà questo metodo è ok se mi devo chrootare una sola volta ma se dovessi chrootarmi n volte sarebbe un problema tutte le volte ricordarsi di commentare chroot.in ... :roll:
Back to top
View user's profile Send private message
.:chrome:.
Advocate
Advocate


Joined: 19 Feb 2005
Posts: 4588
Location: Brescia, Italy

PostPosted: Sun Apr 03, 2005 12:00 pm    Post subject: Reply with quote

Tiro wrote:
in realtà questo metodo è ok se mi devo chrootare una sola volta ma se dovessi chrootarmi n volte sarebbe un problema tutte le volte ricordarsi di commentare chroot.in ... :roll:


piccola variante:
la sintassi di chroot é questa (preso da man chroot):
Code:
chroot <path> {optional program to run}

specifichi quindi
Code:
 chroot <where> runscript
dove runcript è uno script bash che fa quello che vuoi. lui si arrangia a chiamare la bash e tutti sono felici e contenti
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Sun Apr 03, 2005 1:22 pm    Post subject: Reply with quote

esattamente quello che andavo cercando...!! :) grazie! ;)
Back to top
View user's profile Send private message
n3m0
l33t
l33t


Joined: 08 Feb 2004
Posts: 798
Location: Richville, Naples, Italy, Europe

PostPosted: Sun Apr 03, 2005 1:28 pm    Post subject: Reply with quote

Tiro wrote:
esattamente quello che andavo cercando...!! :) grazie! ;)


Sì, ma se non erro, il "program to run" deve avere un percorso a partire dalla nuova root. Mi spiego.
Se dai:

Code:
# chroot /mnt/nuovaroot /bin/mioscript.sh


mioscript.sh deve trovarsi (secondo la vecchia root), in /mnt/nuovaroot/bin/mioscript.sh.
_________________
L’energia è la civiltà. Lasciarla in mano ai piromani/petrolieri è criminale. Perché aspettare che finisca il petrolio?
L’età della pietra non è mica finita per mancanza di pietre. - B.G.


Site/Blog: http://www.neminis.org
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Sun Apr 03, 2005 2:54 pm    Post subject: Reply with quote

esatto infatti ho risolto così:

Code:
# echo "chroot /mnt/hardened /start-script" >> /etc/conf.d/local.start


e
Code:

# cat /mnt/hardened/start-script
/etc/init.d/ssh2 start
/etc/init.d/mldonkey start
 ecc..



in modo che ad ogni riavvio dello script /etc/init.d/local mi si riavviino anche i servizi in chroot (utile al boot 8) ) e allo stesso tempo mi posso chrootare in /mnt/hardened senza stare a togliere e mettere ogni volta i comandi nel .bashrc :)
un'ulteriore rifinitura sarebbe creare uno script /etc/init.d/hardservices nel quale viene inserito appunto

Quote:
chroot /mnt/hardened /start-script


ma questi sono solo particolari... ;)
Back to top
View user's profile Send private message
.:chrome:.
Advocate
Advocate


Joined: 19 Feb 2005
Posts: 4588
Location: Brescia, Italy

PostPosted: Sun Apr 03, 2005 3:53 pm    Post subject: Reply with quote

n3m0 wrote:
Tiro wrote:
esattamente quello che andavo cercando...!! :) grazie! ;)


Sì, ma se non erro, il "program to run" deve avere un percorso a partire dalla nuova root. Mi spiego.
Se dai:

Code:
# chroot /mnt/nuovaroot /bin/mioscript.sh


mioscript.sh deve trovarsi (secondo la vecchia root), in /mnt/nuovaroot/bin/mioscript.sh.


sì, esattamente... chiedo scusa se sono stato impreciso, ma vedo che il destinatario del messaggio ha capito lo stesso :wink:
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Wed Apr 20, 2005 8:26 pm    Post subject: Reply with quote

e se volessi avviare di seguito un altro script sempre dentro il chroot ma da utente normale? ad es per avviare un programma p2p?
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Thu Apr 21, 2005 10:17 am    Post subject: Reply with quote

Da dentro il primo script fai:

Code:

....
su utente
script_name
...

_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
Tiro
l33t
l33t


Joined: 14 Feb 2003
Posts: 752
Location: italy

PostPosted: Thu Apr 21, 2005 11:34 am    Post subject: Reply with quote

azz...essendo un chroot hardened non c'è il comando su! lo emergo oppure esiste un altro metodo? :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum