Last active
July 21, 2019 18:22
-
-
Save bbayles/7cb42edad8898c6167fe44e2b0a6ed6c to your computer and use it in GitHub Desktop.
Rename SWC Sensor on first boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create the two files (sudo nano <filename>): | |
* /opt/obsrvbl-ona/set_ona_name.sh | |
* /etc/systemd/system/set_ona_name.service | |
Make the first script executable: | |
sudo chmod +x /opt/obsrvbl-ona/set_ona_name.sh | |
Enable the service: | |
sudo systemctl enable set_ona_name.service | |
Turn off the machine and clone it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Rename SWC Sensor | |
[Service] | |
Type=oneshot | |
ExecStart=/opt/obsrvbl-ona/set_ona_name.sh | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -f "/opt/obsrvbl-ona/ona_name_set" ]; then | |
sed -i '/OBSRVBL_ONA_NAME/d' "/opt/obsrvbl-ona/config.local" | |
echo "OBSRVBL_ONA_NAME=\"ona-$(date '+%Y-%m-%d %H:%M:%S.%N' | sha256sum | base64 | head -c 6)\"" >> "/opt/obsrvbl-ona/config.local" | |
touch "/opt/obsrvbl-ona/ona_name_set" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment