Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A shell script to auto-update Chimera Web Browsers
Chimera's Navigator is having nightly builds released lately, so I wrote a shell script to grab it, mount the image, backup the old navigator.app, copy the new one over, and rename the disk image file to the current date.

Read the rest of the article for the script...

The script should run fine without any modifications on any OS X 10.1.4 install. Commented lines are how I have it set up on my system. Change the cd line near the beginning to change where the script saves stuff.

#! /bin/sh

/bin/echo "Beginning Chimera Nightly Download: `date`"
/bin/echo "Changing to download folder"
cd $HOME
#cd $HOME/Downloads/Chimera
/bin/echo "pwd is: `pwd`"

/bin/echo "Downloading Chimera: `date`"

/usr/bin/curl -O ftp://ftp.mozilla.org/pub/chimera/nightly/latest-trunk/Chimera.dmg.gz
#/usr/local/bin/wget -c ftp://ftp.mozilla.org/pub/chimera/nightly/latest-trunk/Chimera.dmg.gz

if [ -f Chimera.dmg.gz ];then

/usr/bin/gunzip Chimera.dmg.gz

# /bin/echo "Converting Chimera DMG: `date`"
# /usr/bin/hdiutil convert -format UDZO -o temp.dmg Chimera.dmg
# /bin/rm Chimera.dmg
# /bin/mv temp.dmg Chimera.dmg

/bin/echo "Mounting Chimera DMG: `date`"
thedisk=`/usr/bin/hdid Chimera.dmg | /usr/bin/awk '{print $1}' | /usr/bin/head -n1`

/bin/echo "Testing to see if Chimera is running."
/bin/ps -xa | /usr/bin/grep Navigator | /usr/bin/grep -v grep > /dev/null

if [ $? -eq 0 ]
then
/bin/echo "Getting Chimera PID"
killme=`/bin/ps -xa | /usr/bin/grep Navigator | /usr/bin/grep -v grep | /usr/bin/cut -c1-5`
/bin/echo "Killing Chimera"
/bin/kill $killme
else
/bin/echo "Chimera not running"
fi

/bin/echo "Backing up old Chimera"
/usr/bin/tar -czf /Applications/NavOld.tar.gz /Applications/Navigator.app

/bin/echo "Removing old Chimera"
/bin/rm -rf /Applications/Navigator.app

/bin/echo "Copying Chimera Application: `date`"
# /usr/local/sbin/CpMac -r "/Volumes/Chimera/Navigator.app" "/Applications/"
/usr/bin/ditto "/Volumes/Chimera/Navigator.app" "/Applications/"

/bin/echo "Ejecting Chimera DMG: `date`"
/usr/bin/hdiutil eject $thedisk

/bin/echo "Renaming Chimera DMG"

if [ -f "Chimera.dmg" ]; then
thedate=`/bin/date +%D | /usr/bin/tr "/" "-"`
/bin/mv -f "Chimera.dmg" "Chimera.$thedate.dmg"
/bin/echo "Renamed to Chimera.$thedate.dmg"
fi

/bin/echo "End Chimera download: `date`"

fi
[Editor's note: I tested this and it works perfectly. The only caveat is to also change the path where the script looks for "Navigator" if you don't have it installed at the top level of the default Applications folder.]
    •    
  • Currently 1.60 / 5
  You rated: 4 / 5 (5 votes cast)
 
[6,421 views]  

A shell script to auto-update Chimera | 10 comments | Create New Account
Click here to return to the 'A shell script to auto-update Chimera' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
no luck
Authored by: loren_ryter on Jun 03, '02 10:11:15AM

i'm no shell script expert by i couldn't get this to work properly....

i wanted the download directory to be "/Volumes/Scratch/Downloads/Chimera/" and I wanted the target directory to be "/Applications (OS X)/Internet/Browsers/"... I tried to change the relevant strings. I put quotes around all the path strings (replaced "/Applications/" with my target path string.)

but what I got was:

1. chimera .dmg downloaded to ~ directory

2. a "Contents" folder in the target directory with no application but all the resources.

I put quotes around all the path strings (replaced "/Applications/" with my target path string.)

Maybe someone can re-rewite this with a variable target path? and explain why the download would wind up in my home directory rather than the specified download directory?

thanks



[ Reply to This | # ]
no luck
Authored by: dim ben on Jun 03, '02 12:02:44PM

in the line that copys the new Chimera to your application folder, just add "Navigator.app" to the path of your application directory, and it will work, no matter what folder you want your app to be copied to.

Use
/usr/bin/ditto "/Volumes/Chimera/Navigator.app" "/your/path/Navigator.app"

instead of
/usr/bin/ditto "/Volumes/Chimera/Navigator.app" "/Applications/"



[ Reply to This | # ]
no luck
Authored by: loren_ryter on Jun 03, '02 10:30:17PM

ok got it finally that worked. thanks.



[ Reply to This | # ]
diito?
Authored by: shreddiez on Jun 03, '02 11:45:19AM

Personally the "ditto" command did not copy the navigator app accross, rather its Contents folder. You can instead use this command....

/Developer/Tools/CpMac -r "/Volumes/Chimera/Navigator.app" "/Applications/"

Assuming you have devtools installed.



[ Reply to This | # ]
I goofed
Authored by: THEM on Jun 03, '02 04:11:04PM

I goofed in the ditto line, remove the Navigator.app so you have
/usr/bin/ditto "/Volumes/Chimera/" "/Applications/"

That will copy it properly. I dislike ditto.



[ Reply to This | # ]
I goofed
Authored by: loren_ryter on Jun 03, '02 10:24:07PM

hmm... now everything worked except Navigator is not copied over to the target directory.

When I tried manually using the same commands on the command line, i get permission errors.... and i take it "cpmac" is a command you can install with fink? i have fink, but "fink install CpMac" finds nothing.

[12-228-142-249:~] lryter% ditto "/volumes/chimera/" "/Applications (OS X)/Internet/browsers/"
./.Trashes/: Permission denied
[12-228-142-249:~] lryter% /usr/local/sbin/CpMac -r "/Volumes/Chimera/Navigator.app" "/Applications (OS X)/Internet/browsers/"
/usr/local/sbin/CpMac: Command not found.



[ Reply to This | # ]
ignore above
Authored by: loren_ryter on Jun 03, '02 10:34:10PM

sorry ... don't know how to delete postings here. but i got it working with the suggestion of someone in a reply to my original thread.

ditto had to include navigator.app, so you had to have

ditto "/volumes/chimera/navigator.app" "/targetvolume/targetdir/navigator.app"

rather than:

ditto "/volumes/chimera/" "targetvolume/targetdir/"



[ Reply to This | # ]
'cp -Rp' is enough - Chimera.app doesn't ship with resource forks
Authored by: mblakele on Oct 27, '02 03:07:26PM

Chimera doesn't ship with resource forks, so this is sufficient:

cp -Rp /Volumes/$FILENAME/${APPNAME}.app /Applications/

of course, there's no guarantee that Chimera won't add resource forks some day... You can check for resource forks with:

find /Applications/Navigator.app -print0 | perl -0ne 'chop; print "$_\n" if -s "$_/..namedfork/rsrc"'



[ Reply to This | # ]
Why doesn't curl work?
Authored by: ateles on Jun 05, '02 01:19:45PM

I ran this script and I couldn't get curl (or wget) to work. They returned (in curl's case):

curl: (5) Couldn't resolve proxy ''none''

so I replaced ftp by http in the curl line:

curl -O ftp://ftp.mozilla.org/pub/chimera/nightly/latest-trunk/Chimera.dmg.gz

by

curl -O http://ftp.mozilla.org/pub/chimera/nightly/latest-trunk/Chimera.dmg.gz

and that worked! Any idea why wouldn't work with ftp://....?

ateles



[ Reply to This | # ]
Script works great - Chimera does not!
Authored by: bluehz on Jun 07, '02 07:02:00PM

The script works great! Very Impressive!

Unfortunately I can not get Chimera to run in OS X 10.1.5....

Date/Time: 2002-06-07 19:00:02 -0400
OS Version: 10.1.5 (Build 5S60)
Host: xxxxxxxx

Command: Navigator
PID: 1508

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
#0 0x000189a8 in BookmarksService::AddObserver(void)
#1 0x00025394 in -[CHBookmarksToolbar initializeToolbar]
#2 0x00006520 in -[BrowserWindowController windowDidLoad]
#3 0x70da5198 in -[NSWindowController _windowDidLoad]
#4 0x70c82dc4 in -[NSWindowController window]
#5 0x70da5abc in -[NSWindowController showWindow:]
#6 0x00005448 in -[MainController openBrowserWindowWithURL:]
#7 0x000053c8 in -[MainController openBrowserWindowWithURLString:]
#8 0x000049dc in -[MainController newWindow:]
#9 0x00004770 in -[MainController awakeFromNib]
#10 0x708a0170 in -[NSSet makeObjectsPerformSelector:]
#11 0x70c17790 in -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]
#12 0x70c63830 in loadNib
#13 0x70c1f050 in +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:]
#14 0x70c69a98 in +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:]
#15 0x70c5e014 in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#16 0x70c91e74 in NSApplicationMain
#17 0x00002cbc in _start
#18 0x00002aec in start

Thread 1:
#0 0x700343e8 in semaphore_wait_trap
#1 0x700342c8 in pthread_join
#2 0x000e6214 in 0xe6214

Thread 2:
#0 0x7003f4c8 in semaphore_wait_signal_trap
#1 0x7003f2c8 in _pthread_cond_wait
#2 0x70250aa8 in TSWaitOnCondition
#3 0x702ae124 in MPRemoteCall
#4 0x000e629c in 0xe629c
#5 0x7002054c in _pthread_body
#6 0x90010008 in 0x90010008

Thread 3:
#0 0x70000978 in mach_msg_overwrite_trap
#1 0x70005a04 in mach_msg
#2 0x70026a2c in _pthread_become_available
#3 0x70026724 in pthread_exit
#4 0x70848ba0 in -[NSThread _exit]
#5 0x70842368 in forkThreadForFunction
#6 0x7002054c in _pthread_body

Thread 4:
#0 0x700252fc in select
#1 0x00162758 in poll
#2 0x0015ee70 in _pr_poll_with_poll
#3 0x02e77684 in nsSocketTransportService::Run(void)
#4 0x00235898 in nsThread::Main(void *)
#5 0x0016032c in _pt_root
#6 0x7002054c in _pthread_body

Thread 5:
#0 0x7003f4c8 in semaphore_wait_signal_trap
#1 0x7003f2c8 in _pthread_cond_wait
#2 0x0015b418 in PR_WaitCondVar
#3 0x02e81914 in nsDNSService::DequeuePendingQ(void)
#4 0x02e8131c in nsDNSService::Run(void)
#5 0x00235898 in nsThread::Main(void *)
#6 0x0016032c in _pt_root
#7 0x7002054c in _pthread_body

Thread 6:
#0 0x70044cf8 in semaphore_timedwait_signal_trap
#1 0x70044cd8 in semaphore_timedwait_signal
#2 0x7003f2b8 in _pthread_cond_wait
#3 0x0015b1b4 in pt_TimedWait
#4 0x0015b42c in PR_WaitCondVar
#5 0x002392f8 in TimerThread::Run(void)
#6 0x00235898 in nsThread::Main(void *)
#7 0x0016032c in _pt_root
#8 0x7002054c in _pthread_body

Thread 7:
#0 0x7003f4c8 in semaphore_wait_signal_trap
#1 0x7003f2c8 in _pthread_cond_wait
#2 0x0015b418 in PR_WaitCondVar
#3 0x002369b8 in nsThreadPool::GetRequest(nsIThread *)
#4 0x0023730c in nsThreadPoolRunnable::Run(void)
#5 0x00235898 in nsThread::Main(void *)
#6 0x0016032c in _pt_root
#7 0x7002054c in _pthread_body

PPC Thread State:
srr0: 0x000189a8 srr1: 0x0200f030 vrsave: 0x00000000
xer: 0x00000010 lr: 0x000189a0 ctr: 0x0026a51c mq: 0x00000000
r0: 0x000189a0 r1: 0xbffff590 r2: 0x04618292 r3: 0xbffff5f6
r4: 0x00000000 r5: 0x00037385 r6: 0x00000000 r7: 0x0000000d
r8: 0x00000000 r9: 0x0000001a r10: 0x0026a51c r11: 0x84000282
r12: 0x0026a51c r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x80bb3e9c
r20: 0x80bb362c r21: 0x0012fd20 r22: 0x046189c0 r23: 0xbffff5c8
r24: 0x44000288 r25: 0x003c9b80 r26: 0x003f9840 r27: 0x0000000f
r28: 0x003ef2f0 r29: 0x00000000 r30: 0x00037378 r31: 0x00018850

**********



[ Reply to This | # ]