-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelapse.service
34 lines (25 loc) · 1.02 KB
/
timelapse.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# This script is a systemd service for the timelapse script
# It will load the configuration file and execute the timelapse script
# The script will be executed as root if you add the service to systemd and enable it
# sudo systemctl daemon-reload
# sudo systemctl enable timelapse.service
# sudo systemctl start timelapse.service
[Unit]
Description=GoPro Timelapse Script
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=180
StartLimitBurst=3
[Service]
Type=simple
# Load configuration and execute script
ExecStart=/bin/bash -c "config_file='/home/timelapse/config/config.json'; username=$(jq -r .rpi.username $config_file); script_path=$(jq -r .rpi.path $config_file); work_dir=$(jq -r .rpi.work_dir $config_file); . /home/gopro_env/bin/activate && python $script_path"
Restart=on-failure
RestartSec=60
# root is easier, trust me
User=root
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
WorkingDirectory=/home/timelapse
[Install]
WantedBy=multi-user.target