/usr/share/doc/obexpushd/examples/file_storage.sh is in obexpushd 0.11.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #!/bin/bash
set -e
#DIALOG=Xdialog --default-no
DIALOG=kdialog
ROOT_PATH=""
#
# compatible with obexpushd >= 0.6
#
MODE="$1"
FROM=""
NAME=""
SUB_PATH="${ROOT_PATH}./"
LENGTH="0"
MIMETYPE=""
while read LINE; do
echo "${LINE}" 1>&2
if ( test -z "${LINE}" ); then
break
fi
TAG=$(echo "${LINE}" | cut -f 1 -d ":")
VALUE=$(echo "${LINE}" | cut -f 2- -d " ")
case $TAG in
From) FROM="${VALUE}";;
Name) NAME="${VALUE}";;
Path) SUB_PATH="${ROOT_PATH}${VALUE}/";;
Length) LENGTH="${VALUE}";;
Type) MIMETYPE="${VALUE}";;
esac
done
case "${MODE}" in
put)
FILE="${SUB_PATH}${NAME}"
echo "script: testing ${FILE}..." 1>&2
test -z "${FILE}" && exit 1
echo "script: testing for existence of ${FILE}..." 1>&2
test -e "${FILE}" && exit 1
#tell obexpushd to go on
echo "script: asking user for permission..." 1>&2
${DIALOG} --title "Obex-Push" \
--yesno \
"Allow receiving the file\n\"${FILE}\"\n(${LENGTH} bytes) from\n${FROM}" \
10 40
if ( test "$?" -eq "0" ); then
echo "OK"
else
echo "ABORT"
exit 1
fi
echo "script: storing file on disk..." 1>&2
cat > "${FILE}"
echo "script: file saved to disk." 1>&2
setfattr -n "user.mime_type" -v "${MIMETYPE}" "${FILE}"
sleep 1
echo "script: done" 1>&2
;;
get)
FILE=${SUB_PATH}${NAME}
test -z "${FILE}" && exit 1
test -f "${FILE}" || exit 1
stat --printf="Length: %s\n" ${FILE}
stat --format="%y" "${FILE}" | date -u +"Time: %Y%m%dT%H%M%SZ"
MIMETYPE=$(getfattr -n "user.mime_type" "${FILE}")
if [ "${MIMETYPE}" ]; then
echo "Type: ${MIMETYPE}"
fi
echo ""
cat "${FILE}"
;;
delete)
FILE=${SUB_PATH}${NAME}
exec rm -rf "${FILE}"
;;
listdir)
FILE=$(mktemp)
obex-folder-listing ${SUB_PATH} >${FILE} 2>/dev/null
stat --printf="Length: %s\n" ${FILE}
echo ""
cat ${FILE}
rm -f ${FILE}
;;
createdir)
exec mkdir -p ${SUB_PATH}
;;
capability)
;;
esac
exit 0
|