A tradução desta página ainda não está completa. Até lá, partes incompletas mostrarão o original em inglês.

Bash e Scripting

"Scripting" é a técnica de encadear comandos formando um procedimento automatizado e salvar isso em arquivos texto, chamados "scripts". Sempre que você executa um script os comandos são processados um após o outro, como se você os digitasse num Terminal.
Scripts podem executar simples comandos numa ordem específica, ou resultarem em sofisticadas peças de código que resolvem tarefas complexas.

index O Bash

Since scripts rely naturally a lot on the shell they are interpreted by, you should first familiarize yourself with the BASH that's used by Haiku. There are many resources online as it's a widely used shell. One nice document is Johan Jansson's Introduction to bash - a tutorial for bash under BeOS.
The Bash Reference Manual (PDF, 720 KiB) is a nice resource to get into the details.

index A Bíblia do Scripting

Depois de ter aprendido umas noções básicas sobre como trabalhar no shell, é hora de lentamente adentrar no mundo do scripting. Novamente, você encontrará muitos tutoriais e materiais de referência online como também em livrarias. Uma introdução muito boa que foi praticamente feita sob medida para o Haiku está disponível online, é o capítulo sobre scripting (PDF, 900kb) do livro BeOS Bible de Scot Hacker.

indexScripts no Haiku

Haiku used to have scripts for booting and shutting down. Today it uses the launch_daemon instead. However, the user can still augment this process with certain user scripts. If they don't exist already, you'll have to create the needed files yourself. Otherwise simply add your commands where in the process you want them to be executed.

index O UserBootscript

/boot/home/config/settings/boot/UserBootscript will be executed after the system has finished its boot process. For example, you could launch a number of programs that would then be automatically started on every boot up:

# Iniciar o LaunchBox
/boot/system/apps/LaunchBox &

# Iniciar o Applet Workspaces
/boot/system/apps/Workspaces &

Lembre-se de terminar o comando com um "&" para iniciá-lo como um processo em segundo plano (background process), ou o script ficará suspenso até este comando ter sido concluído (neste caso: o aplicativo aberto ser fechado novamente).

A simple alternative to the above for launching applications at boot up is to put links to them in the /boot/home/config/settings/boot/launch directory. This can be done simply by right-clicking on the application you wish to have started automatically, going to Create Link and then navigating to the above directory.

index The UserShutdownScript - not yet working

/boot/home/config/settings/boot/UserShutdownScript will be executed as the first step in the shutdown process. If the script returns a non-zero exit status, the shutdown is aborted.

index The UserShutdownFinishScript - not yet working

/boot/home/config/settings/boot/UserShutdownFinishScript is executed as the last step in the shutdown process. Note, that most parts of the system have terminated by the time this script is executed.