trashman install <package>
-Instead of being just a shorthand, `trashman` packages try as best as possible
+Instead of being just a shorthand, `trashman` packages can try as best as possible
not to fetch keys and scripts from remote locations without some basic checks. So if
you have to add files into `/etc/apt/trusted.gpg.d`, `trashman` will provide those
keys or fingerprints instead of donwloading it from somewhere, in which case it could
# Check for superuser privileges
trashman_check_root() {
local action="$1"
+ local package="$2"
if [ -z "$action" ]; then
return
fi
if [ "`whoami`" != "root" ]; then
- trashman_echo "Action $action requires root privileges"
- exit 1
+ if which sudo &> /dev/null; then
+ # Try to invoke it with sudo
+ trashman_echo "You're running as a regular user, trying to re-invoke the command using sudo..."
+ sudo $PROGRAM $action $package
+ exit $?
+ else
+ trashman_echo "Action $action requires root privileges"
+ exit 1
+ fi
fi
}
# Checking for privileges
if [ "$BASENAME" = "trashman" ]; then
- trashman_check_root $ACTION
+ trashman_check_root $ACTION $package
else
trashman_check_sudo
fi