| Ligne 42 : |
Ligne 42 : |
| | | | |
| | # Utiliser {{fname|sudo raspi-config}} pour '''logger automatiquement votre pi en {{underline|mode console}}''' | | # Utiliser {{fname|sudo raspi-config}} pour '''logger automatiquement votre pi en {{underline|mode console}}''' |
| − | # Ecrire un fichier {{fname|/home/pi/my_app/my_app.sh}} qui contient de quoi démarrer votre application | + | # Ecrire un fichier {{fname|/home/pi/my_app/my_app.sh}} qui contient de quoi démarrer votre application.<br />C'est à la fois pratique durant vos développements et facilite le démarrage |
| | | | |
| | <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| Ligne 61 : |
Ligne 61 : |
| | cd - | | cd - |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | + | |
| | + | # Modifiez le fichier {{fname|.baschrc}} |
| | + | |
| | + | Rendez vous dans votre répertoire home, puis éditez votre fichier {{fname|.bashrc}} |
| | + | |
| | + | <syntaxhighlight lang="bash"> |
| | + | cd ~ |
| | + | nano .bashrc |
| | + | </syntaxhighlight> |
| | + | |
| | + | ajoutez la section similaire à celle ci-dessous pour démarrer automatiquement votre script {{fname|my_app.sh}}. |
| | + | |
| | + | <syntaxhighlight lang="bash"> |
| | + | # starts my_app (if not started yet) |
| | + | ps -a | grep -v grep | grep my_app.sh > /dev/null |
| | + | result=$? |
| | + | if [ "${result}" -eq "0" ] |
| | + | then echo "MY_APP is already running!" |
| | + | else |
| | + | tty | grep tty1 > /dev/null |
| | + | result=$? |
| | + | if [ "${result}" -eq "0" ] |
| | + | then |
| | + | echo "MY_APP starting..." |
| | + | sudo /home/pi/my_app/my_app.sh & |
| | + | else |
| | + | echo "MY_APP not started (autostart reserved to tty1)" |
| | + | fi |
| | + | fi |
| | + | </syntaxhighlight> |
| | + | |
| | | | |
| | <hr /> | | <hr /> |
| | | | |
| | {{MCH-Accord}} | | {{MCH-Accord}} |