Supported for --config when scripts are in PATH
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Fri, 14 Mar 2008 23:59:11 +0000 (23:59 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Fri, 14 Mar 2008 23:59:11 +0000 (23:59 +0000)
README
ccoop-atomize
ccoop-update

diff --git a/README b/README
index a3ea2ca274bc0b4047b39d24a3331fb3c19ce757..5a6f0b16a4f5421dc573ffa797db3c7d524ef759 100644 (file)
--- a/README
+++ b/README
@@ -16,7 +16,7 @@ Configuration
 
 Lors de la première utilisation, lancez 
 
-./ccoop-update.sh --config
+ccoop-update.sh --config
 
 Cela crééra le fichier ~/ccoop/config et installera un entrée cron
 
index d39b3bb2cf664ec29bf15a9090a9d3d21a92bb26..e095523c92e9a8657b3b4fb9052a9d89aeb19663 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import sys, os,datetime
+import sys,os,datetime
 
 account=sys.argv[1]
 name=sys.argv[2]
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
-    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
 }
 
@@ -202,12 +208,18 @@ function updatehistory() {
 
 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]}
 
-        "`dirname $0`/ccoop-atomize" "$account" "$name" "$balance" > $CCPATH/$account.atom
+        "$path/ccoop-atomize" "$account" "$name" "$balance" > $CCPATH/$account.atom
     done
 }