From 762f48102f0c75141f4fa538b377b89565ddd5d4 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 2 Jul 2013 10:40:36 +0200 Subject: [PATCH] better method of running without root privileges --- sshbackup | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sshbackup b/sshbackup index 80924c0..66f4d8e 100755 --- a/sshbackup +++ b/sshbackup @@ -23,6 +23,7 @@ sshkey=0 bandwidth=0 limit=0 list=0 +noroot=0 options=$* @@ -50,6 +51,8 @@ usage() echo " -s, --sshkey alternate sshkey [~/.ssh/id_rsa]" echo " -b, --bandwidth bandwidth limit in kbit/s" echo + echo " -n, --no-root run without root privileges" + echo } version() @@ -78,10 +81,9 @@ amiroot() preflight() { #amiroot? - if ( ! amiroot ); then - echo "warning: in order to conserve owner and group attributes" - echo "warning: you need to run sshbackup as root." - return 0 + if ( ! amiroot ) && [ $noroot -eq 0 ]; then + echo "aborting mission. you need be root or use the --no-root option." + return 1 fi #source and destination path? @@ -218,6 +220,9 @@ for option in $options; do -b|--bandwidth) bandwidth=1 ;; + -n|--no-root) + noroot=1 + ;; *) if [ $config -eq 1 ]; then if [ -r "$option" ]; then