mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-18 04:32:23 -05:00
guh
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -14,6 +14,10 @@ if [[ ${ROVERD_MIGRATE:-} == 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
# Rename avoids overwriting an executable that the running service has mapped.
|
# Rename avoids overwriting an executable that the running service has mapped.
|
||||||
install -m 0755 "dist/roverd-linux-$arch" /usr/local/bin/roverd.new
|
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
|
mv -f /usr/local/bin/roverd.new /usr/local/bin/roverd
|
||||||
apt-get update
|
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
|
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=()
|
options=()
|
||||||
if [ "$inverted" = true ]; then options+=(--rotation 180); fi
|
if [ "$inverted" = true ]; then options+=(--rotation 180); fi
|
||||||
if [ -n "$sensor_mode" ]; then options+=(--mode "$sensor_mode"); 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[@]}" \
|
"$camera" --inline --timeout 0 "${options[@]}" \
|
||||||
--width "$width" --height "$height" \
|
--width "$width" --height "$height" \
|
||||||
--framerate "$fps" --bitrate "$bitrate" \
|
--framerate "$fps" --bitrate "$bitrate" \
|
||||||
|
|||||||
+13
-4
@@ -303,18 +303,27 @@ func LoadConfig(path string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DecodeConfig(data []byte) (*Config, error) {
|
func DecodeConfig(data []byte) (*Config, error) {
|
||||||
if err := ValidateConfigurationSchema(data); err != nil {
|
if trimmed := bytes.TrimSpace(data); len(trimmed) == 0 || trimmed[0] != '{' {
|
||||||
return nil, err
|
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 := json.NewDecoder(bytes.NewReader(data))
|
||||||
decoder.DisallowUnknownFields()
|
|
||||||
if err := decoder.Decode(&cfg); err != nil {
|
if err := decoder.Decode(&cfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := decoder.Decode(new(any)); err != io.EOF {
|
if err := decoder.Decode(new(any)); err != io.EOF {
|
||||||
return nil, errors.New("expected one JSON object")
|
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 {
|
if err := validateConfig(&cfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user