Pi Zero Easy IoT

安価で簡単に IoT を始めよう! - Raspberry Pi Zero によるプログラミングレス IoT 環境データ収集

syncLog

syncLog is a systemd service (syncLog.service) for Raspbian Buster. This service task is to execute rsync and rclone command. (especially from when os system starting) with a specific configuration file on Raspbian Buster.

For example, if you make a syncLog configuration file in /boot/ (this area is able to read and write by using Windows or MacOS) and edit it, and insart microSD card into Raspberry Pi Zero and power on it, you can reset a configuration without user login to Raspbian Buster.

Installation

cd syncLog
sudo ./install

install command options

Example for install with customized env.sh

sudo ./install -c "configuration file path"  -s "status file path"

Example for initialize the env.sh

sudo ./install -i

Configuration

For reconfiguration, edit syncLogConfig.js. ( if installed with -c "another file path" , edit it. ) This configuration file is javascript source. (required by syncLog.js)

Example

syncLogConfig.js

/*
This is syncLog setting file (Javascript source).
Setting is array of objects. 
Followings are example of setting.

module.exports = [
  {
    type: 'rsync',                           //rsync
    intervalHours: 1,                        //execute interval hours
    source: '/home/pi/source_dir/',          //local source directory
    dest: '/boot/data/'                      //local distination directory
  }
  ,
  {
    type: 'rclone',                          //rclone
    intervalHours: 24,                       //execute interval hours
    rcloneConf: '/boot/rclone.conf',         //configuration file generated by rclone
    source: '/boot/data',                    //local directory
    destService: 'gdrive',                   //service name in rclone.conf
    destDir: 'data'                          //folder in cloud service
  }
];
*/

module.exports = [

];

As javascript source, exports array of setting objects (one is for rsync and another one is for rclone).

Both are check to execute every 1 hours passes from when this system starts, and on each executing, if on the cases both executed, rsync is executed before rclone.

And require another prepaired configuration file rcloneConf: "rclone.conf", this is a configuration file generated by rclone in Windows or MacOS or Linux etc.

Usage

sudo systemctl start syncLog.service
sudo systemctl enable syncLog.service

How to work

syncLog.service --ExecStart--> syncLog.sh

syncLog.sh --execute--> check.js
           --execute--> syncLog.js

Finally, syncLog.service is in service-activity(active) successfully.