-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfll
executable file
·46 lines (39 loc) · 1.1 KB
/
fll
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
#!/bin/sh -e
# Copyright: (C) 2008-2024 Kel Modderman <kelvmod@gmail.com>
# License: GPLv2 or any later version
# By default we execute this as root user
ROOTEXEC=yes
# Locate directory we are called from
THIS_DIR=$(dirname $(readlink -f ${0}))
DEFAULTD="/usr/share/fll"
# Locate the real program
if [ -f ${THIS_DIR}/pyfll ]; then
FLL="${THIS_DIR}/pyfll --share ${THIS_DIR}"
elif [ -f /usr/share/fll/pyfll ]; then
FLL="${DEFAULTD}/pyfll --share ${DEFAULTD}"
else
echo "Error locating pyfll.py, aborting." >&2
exit 1
fi
# Get callers uid and gid for permission adjustment
USER_UID=$(getent passwd ${USER} | cut -d\: -f3)
USER_GID=$(getent passwd ${USER} | cut -d\: -f4)
for arg in "${@}"; do
case "${arg}" in
-h*|--help|-n*|--non-root)
ROOTEXEC=no
break
;;
esac
done
if [ "${ROOTEXEC}" = yes ]; then
echo "Requires root!"
if groups | grep -wq sudo; then
exec sudo /usr/bin/python3 ${FLL} --uid ${USER_UID} --gid ${USER_GID} ${@}
else
ROOT_CMD="/usr/bin/python3 ${FLL} --uid ${USER_UID} --gid ${USER_GID} ${@}"
exec su root --command "${ROOT_CMD}"
fi
else
exec /usr/bin/python3 ${FLL} ${@}
fi