Skip to content

Instantly share code, notes, and snippets.

@rsvp
Created September 22, 2012 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsvp/3766881 to your computer and use it in GitHub Desktop.
Save rsvp/3766881 to your computer and use it in GitHub Desktop.
jpilotsudo.sh : help sync Palm device with jpilot. \ Linux bash script.
#!/usr/bin/env bash
# bash 4.2.24(1) Linux Ubuntu 12.04 Date : 2012-09-21
#
# _______________| jpilotsudo : help sync Palm device with jpilot.
#
# Usage: jpilotsudo # requires sudo access.
#
# Dependencies: jpilot
#
# Error Message to be resolved:
# "HotSync Problem: The connection between your handheld computer
# and the desktop could not be established."
# CHANGE LOG
# 2012-09-21 Discovered that jpilot needs root permission to access "usb:"
# in order to sync with my Visor.
#
# This was not necessary before Ubuntu 12.04 Precise;
# speculate that USB for the device now requires root level access.
# _____ PREAMBLE_v2: settings, variables, and error handling.
#
LC_ALL=POSIX
# locale means "ASCII, US English, no special rules,
# output per ISO and RFC standards."
# Esp. use ASCII encoding for glob and sorting characters.
shopt -s extglob
# ^set extended glob for pattern matching.
shopt -s failglob
# ^failed pattern matching signals error.
set -e
# ^errors checked: immediate exit if a command has non-zero status.
set -u
# ^unassigned variables shall be errors.
# Example of default VARIABLE ASSIGNMENT: arg1=${1:-'foo'}
program=${0##*/} # similar to using basename
# memf=$( mktemp /dev/shm/88_${program}_tmp.XXXXXXXXXX )
cleanup () {
# Delete temporary files, then optionally exit given status.
local status=${1:-'0'}
# rm -f $memf
[ $status = '-1' ] || exit $status # thus -1 prevents exit.
} #--------------------------------------------------------------------
warn () {
# Message with basename to stderr. Usage: warn "message"
echo -e "\n !! ${program}: $1 " >&2
} #--------------------------------------------------------------------
die () {
# Exit with status of most recent command or custom status, after
# cleanup and warn. Usage: command || die "message" [status]
local status=${2:-"$?"}
cleanup -1 && warn "$1" && exit $status
} #--------------------------------------------------------------------
trap "die 'SIG disruption, but cleanup finished.' 114" 1 2 3 15
# Cleanup after INTERRUPT: 1=SIGHUP, 2=SIGINT, 3=SIGQUIT, 15=SIGTERM
#
# _______________ :: BEGIN Script ::::::::::::::::::::::::::::::::::::::::
group=''
# ^Optionally specify your favorite registered group. <=!
if [ "$group" = '' ] ; then
group=$USER
fi
echo " :: $program: To be SOLELY used for SYNC operation. "
echo " :: - After sudo access is given, sync at GUI as usual."
echo " :: - Exit jpilot immediately after sync is finished. "
echo
# _____ MAIN LINE OF THIS ENTIRE SCRIPT
sudo jpilot && sudo chown -hR $USER:$group $HOME/.jpilot
# ^files and symlinks need to be changed from root:root.
echo
echo " :: $program: files and symlinks in .jpilot now owned by $USER:$group"
echo " :: - For non-sync operations, use jpilot as usual."
cleanup
# _______________ EOS :: END of Script ::::::::::::::::::::::::::::::::::::::::
# # Sample messages from jpilot upon sync...
# #
# ****************************************
# Syncing on device usb:
# Press the HotSync button now
# ****************************************
# Doing a fast sync.
# Syncing DatebookDB
# Syncing AddressDB
# Syncing ToDoDB
# Syncing MemoDB
# Syncing ExpenseDB
# Backup: Aide Mobipocket_PAR.pdb is up to date, fetch skipped.
# Backup: CityTimeDB.pdb is up to date, fetch skipped.
# Backup: Datebk3HDB.pdb is up to date, fetch skipped.
# Backup: HSAdvCalcDB.pdb is up to date, fetch skipped.
# Backup: MobiSysLib.pdb is up to date, fetch skipped.
# Backup: AddressDB.pdb is up to date, fetch skipped.
# Backup: Fetching 'DatebookDB'... OK
# Backup: ExpenseDB.pdb is up to date, fetch skipped.
# Backup: LauncherDB.pdb is up to date, fetch skipped.
# Backup: MailDB.pdb is up to date, fetch skipped.
# Backup: MemoDB.pdb is up to date, fetch skipped.
# Backup: ConnectionDB.pdb is up to date, fetch skipped.
# Backup: NetworkDB.pdb is up to date, fetch skipped.
# Backup: ToDoDB.pdb is up to date, fetch skipped.
# Backup: MBP_global_configuration.pdb is up to date, fetch skipped.
# Backup: mobibook_log.pdb is up to date, fetch skipped.
# Backup: MobipocketCommonRez.pdb is up to date, fetch skipped.
# Backup: MobipocketCommonImages.pdb is up to date, fetch skipped.
# Backup: Keyboard Options.pdb is up to date, fetch skipped.
# Backup: HardBall.prc is up to date, fetch skipped.
# Backup: Keyboard.prc is up to date, fetch skipped.
# Backup: MobiBook.prc is up to date, fetch skipped.
# Backup: SubHunt.prc is up to date, fetch skipped.
# Backup: Graffiti.prc is up to date, fetch skipped.
# Backup: PocketChess.prc is up to date, fetch skipped.
# Backup: AddressCitiesDB.pdb is up to date, fetch skipped.
# Backup: CitiesDB.pdb is up to date, fetch skipped.
# Backup: AddressCompaniesDB.pdb is up to date, fetch skipped.
# Backup: AddressCountriesDB.pdb is up to date, fetch skipped.
# Backup: psysLaunchDB.pdb is up to date, fetch skipped.
# Backup: Graffiti ShortCuts .prc is up to date, fetch skipped.
# Backup: Fetching 'Unsaved Preferences'... OK
# Backup: Net Prefs.prc is up to date, fetch skipped.
# Backup: System MIDI Sounds.pdb is up to date, fetch skipped.
# Backup: Fetching 'Saved Preferences'... OK
# Backup: AddressStatesDB.pdb is up to date, fetch skipped.
# Backup: AddressTitlesDB.pdb is up to date, fetch skipped.
# Backup: VendorsDB.pdb is up to date, fetch skipped.
# Expiring old archives...
# Expiring /home/yaya/.jpilot/Backup/Archive_2012-09-21@18:34:52
# Backup: backup complete
# Fetching 'Saved Preferences' (Creator ID 'psys')... OK
# Finished.
# 2012-09-21 Error message non-fatal:
# (jpilot:16270): Gtk-CRITICAL **: IA__gtk_text_buffer_insert: assertion `text != NULL' failed
# vim: set fileencoding=utf-8 ff=unix tw=78 ai syn=sh :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment