This commit is contained in:
legop3
2026-11-17 21:02:13 -05:00
parent 0ea99d0158
commit dcc14388a6
7 changed files with 17 additions and 5 deletions
+4
View File
@@ -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
-1
View File
@@ -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" \
+13 -4
View File
@@ -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
}