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
471 B
Bash
Executable File

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