#!/bin/sh set -x setvar MOUNTPOINT = "$1" test -z $MOUNTPOINT && echo "No mountpoint specified" && exit 1 mkdir -p $MOUNTPOINT proc mount_drive { # TODO fix for multiple disks, cdroms etc setvar DEVS = "$(find /dev -maxdepth 1 -type b ! -name 'loop*' ! -name 'nbd*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | sort)" for DEV in [$DEVS] { setvar DRIVE = ""/dev/${DEV}"" # see if it has a partition table if sfdisk -d ${DRIVE} >/dev/null 2>/dev/null { # 83 is Linux partition identifier setvar DATA = $(sfdisk -J "$DRIVE" | jq -e -r '.partitiontable.partitions | map(select(.type=="83")) | .[0].node') if test $Status -eq 0 { mount $DATA $MOUNTPOINT && return } } } echo "WARNING: Failed to mount a persistent volume (is there one?)" } mount_drive