Eu tenho um pequeno script para iniciar um servidor fluidsynth e conectá-lo ao meu dispositivo midi no meu rasberry (o sistema operacional é raspbian stretch lite).
echo "Starting"
fluidsynth -is -a alsa --gain 3 /usr/share/sounds/sf2/Nice-Keys-B-Plus-JN1.4.sf2 &
echo "Fluidsynth started"
while true; do aconnect -o; if [[ $(aconnect -o ) = *FLUID* ]]; then break; fi; sleep 2; done
aconnect 20:0 128:0
echo "Connected"
O aconnect -o fora da condição é para depuração.
Quando executei normalmente (./startup_fluid_synth.sh) funcionou bem:https://pastebin.com/kU0wDu3w
Meu crontab -e diz:
@reboot /home/pi/startup_fluid_synth.sh >> /home/pi/fluid.log
Agora, quando eu reinicializo o pi, os scripts são iniciados, mas o log mostra claramente que a condição deveria ser atendida, mas não é:https://pastebin.com/FnxMKBkF
Alguma idéia de por que isso poderia ser?
Atualizar: O log de erros mostra:
/home/pi/startup_fluid_synth.sh: 4: /home/pi/startup_fluid_synth.sh: [[: not found
É possível que o cron não conheça o comando [[]] de alguma forma?
Responder1
Adicionar #!/bin/bash ao arquivo .sh resolveu o problema.
#!/bin/bash
echo "Starting"
/usr/bin/fluidsynth -is -a alsa --gain 3 /usr/share/sounds/sf2/Nice-Keys-B-Plus-JN1.4.sf2 &
echo "Fluidsynth started"
while true; do /usr/bin/aconnect -o; if [[ $(/usr/bin/aconnect -o ) = *FLUID* ]]; then break; fi; sleep 2; done
/usr/bin/aconnect 20:0 128:0
echo "Connected"