1 2 3 4 5 6
#!/bin/bash _sudo='' [[ -z "$1" ]] && { echo "Usage: $(basename "$0") <device>"; exit 1; } [[ ${UID} -ne 0 ]] && _sudo='sudo' exec ${_sudo} udisksctl power-off -b "$1"