This repository has been archived on 2022-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
archive_hook.sh/bin/forgehook

15 lines
490 B
Plaintext
Raw Normal View History

2020-04-26 22:08:08 +00:00
#! /bin/bash
2020-04-27 15:23:42 +00:00
# Auto-detect owner of forgehook-backend on current system
# stat has different syntax on various system so we use find
2020-04-27 15:23:42 +00:00
owner=$(find /usr/local/bin/forgehook-backend -maxdepth 0 -printf '%u')
2020-04-27 14:54:55 +00:00
if [[ $? != 0 ]]; then
2020-04-27 15:23:42 +00:00
echo "FATAL ERROR: forgehook-backend not found in /usr/local/bin"
2020-04-27 14:54:55 +00:00
exit 1
fi
# Start the backend escalating privileges to its owner
# TODO: introduce timeout on a dummy sudo to check sudo rules
# are setup properly
2020-04-27 15:23:42 +00:00
sudo -u "$owner" forgehook-backend $@