Setup auto boot
Assumption in this tutorial: The restricted user for OpenSim is “maria”.
We copy the following script with the file name “maria-autostart.sh” as user root to /etc/systemd/system
. (You can select any filename and directory, we select the sake of clarity the directory containing the configuration file.) With this script, at boot time the self-made firewall script is called. Finally, the user is set to the restricted OpenSim account (here maria), and in whose home directory a file “autostart.sh” is called. There later the limited user can run programs at start-up.
vi /etc/systemd/system/maria-autostart.sh
#!/bin/sh # # /etc/systemd/system/maria-autostart.sh case $1 in start) bash /root/firewall.sh su maria -l -c 'bash autostart.sh' & ;; stop) ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac
Then we set execute permissions:
chmod u+x /etc/systemd/system/maria-autostart.sh
Thus, our script can be started as a service, it still needs a configuration file. Here, the directory /etc/systemd/system
is mandatory, the file extension .service
as well. So here we call the configuration file meaningful “maria-autostart.service”:
vi /etc/systemd/system/maria-autostart.service
[Unit] Description=At system boot start firewall and call autostart.sh of user. [Service] Type=oneshot ExecStart=/etc/systemd/system/maria-autostart.sh start ExecStop=/etc/systemd/system/maria-autostart.sh stop RemainAfterExit=yes [Install] WantedBy=multi-user.target
If both files are created, we must activate the service:
systemctl enable maria-autostart.service
Log in now with the limited user account, and in its home directory (here maria) create a text file named “autostart.sh”. For first, this file can be left empty, later it will be filled with the startup commands for OpenSim. Do this file creation not as user root, otherwise later the restricted user cannot modify the file.
Set execute permissions: “chmod u+x autostart.sh”
Computer boot up once a day
(To deepen see also: Wiki)
OpenSim is still in beta stage, and is sometimes not very stable. Therefore, the computer shall start anew each day. Paste the following line into the file /etc/crontab
:
0 6 * * * root shutdown -r now
The numbers give the time, here 6:00 o’clock.
Continued: Configuring MariaDB (or MySql)