The following document is a guide to start CAR component automatically. You need to make start and stop.sh and modify some configuration files in your Desktop environment. To simplify the management, you should create a scripts folder in your home folder (e.g. mkdir ~/demcare/scripts).
Summary :
- Creating start and stop scripts
- To start CAR with system startup
- Launching CAR from a remote computer
- Scheduled task to reboot the system
1 – Creating start and stop scripts
We assume you have created a folder scripts in your demcare folder , e.g.,
/home/username/demcare/scripts/
1.1 – Start script :
Create a file in your scripts folder called start.sh and add the following content :
#!/bin/bash Demcare_CAR=/usr/local/inria/sup/bin/sup-Demcare_CAR Config_Files=/home/inria/demcare/ConfigFiles/ # The video recording is optional, if not using you can comment the following parameter. Videos_Folder=/home/inria/asusdata/ $Demcare_CAR $Config_Files $Videos_Folder
Make the script able to be executable :
chmod ug+x start.sh
1.2 – Stop script :
You need to install wmctrl to close the sup-Demcare_CAR window properly :
yum install wmctrl
Create a file in your scripts folder called stop.sh and add the following content :
#!/bin/bash wmctrl -c "Demcare"
Make the script able to be executable :
chmod ug+x stop.sh
2 – To start CAR with system startup
2.1 – Add CAR to start after the session logging :
For a Gnome session,
mkdir ~/.config/autostart/
create new file :
nano ~/.config/autostart/start-car.desktop
and add the following content (adapt it for your installation) :
[Desktop Entry] Type=Application Exec=/home/username/demcare/scripts/start.sh Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name=CAR autostart Comment=Start CAR on the session startup
For another Desktop environment, you just need to found how to start a program on the session startup
2.2 – Activate the autologin for your user :
Certain installations do not allow you to do this with the first method below, choose then the second one.
If after following 2.1 or 2.2, the autologin still does not work, then follow 2.3
2.2.1) sudo gnome-control-center
under your username (e.g. inria) account, click on unlock on the top right and then click on the auto login option.
2.2.2) For a Gnome session, edit the file “/etc/gdm/custom.conf”, and add the following content under “daemon” section (adapt it for your installation) :
[daemon]
AutomaticLoginEnable=True AutomaticLogin=username
Replace username by the username used to run CAR. For another Desktop environment, you just need to found how to make autologin for an user.
2.2.3) If 22.1 or 222 does not work; do this:
sudo nano /etc/lightdm/lightdm.conf
and uncomment the 2 lines to have this (adapt to your username e.g. inria)
autologin-user=inria
autologin-user-timeout=0
3 – Launching CAR from a remote computer
3.1 – In CAR computer (Linux machine) :
Install OpenSSH Server (As root) :
yum install openssh-server
Start the daemon at the system startup (As root) :
chkconfig sshd on service sshd start
3.2 – In the remote computer :
You should have a SSH client on the Windows machine :
- Get and install PuTTY (or at least get Plink) from the download link.
Example of usage for the Dem@care system :
To start CAR from the remote machine, you should follow the steps bellow :
- Get the startCARprocess.cmd and stopCARprocess.cmd script for the Windows machine from the SVN (INRIA folder),
- Configure the script to adapt it for your usage.
Script configuration :
The default path to PuTTY is C:\Program Files (x86)\PuTTY.
In case you have installed in another place or only installed plink.exe you will need to add your path to plink.exe at the line 24 of both scripts.
Inside the script, set the following variables with the corresponding values for your installation :
- CARuser: CAR machine username.
- CARuser-pw: CAR machine user password .
Script usage :
The configuration by default allows you to start the script given the IP address as parameter, and assuming the machine has an user account called INRIA.
For instance, in the windows prompt, you can type:
C:\DEMCARE\INRIA_components> startCARprocess.cmd
or
C:\DEMCARE\INRIA_components> stopCARprocess.cmd
4 – Scheduled task to restart the system
You can have a scheduled task which will restart the system. Before following the next steps, you need :
4.1 Script to reboot the system :
Create a new script into your scripts folder, for instance :
touch /home/username/demcare/scripts/reboot.sh chmod ug+x /home/username/demcare/scripts/reboot.sh
Add the following content :
#!/bin/bash logFile="/home/username/demcare/log-car.txt" su username -c "DISPLAY=:0 /home/username/demcare/scripts/stop.sh" echo -e "$(date --iso-8601=seconds)\t The system will be restarted in 60s" >> $logFile sleep 60 reboot Make sure the log file accessible by everyone (create a blank one if non existant): sudo chmod 777 log-car.txt
This script call the stop.sh scripts to close the application, then add an entry in a log file about this.
Finally the system will reboot after 60s of waiting.
Replace by the user name which run CAR application.
4.2 Scheduled task (run by crontab) :
As root, create a new file into /etc/cron.d/ (for instance, named “reboot-car”) :
# Weekly system rebooting SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="" 59 11 * * mon,fri root DISPLAY=:0 /home/username/demcare/scripts/reboot.sh
Replace by the user name which run CAR application.
By using this task, each Monday and Friday at 11:59am, CAR will be stopped and the system will be restarted. (For more informations about Crontab, you can have a look on “man crontab”)