rocrail-linux-user-en
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | rocrail-linux-user-en [2022/02/28 19:09] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Auto start in user context ====== | ||
| + | [[: | ||
| + | [[english | Content ]] -> [[english# | ||
| + | \\ | ||
| + | |||
| + | {{: | ||
| + | \\ | ||
| + | |||
| + | | //The user **pi** is used in the examples. \\ This is the preferred way to start the Rocrail Server automatically after reboot instead of running it as daemon in root context.// | | ||
| + | |||
| + | \\ | ||
| + | |||
| + | =====Introduction===== | ||
| + | If the Rocrail Server runs on a dedicated computer like the Raspberry Pi, it would be helpful if the Server starts automatically after every reboot in user context.\\ | ||
| + | There are several ways to establish this, but the crontab solution is very easy to implement.\\ | ||
| + | |||
| + | \\ | ||
| + | =====Start script===== | ||
| + | The provided '' | ||
| + | This provided version supports also functions of the __**[[: | ||
| + | ==== A start script from scratch === | ||
| + | Create a start script, **startrocrail.sh** in the home directory of user **pi** by opening an editor like **vi startrocrail.sh**: | ||
| + | <code bash> | ||
| + | #!/bin/sh | ||
| + | cd / | ||
| + | / | ||
| + | </ | ||
| + | Make the script executable: | ||
| + | <code bash> | ||
| + | chmod +x startrocrail.sh | ||
| + | </ | ||
| + | |||
| + | ====Shutdown option==== | ||
| + | | //Use this option first if everything runs perfect.// \\ //User **pi** is supposed to be a sudoer.// | | ||
| + | To automatically shutdown the computer after the Rocrail Server did stop, add the following line to the **startrocrail.sh** script: | ||
| + | <code bash> | ||
| + | if [ $? -eq 70 ] | ||
| + | then | ||
| + | echo raspberry | sudo -S halt -p | ||
| + | fi | ||
| + | </ | ||
| + | The echo statement is followed by the password of the user. In this case its " | ||
| + | | Rocrail will return 70 in case of a client shutdown command. A kill will return zero. | | ||
| + | \\ | ||
| + | |||
| + | =====CronTab===== | ||
| + | Add the following line at the end of the crontab list of user **pi** with the command **crontab -e**: | ||
| + | <code bash> | ||
| + | @reboot / | ||
| + | </ | ||
| + | Or directly on the command line: | ||
| + | <code bash> | ||
| + | (crontab -l ; echo " | ||
| + | </ | ||
| + | |||
| + | Check the crontab: | ||
| + | <code bash> | ||
| + | crontab -l | ||
| + | </ | ||
| + | Output: | ||
| + | <code bash> | ||
| + | # For more information see the manual pages of crontab(5) and cron(8) | ||
| + | # | ||
| + | # m h dom mon dow | ||
| + | @reboot / | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | =====Stop the Rocrail Server===== | ||
| + | | //A normal shutdown of the computer will issue to all running processes a kill command which also will shutdown the Rocrail Server normally.// | | ||
| + | ====Rocview==== | ||
| + | * __**[[: | ||
| + | |||
| + | ====Rocweb==== | ||
| + | * __**[[: | ||
| + | |||
| + | ====andRoc==== | ||
| + | * System: Shutdown server.\\ | ||
| + | |||
| + | ====Monitor==== | ||
| + | * __**[[: | ||
| + | |||
| + | ====SSH Shell==== | ||
| + | < | ||
| + | killall rocrail | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | =====Provided startrocrail.sh ===== | ||
| + | <code bash> | ||
| + | #!/bin/sh | ||
| + | WS=$1 | ||
| + | PASSWORD=$2 | ||
| + | cd | ||
| + | if [ ! $1 ]; then | ||
| + | cd ~/ | ||
| + | else | ||
| + | cd ~/ | ||
| + | fi | ||
| + | ~/ | ||
| + | if [ $? -eq 70 ] | ||
| + | then | ||
| + | echo $PASSWORD | sudo -S halt -p | ||
| + | fi | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
rocrail-linux-user-en.txt · Last modified: 2022/02/28 19:09 by 127.0.0.1