#!/bin/bash

ME=${0##*/}
TOP=/media

main() {
    local top=$TOP
    test -d $top || fatal "$top is not a directory"

    local d full not_done top=${1%/}
    for d in $(ls $top/); do
        full=$top/$d
        test -d $full       || continue
        mountpoint -q $full && continue
        mount $full
    done
}

fatal() {
    echo "$ME fatal error: $*" >&2
    exit 3
}

main

