-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkindlebag.sh
executable file
·35 lines (30 loc) · 1.03 KB
/
kindlebag.sh
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
# Get hackname from the script's path (NOTE: Will only work for scripts called from /mnt/us/extensions/${KH_HACKNAME})
KH_HACKNAME="${PWD##/mnt/us/extensions/}"
# Try to pull our custom helper lib
libkh_fail="false"
# Handle both the K5 & legacy helper, so I don't have to maintain the exact same thing in two different places :P
for my_libkh in libkh5 libkh ; do
_KH_FUNCS="/mnt/us/${KH_HACKNAME}/bin/${my_libkh}"
if [ -f ${_KH_FUNCS} ] ; then
. ${_KH_FUNCS}
# Got it, go away!
libkh_fail="false"
break
else
libkh_fail="true"
fi
done
if [ "${libkh_fail}" == "true" ] ; then
# Pull default helper functions for logging
_FUNCTIONS=/etc/rc.d/functions
[ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}
# We couldn't get our custom lib, abort
msg "couldn't source libkh5 nor libkh from '${KH_HACKNAME}'" W
exit 0
fi
# We need the proper privileges...
if [ "$(id -u)" -ne 0 ] ; then
kh_msg "unprivileged user, aborting" E v
exit 1
fi
kh_msg "$(/mnt/us/kindlebag/kindlebag -config /mnt/us/kindlebag/config.json -outfolder /mnt/us/documents/)"