SSH Project Synchronization for the Raspberry Pi!
SyncPi is a utility script to remotely configure a Raspberry Pi to initialize and develop projects. It uses SSH to synchronize settings, packages and directories to get a project up and running!
- Install and maintain APT packages from a list
- Append firmware settings to the Pi's configuration
- Register a systemd service to run the project on startup
- Upload necessary project files and folders to the Pi
-
A bootable SD card can be prepared with the Raspberry Pi Imager
-
"Raspberry Pi OS Lite" is recommended for headless projects where no desktop environment is required
-
General
- Set a unique hostname to differentiate from other devices on the network
- Set the user and change the default password
- Set the wireless LAN to connect to your wifi
- Set locale settings to match your timezone
-
Services
- Enable SSH!
- Use password authentication
- If desired, authorized public keys can be provided instead
-
Add the script files under a new folder in the root of your project (such as
.syncpi/
)sync.sh
- SyncPi utility POSIX Shellscript.env.example
- Template environments file.gitignore
- File patterns to ignore in git
-
Make a copy of
.env.sample
and rename it to.env
in the same folder- Set your environment values in the new
.env
file:- Set the value of
SSH_USER
to the Pi's username (ex:pi
) - Set the value of
SSH_SERVER
to the Pi's hostname (ex:raspberrypi.local
)
- Set the value of
- Additional default values can be saved in the
.env.sample
file for future use
- Set your environment values in the new
-
Mark the SyncPi script as executable:
chmod +x sync.sh
-
Run the SyncPi script once to create the additional configuration files:
./sync.sh
-
If requested, log in to the device to add your SSH public key
-
If a public key hasn't been created yet, you can make a new one by running this command in a new terminal:
ssh-keygen -t rsa
-
Configuration files will be created in a config/
folder next to the script. These files should be added to the project's git history.
Packages in this list will be installed via APT on the remote device. Packages installed by this script will be removed if they are no longer in this list.
- To disable this feature, set envrionment
SKIP_PACKAGES
totrue
- To prevent automatically upgrading packages, set
SKIP_PACKAGES_UPGRADE
totrue
- To prevent removing previously installed packages, set
SKIP_PACKAGES_REMOVAL
totrue
The content in this file will be added to the config.txt
file in the remote device. Modifications to this file will update the previously added content. Updates to the configuration will trigger a reboot to apply those changes.
- To disable this feature, set envrionment
SKIP_FIRMWARE
totrue
- To prevent automatic reboots, set
SKIP_REBOOT_DEVICE
totrue
The systemd service definition in this file will be copied over and registered to the remote device. Modifications to this service file will be updated in the registered service.
The default service is configured to run ~/autostart
after a normal reboot.
- Set environment
SERVICE_NAME
to change the default name (defaults tostartup
) - To disable this feature, set envrionment
SKIP_SERVICE
totrue
- To prevent the service from stopping, set
SKIP_SERVICE_STOP_BEFORE_SCRIPT
totrue
- To prevent the service from restarting, set
SKIP_SERVICE_START_AFTER_SCRIPT
totrue
Targeted files and folders in the project will be uploaded using rsync. Source paths relative to the project root will be uploaded to the specified target paths on the remote device.
- Set environment
SYNC_CHMOD
to change the default permissions (defaults toD755,F755
) - Set environment
SYNC_CHOWN
to change the default owning user (defaults to the SSH user) - To disable this feature, set envrionment
SKIP_FILESYNC
totrue
File patterns to ignore when uploading files and folders from the host to the target paths, using rsync's --exclude-from
option. Refer to the rsync documentation for more information.
Ignored file patterns will not be uploaded from the host or overwritten in the remote. This may be important for keeping files that are generated in the remote's project directories.
- This configuration file can be left blank or removed if it is not required for the project
This script is designed to be used to configure a blank Raspberry Pi set up with SSH access, and will perform remote changes on the target device using sudo permissions.
Notekeeping files will be stored on the remote device to track installed packages and the synchronized service name.
File synchronization may override modifications or any existing content in targeted files or folder paths.
This software is provided without warranty. Use at your own risk!