diff --git a/dist/roverd-linux-amd64 b/dist/roverd-linux-amd64 index 90ac5c06..607b8027 100755 Binary files a/dist/roverd-linux-amd64 and b/dist/roverd-linux-amd64 differ diff --git a/dist/roverd-linux-arm64 b/dist/roverd-linux-arm64 index 8db97f2c..4d9e9d1a 100755 Binary files a/dist/roverd-linux-arm64 and b/dist/roverd-linux-arm64 differ diff --git a/dist/roverd-linux-armv6 b/dist/roverd-linux-armv6 index 1708c90f..fc907bdd 100755 Binary files a/dist/roverd-linux-armv6 and b/dist/roverd-linux-armv6 differ diff --git a/dist/roverd-linux-armv7 b/dist/roverd-linux-armv7 index 7b797089..9dad0c1f 100755 Binary files a/dist/roverd-linux-armv7 and b/dist/roverd-linux-armv7 differ diff --git a/rover/install_roverd.sh b/rover/install_roverd.sh index c2883d55..6e3f3731 100755 --- a/rover/install_roverd.sh +++ b/rover/install_roverd.sh @@ -14,6 +14,10 @@ if [[ ${ROVERD_MIGRATE:-} == 1 ]]; then fi # Rename avoids overwriting an executable that the running service has mapped. install -m 0755 "dist/roverd-linux-$arch" /usr/local/bin/roverd.new +if [[ -f /etc/roverd.json ]]; then + # A rejected config must leave the installed executable untouched. + /usr/local/bin/roverd.new -config /etc/roverd.json -check-config +fi mv -f /usr/local/bin/roverd.new /usr/local/bin/roverd apt-get update apt-get install -y git ca-certificates python3 util-linux flite espeak curl xz-utils unzip alsa-utils libc++1 libc++abi1 diff --git a/rover/profiles/video.yaml b/rover/profiles/video.yaml index a906dbda..6f3f8c15 100644 --- a/rover/profiles/video.yaml +++ b/rover/profiles/video.yaml @@ -42,7 +42,6 @@ options=() if [ "$inverted" = true ]; then options+=(--rotation 180); fi if [ -n "$sensor_mode" ]; then options+=(--mode "$sensor_mode"); fi - # Preserve the previous Pi publisher's camera tuning and packet timing. "$camera" --inline --timeout 0 "${options[@]}" \ --width "$width" --height "$height" \ --framerate "$fps" --bitrate "$bitrate" \ diff --git a/rover/roverd/config.go b/rover/roverd/config.go index 7c3d21b4..9eedb983 100644 --- a/rover/roverd/config.go +++ b/rover/roverd/config.go @@ -303,18 +303,27 @@ func LoadConfig(path string) (*Config, error) { } func DecodeConfig(data []byte) (*Config, error) { - if err := ValidateConfigurationSchema(data); err != nil { - return nil, err + if trimmed := bytes.TrimSpace(data); len(trimmed) == 0 || trimmed[0] != '{' { + return nil, errors.New("expected one JSON object") } - var cfg Config + // Defaults fill newly added settings; decoding into Config drops obsolete ones. + cfg := DefaultConfig() decoder := json.NewDecoder(bytes.NewReader(data)) - decoder.DisallowUnknownFields() if err := decoder.Decode(&cfg); err != nil { return nil, err } if err := decoder.Decode(new(any)); err != io.EOF { return nil, errors.New("expected one JSON object") } + // Validate the current shape after applying saved settings, so schema changes + // do not prevent an otherwise valid installed rover from starting. + current, err := json.Marshal(cfg) + if err != nil { + return nil, err + } + if err := ValidateConfigurationSchema(current); err != nil { + return nil, err + } if err := validateConfig(&cfg); err != nil { return nil, err }