mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-18 04:32:23 -05:00
guh
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user