Supported for --config when scripts are in PATH
[ccoop.git] / ccoop-update
index 66ed5973f4a94533f3a029c252a12d0e455a8a60..20dba1a56da9d22009cc58946ace9b5f245d7142 100755 (executable)
@@ -99,7 +99,13 @@ function doconfig() {
     echo "COOPPASSWORD=$COOPPASSWORD">>$CCPATH/config
     echo >&2
     echo "config writen to $CCPATH/config" >&2
     echo "COOPPASSWORD=$COOPPASSWORD">>$CCPATH/config
     echo >&2
     echo "config writen to $CCPATH/config" >&2
-    crontab -l | grep -v ccoop-update || echo "$(($RANDOM%60)) 6     * * *   $PWD/`dirname $0`/ccoop-update -q" | crontab -
+    if [[ "${0:0:1}"=="/" ]]; then
+        # absolute path
+        command="$0"
+    else
+        command="$PWD/$0"
+    fi
+    crontab -l | grep -v ccoop-update || echo "$(($RANDOM%60)) 6     * * *   $command -q" | crontab -
     echo "crontab installed" >&2
 }
 
     echo "crontab installed" >&2
 }
 
@@ -202,12 +208,18 @@ function updatehistory() {
 
 function atomize() {
     inform "Updating feeds"
 
 function atomize() {
     inform "Updating feeds"
+    if [[ "${0:0:1}"=="/" ]]; then
+        # absolute path
+        path="`dirname $0`"
+    else
+        path="$PWD/`dirname $0`"
+    fi
     for idx in ${!accountsId[@]}; do
         account=${accountsId[$idx]}
         name=${accountsNames[$idx]}
         balance=${accountsBalances[$idx]}
 
     for idx in ${!accountsId[@]}; do
         account=${accountsId[$idx]}
         name=${accountsNames[$idx]}
         balance=${accountsBalances[$idx]}
 
-        "`dirname $0`/ccoop-atomize" "$account" "$name" "$balance" > $CCPATH/$account.atom
+        "$path/ccoop-atomize" "$account" "$name" "$balance" > $CCPATH/$account.atom
     done
 }
 
     done
 }