#!/bin/bash

# Initialize the CADDY_URL to a default
caddy="$(snapctl get caddy)"
if [ -z "$caddy" ]; then
  snapctl set caddy=disable
fi

# Initialize the PORT to a default
port="$(snapctl get port)"
if [ -z "$port" ]; then
  snapctl set port=3000
fi

# Initialize the MONGO_URL to a default
mongourl="$(snapctl get mongo-url)"
if [ -z "$mongourl" ]; then
  snapctl set mongo-url=mongodb://localhost:27017/parties
fi

# Initialize the MONGO_OPLOG_URL to a default
mongooplogurl="$(snapctl get mongo-oplog-url)"
if [ -z "$mongooplogurl" ]; then
  snapctl set mongo-oplog-url=mongodb://localhost:27017/local
fi

# Initialize the protocol to a default
https="$(snapctl get https)"
if [ -z "$https" ]; then
  snapctl set https=disable
fi

# Initialize backup to a default
backup="$(snapctl get backup-on-refresh)"
if [ -z "$backup" ]; then
  snapctl set backup-on-refresh=disable
fi

# Set back snap-refreshing to false
snapctl set snap-refreshing=false

# Initialize db-feature-compatibility-version to a default
db_featureCompatibilityVersion="$(snapctl get db-feature-compatibility-version)"
if [ -z "$db_featureCompatibilityVersion" ]; then
  snapctl set db-feature-compatibility-version=3.6
fi

