Comandi alla partenza su raspberrey

Pubblicità

S.t.e.r.l.o.k.

Utente Èlite
Messaggi
2,011
Reazioni
129
Punteggio
111
Ho un problema con una distro di debian,
non riesco ad automattizzare il lavoro, di conseguenza
avviare uno script .SH alla partenza automaticamente,
per fissare delle regole, altrimenti dovrei sempre ricordagliele :D

lo script e il seguente.... ciao


Codice:
#!/bin/sh

service network-manager stop
ifconfig wlan0 down
macchanger -r wlan0
ifconfig wlan0 up
ifconfig wlan1 down
macchanger -r wlan1
ifconfig wlan1 up
 
che errore ti da? o proprio non si avvia lo script?
Lo script è eseguibile?
Bash:
chmod +x script.sh
Lo script lo hai settatno in init.d o in rc.local?
 
ti dico come ho fatto, anche se non fa quel che dico....

sono andato qui:

Codice:
/etc/init.d

creato lo script sh con NANO....

attivato.....

Codice:
chmod +x mioscript.sh

poi ho mandato questo per farlo girare all'avvio in automatico:

Codice:
update-rc.d mioscript.sh defaults
 
tutto fatto con sudo immagino ( se no manco te lo avrebbe fatto creare ).
mmm
Se fai partire lo script manualmente, funziona e fa quello deve fare?
 
Prova a così
Bash:
sudo nano /etc/rc.local

Ci scrivi dentro questo

Bash:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.


service network-manager stop
ifconfig wlan0 down
macchanger -r wlan0
ifconfig wlan0 up
ifconfig wlan1 down
macchanger -r wlan1
ifconfig wlan1 up



exit 0
Per rendere eseguibile il file
Bash:
sudo chmod +x /etc/rc.local
ed infine per settarlo all'avvio
Bash:
sudo systemctl enable rc-local
 
mi ha dato un sacco di errori ma sembra funzioni...... ti incollo lo status dell'errroe...
li dentro posso metterci cio che voglio giusto?
Tanto per aggiungere comandi

Codice:
root@Desktop:~# systemctl enable rc-local
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.
 
ho visto che non spooffa il MAC e normale?

Gli altri comandi li prende tutti :suicidio:
--- i due messaggi sono stati uniti ---
devo darle il sudo? Che dici?
 
Ultima modifica:
Ma sta cosa deve farla all' avvio o quando decidi tu di volerla fare? Perché se la deve fare all' avvio, oltre a systemd ti basti mettere lo script che ho letto sopra in autostart (dis solito sta in ~/.config) altrimenti depositi lo script ''dove te pare'' es. ~/.Scripts) e ti crei un lanciatore o una voce nel menu e lo lanci col comando ''bash -c /dove/te/pare/nome_file.sh''
In teoria andrebbe in /usr/local/bin, ma visto che kali è ''na roba stramba''...boh!!

Con systemd invece devi creare il file.service, dirgli di aspettare per esempio che network sia avviato, puntare allo script oppure inserire i comandi nell' unit. Le altre vie sono più semplici per un nabbo.
 
Pubblicità
Pubblicità
Indietro
Top