3 # This code is open for re-use with no restrictions. xorg
4 # Intent is for someone to port to or use this for a webOS app.
5 # Homepage: http://www.webos-internals.org/wiki/Solution_to_App_Catalog_Installation_Limit
8 #-------------------------------------------------------------------------#
10 # 0.1.0 - original (xorg)
11 # 0.1.1 - added unlink and clean functions (daventx)
12 # 0.1.2 - added bulkmv function, allows moving many apps (xorg)
13 # 0.1.3 - added option for tar backups (xorg)
14 # 0.1.4 - added listmoved function to show apps already moved (xorg)
15 # 0.1.5 - added restoreall function, couple cleanup items (xorg)
16 # 0.1.6 - fixed to show usage if no appname supplied to link/unlink (xorg)
17 # 0.1.7 - added cleanexit (w/mount ro /)
18 # - added exit code documentation for javascripts calling this (xorg)
19 # 0.2.0 - will not move apps that would have attribute issues (xorg)
20 # - will not move apps that have no json file
21 # - improved error handling, improved listing shows actual app names
22 # 0.2.1 - minor update, proper cleanup if link command doesn't move app
23 # - don't create tar backup until testing if app is movable (xorg)
24 # 0.2.2 - broke with Fair Dinkum - resolved by explicit path for du (nt4cats)
25 # - will not move an app if it is running, thx to greg roll
26 # - faster listmoved apps (but no size), error reporting cleanup (xorg)
27 # 0.2.3 - new trap method for link cp errors ; version reporting in usage
28 # - doesn't allow to use mvapp if USB drive is mounted to computer (xorg)
29 # 0.2.4 - turned off TAR backups by default, added 'mvapp info'
30 # - added two hidden functions (see mvapp homepage for details)
31 # - 'mvapp ftr' - force tar restore, 'mvapp rtb' - remove tar backups
32 # 0.2.5 - better screen formatting for Terminal app, added shortcuts
33 # - added /var usage before/after move (xorg)
34 # 0.3.0 - added 'var diag' to check storage usage,
35 # - added linking for email/attachments (xorg)
36 # 0.3.2 - a few reporting improvements, cleaner launching of email
37 # - creates shortcut link m->mvapp
38 # 0.3.4 - now reports number of apps, new 'search' command will
39 # - best guess apps, report outputs now to rtf extension
40 # 0.3.5 - checks for abandoned links, check if fd installed
41 # 0.3.6 - doctor renamed to diag, update preware, terminal apps
42 # 0.3.8 - prep for next webosupdate
43 # 0.3.9 - fix for backup
44 # 0.4.0 - more webosupdate preps, restore direct to new location
45 # 0.4.2 - added migration for linked apps
46 #-------------------------------------------------------------------------#
49 #-------------------------------------------------------------------------#
50 # variables: these are globally available to all functions
51 #-------------------------------------------------------------------------#
55 MEDIA=/media/internal/.apps
56 VAR=/var/usr/palm/applications # Do not change this
59 IPKG_OFFLINE_ROOT=/media/internal/.apps
60 CRYPT=/media/cryptofs/apps/usr/palm/applications
62 # TAR backups are no longer needed, recommend setting to 0
63 BACKUP=0 # set to 1 for tar backups, 0 to disable
64 BACKUPDIR=/media/internal/.appbackups
66 # This should be turned on. Only turn off if javascript is calling this script.
69 #-------------------------------------------------------------------------#
70 # exit codes for javascripts:
72 # 1 - normal usage error
73 # 100 - USB drive is mounted, cannot use mvapp
77 # 30 - link for app does not exist
81 # 10 - app name not supplied
82 # 11 - link already exists
83 # 12 - app does not exist in VAR
84 # 13 - copy failed from VAR to MEDIA
85 # 14 - removing app from VAR failed
86 # 15 - APP has attributes not supported on FAT, did not move to MEDIA
87 # 16 - APP has no json file, did not move to MEDIA
88 # 17 - APP is running, need to close the app before moving
92 # 20 - app name not supplied
93 # 21 - app doesn't exist on MEDIA
94 # 22 - tar restore failed
95 # 23 - copy from MEDIA to VAR failed (only used if tar backup doesn't exist)
96 # 24 - remove from MEDIA failed
103 #-------------------------------------------------------------------------#
105 #-------------------------------------------------------------------------#
106 # function: cleanexit - exit with cleanup items
107 #-------------------------------------------------------------------------#
112 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1 &
114 # put / back to read only
115 mount -o remount,ro / &
117 # Uncomment if you want verbose exit codes
118 # echo "exit code: $code"
122 # end of cleanexit function
125 #-------------------------------------------------------------------------#
126 # function: usage - show command usage options
127 #-------------------------------------------------------------------------#
132 exitcode=1 # default exit code for usage, otherwise exit with incode
136 echo "mvapp link <or> ln domain.appname - move app to media, create link"
137 echo "mvapp bulkmv <or> bm - move/link many apps"
138 echo "mvapp search <or> s appname - search for apps to link/unlk/clean"
139 echo "mvapp unlink <or> ul domain.appname - restore app to var, remove link"
140 echo "mvapp clean <or> c domain.appname - remove app dir and links"
141 echo "mvapp list <or> ls - list all apps sorted by size"
142 echo "mvapp listmoved <or> lm - list apps that have been moved"
143 echo "mvapp restoreall <or> ra - restore all apps to original"
145 echo "mvapp linkemail <or> le - move email/attach to media and link"
146 echo "mvapp unlinkemail <or> ue - restore email/attach to var, rm link"
148 echo "mvapp diag <or> d - report /var usage, diagnositics"
149 echo "mvapp diag <or> d media - with size of apps on media (slow)"
150 echo "mvapp info <or> i - view mvapp homepage in phone browser"
152 echo "mvapp backup <or> b - backup apps/email b4 webos update"
153 echo "mvapp restorebk <or> rb - restore from backup after os update"
154 echo "mvapp postupd - use if no backup before os update"
158 # end of usage function
160 #-------------------------------------------------------------------------#
161 # function: info - launch the mvapp page on webosinternals
162 #-------------------------------------------------------------------------#
165 HOMEPAGE=http://www.webos-internals.org/wiki/Solution_to_App_Catalog_Installation_Limit
166 luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.browser\",\"params\":{\"scene\":\"page\",\"target\":\"$HOMEPAGE\"}} >/dev/null 2>&1
168 echo "View on the phone web browser..."
171 # end of info function
174 #-------------------------------------------------------------------------#
175 # function: cleanapp - removes symbolic links and folder in media and var
176 #-------------------------------------------------------------------------#
181 mount -o remount,rw /
183 # exit to usage if no app name supplied
186 echo "No app name supplied."
192 echo "Continue to remove all traces of $APP."
194 if [ -d $MEDIA/$APP ]
196 echo "Removing $MEDIA/$APP..."
199 echo "Nothing to remove."
205 # Continue on if PROMPTS turned off (call from outside app)
206 if [ $PROMPTS -eq 1 ]
208 echo "This will remove $APP from both...."
212 echo "FIRST ATTEMPT TO... remove the app "
213 echo "from Launcher or Homebrew installer."
215 echo -e "Are you sure you want to remove.."
216 echo -e "$APP? [y/N]: \c"
224 echo "Size of $VAR before cleanup... "
226 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
228 if [ -d $MEDIA/$APP ]
231 echo "Removed directory" $MEDIA/$APP
236 echo "Removed directory" $VAR/$APP
237 rm -r /var/usr/lib/ipkg/info/${APP}"*"
242 echo "Removed link" $VAR/$APP
244 if [ -f $BACKUPDIR/$APP.tgz ]
246 rm -r $BACKUPDIR/$APP.tgz
247 echo "Removed tar backup" $BACKUPDIR/$APP.tgz
251 # rescan luna in case it's needed
252 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1
253 echo "$APP directories and links removed."
254 echo "Size of $VAR after cleanup... "
256 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
259 # end of cleanup function
262 #-------------------------------------------------------------------------#
263 # function: listapps - list the size of each app, sort showing largest last
264 #-------------------------------------------------------------------------#
266 echo "First number is size in KB. "
267 echo "Size of 0 is an app already linked."
269 for i in `/usr/bin/du -s * | sort -n |cut -f 2`
272 SIZE=`/usr/bin/du -s $VAR/$APP |cut -f1`
274 if [ -f $VAR/$APP/appinfo.json ]
276 TITLE=`grep title $VAR/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2`
278 echo "$SIZE - $APP - $TITLE"
283 # end of listapps function
285 #-------------------------------------------------------------------------#
286 # function: listmoved - list apps moved/linked, sort showing largest last
287 #-------------------------------------------------------------------------#
292 echo "No apps linked yet..."
296 echo "Generating list, hold please."
297 echo "This may take up to a minute..."
299 # for i in `/usr/bin/du -s * | sort -n |cut -f 2`
300 for i in `ls -tr $MEDIA`
303 SIZE=`/usr/bin/du -s $MEDIA/$APP |cut -f1`
306 if [ -f $MEDIA/$APP/appinfo.json ]
308 TITLE=`grep title $MEDIA/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2`
310 echo "$SIZE - $APP - $TITLE"
313 # end of listmoved function
316 #-------------------------------------------------------------------------#
317 # function: linkapp - move the app to media and create symbolic link
318 #-------------------------------------------------------------------------#
325 echo -e "\nNo application supplied..."
330 # Check if the app is running
331 luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 | grep $APP >/dev/null 2>&1
334 echo -e "\n$APP is running. \nClose the app before moving."
339 if [ ! -f $VAR/$APP/appinfo.json ]
341 echo -e "\n$APP has no json file. \nRecommend not moving."
342 echo -e "\nMove anyway? [y/N]: \c"
345 [Yy]*) echo "Continuing with install...";;
346 *) code=16; return $code;;
357 echo -e "Link already exists for... \n${APP}"
361 TITLE=`grep title $VAR/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2`
363 mount -o remount,rw /
367 echo -e "\nMoving... \n$APP \n$TITLE \nto $MEDIA..."
369 echo "$APP does not exist..."
374 mount -o remount,rw /
376 echo -e "\nSize before move... "
378 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
382 # move over to USB drive
383 cp -rp $VAR/$APP $MEDIA >/tmp/cpresult.out 2>&1
384 if [ -s /tmp/cpresult.out ]
386 grep "cannot preserve" /tmp/cpresult.out >/dev/null 2>&1
390 echo -e "\n$APP \nCANNOT BE MOVED as it \ncontains special attributes."
391 echo "Leaving app in original location."
392 echo -e "This is not an error message. \nmvapp properly handled this."
398 echo -e "Copy failed. \nLeaving app in original location."
407 # Backup using tar if enabled
410 if [ ! -d $BACKUPDIR ]
414 echo -e "Backing up $APP $TITLE \nto $BACKUPDIR using tar..."
415 tar czf $BACKUPDIR/${APP}.tgz $VAR/$APP 2>&1 >/dev/null
421 echo -e "Remove failed. \nLeaving app in original location."
426 # create the symbolic link
427 ln -s $MEDIA/$APP $VAR/$APP
429 # rescan luna in case it's needed
430 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1
432 echo -e "$APP \nSUCCESSFULLY moved and linked."
433 echo -e "\nSize after move... "
435 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
437 # end of linkapp function
440 #-------------------------------------------------------------------------#
441 # function: unlinkapp - restore the app to var and remove symbolic link
442 #-------------------------------------------------------------------------#
447 echo "No application supplied..."
451 mount -o remount,rw /
453 if [ -d $MEDIA/$APP ]
456 echo "RESTORING $APP..."
458 echo -e "\n$APP does not exist \nor was not moved.\n\n"
462 echo "Size of $VAR before move... "
464 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
466 # remove the old symbolic link
469 # move to original location or restore from tar if it exists
470 if [ -f $BACKUPDIR/$APP.tgz ] && [ $BACKUP -eq 1 ]
472 echo "Restoring from tar backup...."
474 tar xzf $BACKUPDIR/$APP.tgz
477 echo "Tar restore FAILED. Remove and restore app using official webOS/Pre methods."
480 rm -r $BACKUPDIR/$APP.tgz
483 echo "Restoring from $MEDIA..."
484 cp -r $MEDIA/$APP $VAR
487 echo -e "Copy FAILED. \nLeaving app in $MEDIA."
495 echo -e "Remove FAILED. \nLeaving app in $MEDIA."
500 # rescan luna in case it's needed
501 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1
503 echo -e "$APP \nmoved and unlinked SUCCESSFULLY."
504 echo "Size after move... "
506 df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}'
508 # end of unlinkapp function
510 #-------------------------------------------------------------------------#
511 # function: bulkmv - move/link many apps
512 #-------------------------------------------------------------------------#
516 echo "This allows moving many apps."
517 echo "Starting with the largest apps."
521 mount -o remount,rw /
524 for i in `/usr/bin/du -s * | sort -nr |cut -f 2`
527 SIZE=`/usr/bin/du -sh $APP |cut -f 1`
528 TITLE=`grep title $VAR/$APP/appinfo.json 2>/dev/null |cut -d: -f2 |cut -d\" -f2`
530 echo "------------------"
532 echo -e "Size of $APP \n$TITLE \nis $SIZE."
534 echo -e "\nWould you like to move and link...\n$TITLE? [y/N/q]: \c"
539 *) echo "$APP not moved."
546 # end of bulkmv function
548 #-------------------------------------------------------------------------#
549 # function: restoreall - restore all apps, back to /var
550 #-------------------------------------------------------------------------#
553 #Only confirm if PROMPT turned on. (allows outside app to call)
554 if [ $PROMPTS -eq 1 ]
557 echo "This will restore all applications back to original location"
558 echo "and remove the links. Recommend charging phone during "
559 echo "restore if battery low or if many apps to restore."
560 echo -e "Are you sure you want to continue? [y/N]: \c"
568 ls $MEDIA | while read APP
570 echo "Restoring $APP and unlinking..."
574 # end of restoreall function
576 #-------------------------------------------------------------------------#
577 # function: removetarbackups - remove entire tar backup directory
578 #-------------------------------------------------------------------------#
580 echo "Tar backups are no longer needed and waste space on /media."
581 echo "Backups are located in $BACKUPDIR"
582 echo "Type \"remove\" to remove entire backup directory: "
585 [Rr]emove) echo "Removing $BACKUPDIR..."
593 # end of removetarbackups function
595 #-------------------------------------------------------------------------#
596 # function: checklinks - check to make sure links match .apps
597 #-------------------------------------------------------------------------#
605 echo "Checking abandoned links..."
607 #ls $MEDIA |while read app
608 for app in `ls $MEDIA`
610 if [ ! -h $VAR/$app ]
613 echo "Missing link for..."
617 echo "on media.
\87Probably leftovers from"
618 echo "deleted app. Recommend removing."
620 echo "Would you like"
621 echo -e "to remove the app? [y/N]: \c"
624 [Yy]*) rm -r $MEDIA/$app;;
628 echo "Checklinks complete."
630 } #end of checklinks function
632 #-------------------------------------------------------------------------#
633 # function: diag - report var storage usage areas
634 #-------------------------------------------------------------------------#
637 ownerid=`ls -ld /media/internal |cut -d" " -f5`
638 if [ $ownerid != "root" ]
641 echo "/media/internal is not owned by root."
642 echo "Was SFTP installed? May have impact."
647 echo "Gathering diag report, hold please..."
648 if [ -d $MEDIA ] && [ $APP ]
650 mappsz=`/usr/bin/du -sm $MEDIA |cut -f1`
652 #varused=df -m /var |grep /var |awk '{print ": "$2,"MB " $4 " - avail: " $3,"MB"}'
653 varused=`df -m /var |grep /var |awk '{print $2}'`
654 varpct=`df -m /var |grep /var |awk '{print $4}'`
655 varavail=`df -m /var |grep /var |awk '{print $3}'`
656 echo "var used: ${varused}MB $varpct"
657 echo "var available: ${varavail}MB"
659 appsz=`/usr/bin/du -sm $VAR |cut -f1`
660 echo "app used: ${appsz}MB on /var"
662 numapps=`ls $VAR |wc -l`
663 echo "# total apps: $numapps"
667 nummapps=`ls $MEDIA |wc -l`
668 numvapps=`expr $numapps - $nummapps`
669 echo "# var apps: $numvapps"
670 echo "# media apps: $nummapps"
673 if [ -d $MEDIA ] && [ $APP ]
675 echo "app used: ${mappsz}MB on /media"
676 nummapps=`ls $MEDIA |wc -l`
677 echo "# media apps: $nummapps"
680 if [ -h /var/luna/data/emails ]
682 emailsz=`/usr/bin/du -sm /media/internal/.data/emails |cut -f1`
683 attachsz=`/usr/bin/du -sm /media/internal/.data/attachments |cut -f1`
684 echo "email used: ${emailsz}MB on /media"
685 echo "attachmnt used: ${attachsz}MB on /media"
687 emailsz=`/usr/bin/du -sm /var/luna/data/emails |cut -f1`
688 attachsz=`/usr/bin/du -sm /var/luna/data/attachments |cut -f1`
689 echo "email used: ${emailsz}MB on /var"
690 echo "attach used: ${attachsz}MB on /var"
693 softtemp=`/usr/bin/du -sm /var/lib/software/tmp |cut -f1`
694 echo "var tmp used: ${softtemp}MB"
699 optsz=`/usr/bin/du -sm /opt |cut -f1`
700 echo "opt used: ${optsz}MB"
703 ipkglist=`/usr/bin/du -sm /var/usr/lib/ipkg/lists |cut -f1`
704 echo "ipkg lists: ${ipkglist}MB"
707 echo "Recommendations..."
709 echo "- Keep \"var used\" well below 125MB."
712 if [ $varused -gt "125" ]
715 echo "- Consider reducing space on /var."
716 echo "/var use is greater than 125MB."
718 if [ $softtemp -gt 1 ]
721 echo "- Check Updates app."
722 echo "/var/lib/software/tmp is larger"
723 echo "than it should be. May have an"
724 echo "update waiting to be applied."
727 if [ $appsz -gt "20" ] && [ $varused -gt 125 ]
730 echo "- Consider moving apps: mvapp bulkmv"
733 totalsz=`expr $emailsz + $attachsz`
734 if [ ! -h /var/luna/data/emails ] && [ $totalsz -gt "10" ]
737 echo "- Consider moving email: mvapp linkemail"
739 if [ $optsz -gt 10 ] && [ $varused -gt 125 ]
742 echo "- Consider removing optware packages."
743 echo "You have optware software installed."
744 echo "See: ipkg-opt list_installed"
745 echo " Do: ipkg-opt remove ipkg"
746 echo "Ask on PreCentral."
748 if [ $ipkglist -gt 10 ]
751 echo "- ipkg list size is rather large."
752 echo "check /var/usr/lib/ipkg/lists"
753 ls -l |awk '{print $5 "\t" $9}'
759 echo "This report is available on media"
760 echo "drive as... diagreport.rtf"
761 } # end of diag function
763 #-------------------------------------------------------------------------#
764 # function: linkemail - move/link email and attachments to /media
765 #-------------------------------------------------------------------------#
768 mdata=/media/internal/.data
770 echo "This will move email and attachments"
771 echo "to the media drive. It is unknown"
772 echo "if there will be email issues when"
773 echo "Palm upgrades webOS. See \"mvapp "
774 echo "info\" for details."
776 echo "If you are writing a new email,"
777 echo "complete and send before continuing."
779 echo -e "Do you want to continue? [y/N]: \c"
786 if [ -h $vdata/emails ]
788 echo "email link already exists."
792 echo "Closing email application and background service..."
793 luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 \
794 | tr '{' '\n' | grep com.palm.app.email |cut -d: -f3 |cut -d"\"" -f2 \
798 luna-send -n 1 "palm://com.palm.applicationManager/close" "{\"processId\":\"$it\"}"
808 #move email to media and create link
809 echo "Do not close Terminal during moves."
810 echo "Moves could take several minutes."
811 echo "Moving/linking email. "
812 cp -rp $vdata/emails $mdata 2>&1 >/tmp/cpemail.out
813 if [ -s /tmp/cpemail.out ]
815 echo "Copying email failed. Leaving email in place."
818 #mv $vdata/emails $vdata/emails.$$
820 ln -s $mdata/emails $vdata/emails
823 #move attachments to media and create link
824 echo "Moving/linking attachments..."
825 cp -rp $vdata/attachments $mdata 2>&1 >/tmp/cpemail.out
826 if [ -s /tmp/cpemail.out ]
828 echo "Copying attachments failed. Leaving attachments in place."
831 #mv $vdata/attachments $vdata/attachments.$$
832 rm -r $vdata/attachments
833 ln -s $mdata/attachments $vdata/attachments
835 #starup email process
836 echo "Starting up email..."
837 luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.email\"} >/dev/null 2>&1
840 echo "SUCCESSFUL: Confirm you can access your email."
842 echo "NOTE: First time you run email,"
843 echo "it may ask if you want to add "
844 echo "accounts. Press Done."
846 } #end of link email function
848 #-------------------------------------------------------------------------#
849 # function: unlinkemail - move email and attachments to /media
850 #-------------------------------------------------------------------------#
853 mdata=/media/internal/.data
856 if [ ! -d $mdata/emails ]
858 echo "no email on media"
862 if [ ! -h $vdata/emails ]
864 echo "email link does not exist on /var"
868 echo "Closing email application and background service..."
869 luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 \
870 | tr '{' '\n' | grep com.palm.app.email |cut -d: -f3 |cut -d"\"" -f2 \
874 luna-send -n 1 "palm://com.palm.applicationManager/close" "{\"processId\":\"$it\"}"
877 echo "Do not close Terminal during restore."
878 echo "Restore could take several minutes."
879 echo "Restoring email to /var..."
882 # cp email from media to var
883 cp -rp $mdata/emails $vdata 2>&1 >/tmp/cpemail.out
884 if [ -s /tmp/cpemail.out ]
886 echo "copying email back to /var failed."
891 echo "Restoring attachments to /var..."
892 # rm the attachment link
893 rm $vdata/attachments
894 # cp attachments from media to var
895 cp -rp $mdata/attachments $vdata 2>&1 >/tmp/cpemail.out
896 if [ -s /tmp/cpemail.out ]
898 echo "copying attachments back to /var failed."
902 rm -r $mdata/attachments
904 #starup email process
905 echo "Starting up email..."
906 luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.email\"} >/dev/null 2>&1
909 echo "SUCCESSFUL: Confirm you can access your email."
911 } #end of unlinkemail function
913 #-------------------------------------------------------------------------#
914 # function: search - search for partial app names
915 #-------------------------------------------------------------------------#
920 for i in `ls -dt $VAR/*${APP}* $MEDIA/*${APP}* |sort `
923 if [ -f $i/appinfo.json ]
925 TITLE=`grep title $i/appinfo.json |cut -d: -f2 |cut -d\" -f2`
935 echo "App is currently linked to media."
937 if [ -d $MEDIA/$APP ]
939 echo "App is on media drive but has no link."
941 echo "App is in original location, not linked."
945 echo -e "\nWould you like to link/unlink/clean/skip this app? [l/u/c/S/q]: \c"
949 u) mvapp unlink $APP;;
950 c) mvapp clean $APP;;
954 echo -e "\n\n---------------------\n"
960 } #end of search function
963 #-------------------------------------------------------------------------#
964 # function: removelinks - remove links from var app dir
965 #-------------------------------------------------------------------------#
969 echo "This will remove mvapp links on /var."
970 echo "Only run if instructed to do so."
971 echo -e "Certain you want to continue? [y/N]:\c"
978 if [ ! -d /tmp/applinks ]
989 echo "$count - $app has a link"
990 count=`expr $count + 1`
991 cp -rp $VAR/$app /tmp/applinks
997 tar czf /media/internal/applinkbackup.tgz .
1002 #-------------------------------------------------------------------------#
1003 # function: postupd - move apps to /media/cryptofs
1004 #-------------------------------------------------------------------------#
1007 HOMEPAGE=http://m.forums.precentral.net/webos-internals/212349-solution-app-catalog-limit-symbolic-link-method.html
1009 luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.browser\",\"params\":{\"scene\":\"page\",\"target\":\"$HOMEPAGE\"}} >/dev/null 2>&1
1012 You should not run this until
1013 confirmed this is needed.
1015 Check PreCentral mvapp thread
1016 before continuing. mvapp thread has
1017 been launched for you on phone.
1018 Read the first post before continuing.
1021 echo -e "\nReady to continue? [n/Y]: \c"
1031 Large applications may take up
1032 to a minute each to copy.
1034 Do not close the Terminal app
1035 during this process.
1039 if [ ! -d /media/cryptofs/apps/usr/palm/applications ]
1041 echo "New app home location does not exist."
1042 echo "Need to run webOS update first."
1046 if [ ! -d /media/internal/.apps ]
1048 echo "media/internal/.apps does not exist"
1052 cd /media/internal/.apps
1054 echo "Copying $numapps linked"
1055 echo "applications to new app home..."
1061 echo "$count - $app"
1062 cp -rp $app /media/cryptofs/apps/usr/palm/applications
1065 echo "Copy failed. Check PreCentral thread."
1066 export error=`expr $error +1`
1068 count=`expr $count - 1`
1073 echo "There were $error copy error(s)."
1074 echo "Ask on PreCentral mvapp thread."
1078 echo "Copy complete."
1079 echo "Check applications."
1080 echo "If issues, see PreCentral mvapp thread."
1085 #-------------------------------------------------------------------------#
1086 # function: backup - perform tar backups
1087 #-------------------------------------------------------------------------#
1090 echo "This will create backups for"
1091 echo "email, var apps and media apps."
1092 echo "This may take up2 10-20 minutes."
1093 echo "Will show progress of each file."
1095 echo -e "\nReady to continue? [n/Y]: \c"
1103 echo "Performing backups of all apps..."
1104 cd /var/usr/palm/applications
1105 tar cvzf /media/internal/varappbackups.tgz .
1107 if [ -d /media/internal/.apps ]
1109 cd /media/internal/.apps
1110 tar cvzf /media/internal/mediaappbackups.tgz .
1113 if [ -d /media/internal/.data ]
1115 echo "Backing up email and attachments."
1116 cd /media/internal/.data
1117 tar cvzf /media/internal/mediaemail.tgz .
1121 echo "You may now perform the webOS update"
1122 echo "or run another backup just before update."
1123 echo "After webos update, run mvapp restorebk."
1127 #-------------------------------------------------------------------------#
1128 # function: restorebk - restore backups direct to new location
1129 #-------------------------------------------------------------------------#
1132 if [ ! -f /media/internal/mediaappbackups.tgz ]
1134 echo "Backups dont exist."
1135 echo "Try mvapp postupd command. "
1138 echo "This will restore all of your media apps"
1139 echo -e "to the new location. Continue? [y/N]: \c"
1150 cd /media/internal/.apps
1151 tar xvzf /media/internal/mediaappbackups.tgz
1154 echo "Restore complete. Check your apps."
1156 } #end of restorebk function
1158 #-------------------------------------------------------------------------#
1159 # function: cleanup - post cleanup after webos update
1160 #-------------------------------------------------------------------------#
1163 echo "This will clean out .apps/data/backups"
1164 echo "created by mvapp. Do not continue"
1165 echo "until you have run mvapp postupd."
1167 echo -e "Continue? [y/N]: \c"
1174 echo "Removing .apps folder..."
1175 rm -r /media/internal/.apps
1178 echo "Removing backups..."
1179 rm applinkbackup.tgz mediaemail.tgz varappbackups.tgz mediaappbackups.tgz >/dev/null 2>&1
1184 #-------------------------------------------------------------------------#
1185 # function: migrate - migrate linked apps after webos update
1186 #-------------------------------------------------------------------------#
1195 echo "Migrate only works after OS update"
1196 echo "has been applied. Firt do OS update"
1197 echo "and then run this command."
1202 echo ".apps folder does not exist."
1203 echo "try mvapp postupd2"
1204 echo "or mvapp restorebk"
1207 if [ "$app" = "*preware" ]
1209 echo "Skipping Preware."
1220 if [ ! -d $VAR/$app ]
1222 grep cryptofs /media/cryptofs/apps/usr/lib/ipkg/info/${app}*manifest >/dev/null 2>&1
1225 echo "Prepping migration: $app"
1228 cp $MEDIA/$app/appinfo.json $VAR/$app
1232 if [ ! -d $CRYPT/$app ]
1234 cp -rp $MEDIA/$app $CRYPT
1240 echo "Complete. Will now restart Luna."
1241 echo "If apps do not appear afterwards,"
1242 echo "run: mvapp postupd"
1243 echo "Press Enter to Continue: "
1245 (nohup sleep 5; initctl stop LunaSysMgr; sleep 5; initctl start LunaSysMgr) &
1249 #-------------------------------------------------------------------------#
1250 # function: postupd2 - alternate method based on ipkg lists
1251 #-------------------------------------------------------------------------#
1258 echo "Cannot cd into $CRYPT"
1259 echo "Must update webOS first"
1265 grep cryptofs /media/cryptofs/apps/usr/lib/ipkg/info/${app}*manifest >/dev/null 2>&1
1268 echo "Prepping migration: $app"
1269 if [ ! -d $VAR/$app ]
1273 if [ -f $CRYPT/$app/appinfo.json ]
1275 cp $CRYPT/$app/appinfo.json $VAR/$app
1282 echo "Complete. Will now restart Luna."
1283 echo "If apps do not appear afterwards,"
1284 echo "run: mvapp migrate"
1285 echo "Press Enter to Continue: "
1287 (nohup sleep 5; initctl stop LunaSysMgr; sleep 5; initctl start LunaSysMgr) &
1292 #-------------------------------------------------------------------------#
1293 # function: checkfd - check if fair dinkum is installed
1294 #-------------------------------------------------------------------------#
1296 if [ -f /usr/local/bin/ipkg ]
1298 echo "Fair Dinkum is installed and enabled."
1300 echo "Fair Dinkum is NOT installed or enabled."
1303 ipkg -o /var list_installed |grep ipkgservice
1304 ipkg -o /var list_installed |grep preware
1308 #-------------------------------------------------------------------------#
1309 # function: install latest development version
1310 #-------------------------------------------------------------------------#
1312 echo "Installing latest development version."
1313 echo "Use \"ma\" instead of \"mvapp\"."
1315 wget http://gitorious.org/webos-internals/mvapp/blobs/raw/master/mvapp
1317 mv mvapp /usr/local/bin/ma
1318 echo "Done. Type... ma"
1319 } #end of installdev function
1322 #-------------------------------------------------------------------------#
1323 # function: updatepreware - update to latest version of preware
1324 #-------------------------------------------------------------------------#
1329 wget http://gitorious.org/webos-internals/bootstrap/blobs/raw/master/preware-bootstrap.sh
1330 #Alternatively, you can use this tiny URL: http://bit.ly/dDEMO
1331 sh preware-bootstrap.sh
1333 echo "PreWare update complete..."
1338 /usr/bin/ipkg -o /var update
1339 /usr/bin/ipkg -o /var install org.webosinternals.ipkgservice
1340 /usr/bin/ipkg -o /var install org.webosinternals.preware
1341 sh /var/usr/lib/ipkg/info/org.webosinternals.ipkgservice.postinst
1345 #-------------------------------------------------------------------------#
1346 # function: updateterminal - update to latest version of terminal
1347 #-------------------------------------------------------------------------#
1351 ipkg -o /var install org.webosinternals.termplugin
1352 ipkg -o /var install org.webosinternals.terminal
1357 #-------------------------------------------------------------------------#
1358 # function: startup - startup items
1359 #-------------------------------------------------------------------------#
1364 echo "mvapp version: $VERSION"
1366 mount -o remount,rw /
1368 #create shortcut 'm'
1369 if [ ! -h /usr/local/bin/m ]
1372 echo "Created shortcut to mvapp."
1373 echo "Can now use just 'm' to run 'mvapp'."
1375 ln -s /usr/local/bin/mvapp /usr/local/bin/m
1378 if [ ! -f /usr/local/bin/mvappd ]
1381 wget http://gitorious.org/webos-internals/mvapp/blobs/raw/master/mvapp >/dev/null 2>&1
1383 mv mvapp /usr/local/bin/mvappd
1386 df |grep /media/internal 2>&1 >/dev/null
1389 echo "USB drive is mounted to computer. You must unmount from USB to use mvapp."
1395 # end of startup function
1399 #-------------------------------------------------------------------------#
1400 # main - begins here
1401 #-------------------------------------------------------------------------#
1427 "ftr") # force tar restore
1431 "rtb") # remove all tar backups
1438 diag |tee /media/internal/diagreport.rtf
1458 "upw"|"updatepreware")
1461 "upw2"|"updatepreware2")
1464 "upt"|"updateterminal")