]> arthur.barton.de Git - iPhone2Mac.git/commitdiff
Initial import into GIT of iPhone2Mac as of 2009-07-25
authorAlexander Barton <alex@barton.de>
Tue, 29 Sep 2009 08:57:53 +0000 (10:57 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 29 Sep 2009 08:57:53 +0000 (10:57 +0200)
de.barton.iPhone2Mac.plist [new file with mode: 0644]
iPhone2Mac.sh [new file with mode: 0755]

diff --git a/de.barton.iPhone2Mac.plist b/de.barton.iPhone2Mac.plist
new file mode 100644 (file)
index 0000000..52e733b
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>Label</key>
+       <string>de.barton.iPhone2Mac</string>
+       <key>ProgramArguments</key>
+       <array>
+               <string>/usr/local/bin/iPhone2Mac.sh</string>
+       </array>
+       <key>RunAtLoad</key>
+       <true/>
+       <key>StartInterval</key>
+       <integer>600</integer>
+       <key>Nice</key>
+       <integer>5</integer>
+       <key>LowPriorityIO</key>
+       <true/>
+       <key>LimitLoadToSessionType</key>
+       <string>Aqua</string>
+</dict>
+</plist>
diff --git a/iPhone2Mac.sh b/iPhone2Mac.sh
new file mode 100755 (executable)
index 0000000..f639cac
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+# 2009-07-25, alex@barton.de
+
+DEBUG=
+VERBOSE=1
+
+backup_d=""
+call_db=""
+
+[ -n "$DEBUG" ] && VERBOSE=1
+
+abort() {
+       echo "$*"
+       exit 1
+}
+
+message() {
+       echo "$*"
+}
+verbose() {
+       [ -n "$VERBOSE" ] && message "$*"
+}
+debug() {
+       [ -n "$DEBUG" ] && verbose "$*"
+}
+
+umask 0077
+
+NAME=`basename "$0" | cut -d'.' -f1`
+DATA_DIR=~/Library/Application\ Support/$NAME
+CALL_LOG="${DATA_DIR}/call.log"
+CALL_TMP="/tmp/$NAME.$$.call.log.tmp"
+debug "DATA_DIR=$DATA_DIR"
+
+mkdir -p "$DATA_DIR" || abort "Can't create \"$DATA_DIR\"!"
+
+if [ -z "$backup_d" ]; then
+       verbose "Locating backup directory ..."
+       cd ~/Library/Application\ Support/MobileSync/Backup/ \
+               || abort "No backup data stores found!?"
+       cd * \
+               || abort "Can't access backup directory!?"
+else
+       cd "$backup_d" || abort "Can't access backup directory!?"
+fi
+verbose "iPhone Backup directory is \"$PWD\"."
+
+if [ -z "$call_db" ]; then
+       verbose "Locating SQLite call database ..."
+       call_db=$(for f in `file * | fgrep SQLite | cut -d':' -f1`; do
+               sqlite3 "$f" ".schema" | fgrep "CREATE TABLE call (" >/dev/null;
+               [ $? -eq 0 ] && echo "$f"; done
+       )
+fi
+verbose "Call database is \"$call_db\"."
+
+if [ -e "$CALL_LOG" ]; then
+       debug "Copying existing ASCII call log ..."
+       cp "$CALL_LOG" "$CALL_TMP" || abort "Can't copy old log file!"
+fi
+verbose "Dumping SQLite call databse ..."
+sqlite3 "$call_db" "select * from call;" >>"$CALL_TMP"
+verbose "Sorting plain ASCII call log ..."
+sort -u "$CALL_TMP" >"$CALL_LOG"
+rm -f "$CALL_TMP"
+first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+message `wc -l "$CALL_LOG" | awk '{print \$1}'`" unique entries logged, from $first_d to $last_d."