2023-12-22 18:27:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
readonly default_php="/usr/bin/php"
|
|
|
|
php=""
|
|
|
|
|
|
|
|
check_sudo() {
|
|
|
|
if ! command -v sudo > /dev/null; then
|
|
|
|
printf "The sudo command is not available.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# allow overriding the php executable
|
2024-01-10 16:00:08 +00:00
|
|
|
if [ -n "${ARSSE_PHP}" ] && command -v "${ARSSE_PHP}" > /dev/null; then
|
2023-12-22 18:27:02 +00:00
|
|
|
php="${ARSSE_PHP}"
|
|
|
|
else
|
|
|
|
php="${default_php}"
|
|
|
|
fi
|
|
|
|
|
2024-01-10 16:00:08 +00:00
|
|
|
if [ "$(whoami)" = "arsse" ]; then
|
|
|
|
"$php" /usr/share/webapps/arsse/arsse "$@"
|
|
|
|
elif [ "${UID}" -eq 0 ]; then
|
2024-01-05 14:16:57 +00:00
|
|
|
runuser -u "arsse" -- "$php" /usr/share/webapps/arsse/arsse "$@"
|
2023-12-22 18:27:02 +00:00
|
|
|
else
|
|
|
|
check_sudo
|
2024-01-05 14:16:57 +00:00
|
|
|
sudo -u "arsse" "$php" /usr/share/webapps/arsse/arsse "$@"
|
2023-12-22 18:27:02 +00:00
|
|
|
fi
|
|
|
|
|