mount-stick-repo.sh 1.74 KB
Newer Older
1 2 3
#! /bin/bash
set -e

4 5 6
LIPSTICK_LABEL="LIPStick"
LIPSTICK_LABEL_ALT="$(echo -n "$LIPSTICK_LABEL" | tr "[a-z]" "[A-Z]")"

7
#find device
8
DEV="$(blkid -t "LABEL=$LIPSTICK_LABEL" -o device | head -n1 || echo '')"
Gustav Geier's avatar
Gustav Geier committed
9
if [ -z "$DEV" ]; then
10
  DEV="$(blkid -t "LABEL=$LIPSTICK_LABEL_ALT" -o device | head -n1 || echo '')"
Gustav Geier's avatar
Gustav Geier committed
11
fi
12 13 14 15 16 17 18 19 20 21

PS3="[1,2,3]<Enter>: "
while [ -z "$DEV" ];  do
  echo "Der LIP-Install-USB-Stick wurde nicht gefunden."
  echo "Jetzt einstecken oder ohne weitermachen"
  select i in "Stick ist jetzt gesteckt" \
"Ohne Stick weitermachen" \
"Installation abbrechen" ; do
    case $i in
     "Stick ist jetzt gesteckt")
22
       DEV="$(blkid -t "LABEL=$LIPSTICK_LABEL" -o device | head -n1 || echo '')"
Gustav Geier's avatar
Gustav Geier committed
23
       if [ -z "$DEV" ]; then
24
	 DEV="$(blkid -t "LABEL=$LIPSTICK_LABEL_ALT" -o device | head -n1 || echo '')"
Gustav Geier's avatar
Gustav Geier committed
25
       fi
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
       ;;
     "Ohne Stick weitermachen")
       DEV='-nomount-'
       ;;
     "Installation abbrechen")
       exit 2
       ;;
     *)
       echo "Das sollte nicht passieren. Helfer fragen."
       exit 99
       ;;
    esac
    break
  done
done

if [ "$DEV" = "-nomount-" ]; then
  echo "Mache ohne USB-Stick weiter."
  MPOINT=""
  #exit 0
else
  echo "Stick gefunden als $DEV"

  # ask udisks to mount it always.
50
  udisksctl mount --block-device "$DEV" || true
51 52 53

  # see where it is mounted
  DEVFILE=${DEV#/dev/}
54 55
#  MPOINT="$(dbus-send --print-reply=literal --system --dest=org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/${DEVFILE} org.freedesktop.DBus.Properties.Get string:'org.freedesktop.UDisks2.Filesystem' string:'MountPoints' | tail -n +3 | tr -d "\ \]\[" | head -n 1 | xxd -r -p)"
MPOINT="$(udisksctl info --block-device "$DEV" | grep "MountPoints:" | tr -d ' ' | cut -d ':' -f2)"
56 57 58 59

  echo "Der Stick it als '$MPOINT' gemountet"
fi
#end;