# shellcheck shell=bash DESCRIPTION="Network storage's launchd job: mounts on login and network changes, skips servers it can't reach" TIER=quick source "$CONNECTOR/configure.d/60-storage.sh" UNREACHABLE="smb://smoke@nas.smoke.invalid/files" job_loaded() { launchctl print "gui/$(id -u)/$LABEL" > /dev/null 2>&1 } skips_quickly() { local start=$SECONDS bash "$STORAGE_MOUNT" || return 1 [ $((SECONDS - start)) -le 10 ] } lists_unmounted() { [ "$(bash "$STORAGE_MOUNT" --list)" = "$UNREACHABLE|" ] } scenario() { mkdir -p "$CONF_DIR" : > "$STORAGE_CONF" check "record adds a share and the job" record "$UNREACHABLE" "/Volumes/files" check "launchd has the job" job_loaded check "the plist names the script" plutil -lint "$PLIST" check "a server it can't reach is skipped, quickly and without asking" skips_quickly check "--list shows it as not mounted" lists_unmounted check_not "mounted_at doesn't find it" mounted_at "$UNREACHABLE" check "remove_share" remove_share "$UNREACHABLE" check_not "the job is gone with the last share" job_loaded skip "Mounting a real share needs another machine and the sign-in window: check by hand" }