naneos.uploader_settings
Settings of the naneos-uploader service from a text file on the SD card.
A customer without SSH can still change the options of the service and add a WiFi network: the boot partition of a Raspberry Pi is FAT and opens on any PC. Two files live there:
naneos-uploader-change.txt: the customer writesOPTIONS=--interval 60(the same options as on the command line),WIFI_SSID=plusWIFI_PASSWORD=, and/orAUTO_UPDATE=on|off. The next boot applies the lines, then resets the file to its commented template, which also removes the password from the card.naneos-uploader-current.txt: written at every boot, shows the options the service runs with and the WiFi networks the Pi knows, plus an error if the last change was rejected. Never the password.
"Applied" means, for the options, written to an environment file that the
systemd unit reads (EnvironmentFile=) and expands in its ExecStart:
NANEOS_UPLOADER_OPTIONS=--interval 60
and for WiFi, a NetworkManager keyfile in /etc/NetworkManager/system-connections
(root only, mode 600) followed by nmcli connection reload. The new network is
added with a higher autoconnect priority; the known ones are kept.
AUTO_UPDATE enables or disables the naneos_uploader_update.timer (see
uploader_update.py) with systemctl.
The installer writes the naneos_uploader_settings.service unit that runs
naneos-uploader-settings as root before the uploader starts. All lines are
validated before anything is applied: a rejected file keeps the previous
settings, so the service always comes up.
SettingsError
Bases: ValueError
The change file holds something that cannot be applied.
Source code in src/naneos/uploader_settings.py
73 74 | |
apply(boot_dir, env_file, override_dir=DEFAULT_OVERRIDE_DIR, nm_dir=DEFAULT_NM_DIR, nm_reload=nmcli_reload, set_auto_update=systemctl_auto_update, auto_update_state=systemctl_auto_update_state, now=None)
One boot: consume the change file, apply what it holds, write the current file.
Source code in src/naneos/uploader_settings.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
known_wifi(nm_dir)
The ids of the WiFi profiles NetworkManager has (needs root to read).
Source code in src/naneos/uploader_settings.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
nmcli_reload()
Tell a running NetworkManager about the new profile; a warning if that was not possible.
Source code in src/naneos/uploader_settings.py
304 305 306 307 308 309 310 311 312 313 314 315 316 | |
override_warning(override_dir)
A note if a systemctl edit drop-in replaces ExecStart, since that wins over the file.
Source code in src/naneos/uploader_settings.py
336 337 338 339 340 341 342 343 344 345 | |
read_settings(text)
The settings lines as {KEY: value}; comments and blank lines are skipped.
Raises SettingsError for an unknown key, a repeated key or any other content. Error messages never echo a value, since they end up in a world-readable file.
Source code in src/naneos/uploader_settings.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
systemctl_auto_update(enabled)
Switch the update timer; a warning if systemctl could not do it.
Source code in src/naneos/uploader_settings.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
systemctl_auto_update_state()
Whether the update timer is enabled, None if it is not installed.
Source code in src/naneos/uploader_settings.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
validate_auto_update(settings)
True/False for AUTO_UPDATE=on/off, None if the line is absent.
Source code in src/naneos/uploader_settings.py
186 187 188 189 190 191 192 193 194 195 | |
validate_options(options)
The options normalized to single spaces, after the uploader's parser accepted them.
Source code in src/naneos/uploader_settings.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
validate_wifi(settings)
(ssid, password) if the file adds a network, None if both lines are absent.
Source code in src/naneos/uploader_settings.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
write_wifi_profile(nm_dir, ssid, password)
Write the keyfile root-only (NetworkManager ignores it otherwise).
Source code in src/naneos/uploader_settings.py
293 294 295 296 297 298 299 300 301 | |