#!/bin/sh # This code is open for re-use per MIT license. xorg # Homepage: http://www.webos-internals.org/wiki/Solution_to_App_Catalog_Installation_Limit # #-------------------------------------------------------------------------# # versions: # 0.1.0 - original (xorg) #-------------------------------------------------------------------------# #-------------------------------------------------------------------------# # variables: these are globally available to all functions #-------------------------------------------------------------------------# COMMAND=$1 APP=$2 VERSION=0.1.0 MEDIA=/media/internal/.apps VAR=/var/usr/palm/applications # Do not change this IPKG_OFFLINE_ROOT=/media/internal/.apps CRYPT=/media/cryptofs/apps/usr/palm/applications # TAR backups are no longer needed, recommend setting to 0 BACKUP=0 # set to 1 for tar backups, 0 to disable BACKUPDIR=/media/internal/.appbackups # This should be turned on. Only turn off if javascript is calling this script. PROMPTS=1 #-------------------------------------------------------------------------# # exit codes for javascripts: # function usage: # 1 - normal usage error # 100 - USB drive is mounted, cannot use mvapp # # function cleanapp: # 0 - normal exit # 30 - link for app does not exist # # function linkapp: # 0 - normal exit # 10 - app name not supplied # 11 - link already exists # 12 - app does not exist in VAR # 13 - copy failed from VAR to MEDIA # 14 - removing app from VAR failed # 15 - APP has attributes not supported on FAT, did not move to MEDIA # 16 - APP has no json file, did not move to MEDIA # 17 - APP is running, need to close the app before moving # # function unlinkapp: # 0 - normal exit # 20 - app name not supplied # 21 - app doesn't exist on MEDIA # 22 - tar restore failed # 23 - copy from MEDIA to VAR failed (only used if tar backup doesn't exist) # 24 - remove from MEDIA failed # # function linkemail: # 0 - normal exit # 50 - # 51 - # #-------------------------------------------------------------------------# #-------------------------------------------------------------------------# # function: cleanexit - exit with cleanup items #-------------------------------------------------------------------------# cleanexit () { code=$1 luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1 & # put / back to read only mount -o remount,ro / & # Uncomment if you want verbose exit codes # echo "exit code: $code" exit $code } # end of cleanexit function #-------------------------------------------------------------------------# # function: usage - show command usage options #-------------------------------------------------------------------------# usage () { exitcode=$1 if [ ! $exitcode ] then exitcode=1 # default exit code for usage, otherwise exit with incode fi echo "Usage:" echo "mvapp link ln domain.appname - move app to media, create link" echo "mvapp bulkmv bm - move/link many apps" echo "mvapp search s appname - search for apps to link/unlk/clean" echo "mvapp unlink ul domain.appname - restore app to var, remove link" echo "mvapp clean c domain.appname - remove app dir and links" echo "mvapp list ls - list all apps sorted by size" echo "mvapp listmoved lm - list apps that have been moved" echo "mvapp restoreall ra - restore all apps to original" echo echo "mvapp linkemail le - move email/attach to media and link" echo "mvapp unlinkemail ue - restore email/attach to var, rm link" echo echo "mvapp diag d - report /var usage, diagnositics" echo "mvapp diag d media - with size of apps on media (slow)" echo "mvapp info i - view mvapp homepage in phone browser" echo echo "mvapp post135 - may need to run after 1.35 update" cleanexit $exitcode } # end of usage function #-------------------------------------------------------------------------# # function: info - launch the mvapp page on webosinternals #-------------------------------------------------------------------------# info () { HOMEPAGE=http://www.webos-internals.org/wiki/Solution_to_App_Catalog_Installation_Limit luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.browser\",\"params\":{\"scene\":\"page\",\"target\":\"$HOMEPAGE\"}} >/dev/null 2>&1 echo "View on the phone web browser..." } # end of info function #-------------------------------------------------------------------------# # function: cleanapp - removes symbolic links and folder in media and var #-------------------------------------------------------------------------# cleanapp () { clear mount -o remount,rw / # exit to usage if no app name supplied if [ ! $APP ] then echo "No app name supplied." usage 1 fi if [ -h $VAR/$APP ] then echo "Continue to remove all traces of $APP." else if [ -d $MEDIA/$APP ] then echo "Removing $MEDIA/$APP..." rm -r $MEDIA/$APP else echo "Nothing to remove." fi return 30 fi # Continue on if PROMPTS turned off (call from outside app) if [ $PROMPTS -eq 1 ] then echo "This will remove $APP from both...." echo "$VAR and " echo "$MEDIA" echo echo "FIRST ATTEMPT TO... remove the app " echo "from Launcher or Homebrew installer." echo echo -e "Are you sure you want to remove.." echo -e "$APP? [y/N]: \c" read answer case $answer in [Yy]*) continue;; *) cleanexit 0;; esac fi echo "Size of $VAR before cleanup... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' if [ -d $MEDIA/$APP ] then rm -r $MEDIA/$APP echo "Removed directory" $MEDIA/$APP fi if [ -d $VAR/$APP ] then rm -r $VAR/$APP echo "Removed directory" $VAR/$APP rm -r /var/usr/lib/ipkg/info/${APP}"*" fi if [ -h $VAR/$APP ] then rm -r $VAR/$APP echo "Removed link" $VAR/$APP fi if [ -f $BACKUPDIR/$APP.tgz ] then rm -r $BACKUPDIR/$APP.tgz echo "Removed tar backup" $BACKUPDIR/$APP.tgz fi # rescan luna in case it's needed luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1 echo "$APP directories and links removed." echo "Size of $VAR after cleanup... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' cleanexit 0 } # end of cleanup function #-------------------------------------------------------------------------# # function: listapps - list the size of each app, sort showing largest last #-------------------------------------------------------------------------# listapps () { echo "First number is size in KB. " echo "Size of 0 is an app already linked." cd $VAR for i in `/usr/bin/du -s * | sort -n |cut -f 2` do APP=$i SIZE=`/usr/bin/du -s $VAR/$APP |cut -f1` TITLE="" if [ -f $VAR/$APP/appinfo.json ] then TITLE=`grep title $VAR/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2` fi echo "$SIZE - $APP - $TITLE" done } # end of listapps function #-------------------------------------------------------------------------# # function: listmoved - list apps moved/linked, sort showing largest last #-------------------------------------------------------------------------# listmoved () { if [ ! -d $MEDIA ] then echo "No apps linked yet..." cleanexit 1 fi echo "Generating list, hold please." echo "This may take up to a minute..." cd $MEDIA # for i in `/usr/bin/du -s * | sort -n |cut -f 2` for i in `ls -tr $MEDIA` do APP=$i SIZE=`/usr/bin/du -s $MEDIA/$APP |cut -f1` #SIZE="" TITLE="" if [ -f $MEDIA/$APP/appinfo.json ] then TITLE=`grep title $MEDIA/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2` fi echo "$SIZE - $APP - $TITLE" done } # end of listmoved function #-------------------------------------------------------------------------# # function: linkapp - move the app to media and create symbolic link #-------------------------------------------------------------------------# linkapp () { clear if [ ! $APP ] then echo -e "\nNo application supplied..." usage 10 fi # Check if the app is running luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 | grep $APP >/dev/null 2>&1 if [ $? == 0 ] then echo -e "\n$APP is running. \nClose the app before moving." code=17 return $code fi if [ ! -f $VAR/$APP/appinfo.json ] then echo -e "\n$APP has no json file. \nRecommend not moving." echo -e "\nMove anyway? [y/N]: \c" read answer case $answer in [Yy]*) echo "Continuing with install...";; *) code=16; return $code;; esac fi if [ ! -d $MEDIA ] then mkdir $MEDIA fi if [ -h $VAR/$APP ] then echo -e "Link already exists for... \n${APP}" cleanexit 11 fi TITLE=`grep title $VAR/$APP/appinfo.json |cut -d: -f2 |cut -d\" -f2` mount -o remount,rw / if [ -d $VAR/$APP ] then echo -e "\nMoving... \n$APP \n$TITLE \nto $MEDIA..." else echo "$APP does not exist..." usage 12 fi mount -o remount,rw / echo -e "\nSize before move... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' echo # move over to USB drive cp -rp $VAR/$APP $MEDIA >/tmp/cpresult.out 2>&1 if [ -s /tmp/cpresult.out ] then grep "cannot preserve" /tmp/cpresult.out >/dev/null 2>&1 if [ $? = 0 ] then echo echo -e "\n$APP \nCANNOT BE MOVED as it \ncontains special attributes." echo "Leaving app in original location." echo -e "This is not an error message. \nmvapp properly handled this." code=15 rm -r $MEDIA/$APP rm /tmp/cpresult.out return $code else echo -e "Copy failed. \nLeaving app in original location." code=13 fi rm -r $MEDIA/$APP rm /tmp/cpresult.out return $code fi # Backup using tar if enabled if [ $BACKUP -eq 1 ] then if [ ! -d $BACKUPDIR ] then mkdir $BACKUPDIR fi echo -e "Backing up $APP $TITLE \nto $BACKUPDIR using tar..." tar czf $BACKUPDIR/${APP}.tgz $VAR/$APP 2>&1 >/dev/null fi rm -r $VAR/$APP if [ $? != 0 ] then echo -e "Remove failed. \nLeaving app in original location." rm -r $MEDIA/$APP cleanexit 14 fi # create the symbolic link ln -s $MEDIA/$APP $VAR/$APP # rescan luna in case it's needed luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1 echo -e "$APP \nSUCCESSFULLY moved and linked." echo -e "\nSize after move... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' } # end of linkapp function #-------------------------------------------------------------------------# # function: unlinkapp - restore the app to var and remove symbolic link #-------------------------------------------------------------------------# unlinkapp () { if [ ! $APP ] then echo "No application supplied..." usage 20 fi mount -o remount,rw / if [ -d $MEDIA/$APP ] then echo echo "RESTORING $APP..." else echo -e "\n$APP does not exist \nor was not moved.\n\n" cleanexit 21 fi echo "Size of $VAR before move... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' # remove the old symbolic link rm -r $VAR/$APP # move to original location or restore from tar if it exists if [ -f $BACKUPDIR/$APP.tgz ] && [ $BACKUP -eq 1 ] then echo "Restoring from tar backup...." cd / tar xzf $BACKUPDIR/$APP.tgz if [ $? -ne 0 ] then echo "Tar restore FAILED. Remove and restore app using official webOS/Pre methods." cleanexit 22 else rm -r $BACKUPDIR/$APP.tgz fi else echo "Restoring from $MEDIA..." cp -r $MEDIA/$APP $VAR if [ $? != 0 ] then echo -e "Copy FAILED. \nLeaving app in $MEDIA." cleanexit 23 fi fi rm -r $MEDIA/$APP if [ $? != 0 ] then echo -e "Remove FAILED. \nLeaving app in $MEDIA." rm -r $VAR/$APP cleanexit 24 fi # rescan luna in case it's needed luna-send -n 1 palm://com.palm.applicationManager/rescan {} >/dev/null 2>&1 echo -e "$APP \nmoved and unlinked SUCCESSFULLY." echo "Size after move... " /usr/bin/du -sh $VAR df -m /var |grep /var |awk '{print "/var used: "$2,"MB " $4 " - avail: " $3,"MB"}' } # end of unlinkapp function #-------------------------------------------------------------------------# # function: bulkmv - move/link many apps #-------------------------------------------------------------------------# bulkmv() { echo echo echo "This allows moving many apps." echo "Starting with the largest apps." echo mount -o remount,rw / cd $VAR for i in `/usr/bin/du -s * | sort -nr |cut -f 2` do export APP=$i SIZE=`/usr/bin/du -sh $APP |cut -f 1` TITLE=`grep title $VAR/$APP/appinfo.json 2>/dev/null |cut -d: -f2 |cut -d\" -f2` echo echo "------------------" echo echo -e "Size of $APP \n$TITLE \nis $SIZE." echo -e "\nWould you like to move and link...\n$TITLE? [y/N/q]: \c" read answer case $answer in [Yy]*) linkapp;; [Qq]*) cleanexit 0;; *) echo "$APP not moved." continue;; esac echo done } # end of bulkmv function #-------------------------------------------------------------------------# # function: restoreall - restore all apps, back to /var #-------------------------------------------------------------------------# restoreall() { #Only confirm if PROMPT turned on. (allows outside app to call) if [ $PROMPTS -eq 1 ] then echo echo "This will restore all applications back to original location" echo "and remove the links. Recommend charging phone during " echo "restore if battery low or if many apps to restore." echo -e "Are you sure you want to continue? [y/N]: \c" read answer case $answer in [Yy]*) continue;; *) cleanexit 0;; esac fi ls $MEDIA | while read APP do echo "Restoring $APP and unlinking..." unlinkapp done } # end of restoreall function #-------------------------------------------------------------------------# # function: removetarbackups - remove entire tar backup directory #-------------------------------------------------------------------------# removetarbackups() { echo "Tar backups are no longer needed and waste space on /media." echo "Backups are located in $BACKUPDIR" echo "Type \"remove\" to remove entire backup directory: " read answer case $answer in [Rr]emove) echo "Removing $BACKUPDIR..." if [ -d $BACKUPDIR ] then rm -r $BACKUPDIR fi ;; esac } # end of removetarbackups function #-------------------------------------------------------------------------# # function: checklinks - check to make sure links match .apps #-------------------------------------------------------------------------# checklinks() { if [ ! -d $MEDIA ] then return 0 fi echo "Checking abandoned links..." #ls $MEDIA |while read app for app in `ls $MEDIA` do if [ ! -h $VAR/$app ] then echo echo "Missing link for..." echo echo "$app" echo echo "on media. ‡Probably leftovers from" echo "deleted app. Recommend removing." echo echo "Would you like" echo -e "to remove the app? [y/N]: \c" read answer case $answer in [Yy]*) rm -r $MEDIA/$app;; esac fi done echo "Checklinks complete." } #end of checklinks function #-------------------------------------------------------------------------# # function: diag - report var storage usage areas #-------------------------------------------------------------------------# diag() { ownerid=`ls -ld /media/internal |cut -d" " -f5` if [ $ownerid != "root" ] then echo echo "/media/internal is not owned by root." echo "Was SFTP installed? May have impact." echo fi echo echo "Gathering diag report, hold please..." if [ -d $MEDIA ] && [ $APP ] then mappsz=`/usr/bin/du -sm $MEDIA |cut -f1` fi #varused=df -m /var |grep /var |awk '{print ": "$2,"MB " $4 " - avail: " $3,"MB"}' varused=`df -m /var |grep /var |awk '{print $2}'` varpct=`df -m /var |grep /var |awk '{print $4}'` varavail=`df -m /var |grep /var |awk '{print $3}'` echo "var used: ${varused}MB $varpct" echo "var available: ${varavail}MB" appsz=`/usr/bin/du -sm $VAR |cut -f1` echo "app used: ${appsz}MB on /var" numapps=`ls $VAR |wc -l` echo "# total apps: $numapps" if [ -d $MEDIA ] then nummapps=`ls $MEDIA |wc -l` numvapps=`expr $numapps - $nummapps` echo "# var apps: $numvapps" echo "# media apps: $nummapps" fi if [ -d $MEDIA ] && [ $APP ] then echo "app used: ${mappsz}MB on /media" nummapps=`ls $MEDIA |wc -l` echo "# media apps: $nummapps" fi if [ -h /var/luna/data/emails ] then emailsz=`/usr/bin/du -sm /media/internal/.data/emails |cut -f1` attachsz=`/usr/bin/du -sm /media/internal/.data/attachments |cut -f1` echo "email used: ${emailsz}MB on /media" echo "attachmnt used: ${attachsz}MB on /media" else emailsz=`/usr/bin/du -sm /var/luna/data/emails |cut -f1` attachsz=`/usr/bin/du -sm /var/luna/data/attachments |cut -f1` echo "email used: ${emailsz}MB on /var" echo "attach used: ${attachsz}MB on /var" fi softtemp=`/usr/bin/du -sm /var/lib/software/tmp |cut -f1` echo "var tmp used: ${softtemp}MB" optsz=0 if [ -d /opt ] then optsz=`/usr/bin/du -sm /opt |cut -f1` echo "opt used: ${optsz}MB" fi ipkglist=`/usr/bin/du -sm /var/usr/lib/ipkg/lists |cut -f1` echo "ipkg lists: ${ipkglist}MB" echo echo "Recommendations..." echo echo "- Keep \"var used\" well below 125MB." if [ $varused -gt "125" ] then echo echo "- Consider reducing space on /var." echo "/var use is greater than 125MB." fi if [ $softtemp -gt 1 ] then echo echo "- Check Updates app." echo "/var/lib/software/tmp is larger" echo "than it should be. May have an" echo "update waiting to be applied." echo fi if [ $appsz -gt "20" ] && [ $varused -gt 125 ] then echo echo "- Consider moving apps: mvapp bulkmv" fi totalsz=`expr $emailsz + $attachsz` if [ ! -h /var/luna/data/emails ] && [ $totalsz -gt "10" ] then echo echo "- Consider moving email: mvapp linkemail" fi if [ $optsz -gt 10 ] && [ $varused -gt 125 ] then echo echo "- Consider removing optware packages." echo "You have optware software installed." echo "See: ipkg-opt list_installed" echo " Do: ipkg-opt remove ipkg" echo "Ask on PreCentral." fi if [ $ipkglist -gt 10 ] then echo echo "- ipkg list size is rather large." echo "check /var/usr/lib/ipkg/lists" ls -l |awk '{print $5 "\t" $9}' fi echo echo "This report is available on media" echo "drive as... diagreport.rtf" } # end of diag function #-------------------------------------------------------------------------# # function: linkemail - move/link email and attachments to /media #-------------------------------------------------------------------------# linkemail() { vdata=/var/luna/data mdata=/media/internal/.data echo "This will move email and attachments" echo "to the media drive. It is unknown" echo "if there will be email issues when" echo "Palm upgrades webOS. See \"mvapp " echo "info\" for details." echo echo "If you are writing a new email," echo "complete and send before continuing." echo echo -e "Do you want to continue? [y/N]: \c" read answer case $answer in [Yy]*) continue;; *) cleanexit 0;; esac if [ -h $vdata/emails ] then echo "email link already exists." cleanexit 0 fi echo "Closing email application and background service..." luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 \ | tr '{' '\n' | grep com.palm.app.email |cut -d: -f3 |cut -d"\"" -f2 \ | while read it do echo $it luna-send -n 1 "palm://com.palm.applicationManager/close" "{\"processId\":\"$it\"}" done if [ ! -d $mdata ] then mkdir $mdata fi #move email to media and create link echo "Do not close Terminal during moves." echo "Moves could take several minutes." echo "Moving/linking email. " cp -rp $vdata/emails $mdata 2>&1 >/tmp/cpemail.out if [ -s /tmp/cpemail.out ] then echo "Copying email failed. Leaving email in place." cleanexit 52 fi #mv $vdata/emails $vdata/emails.$$ rm -r $vdata/emails ln -s $mdata/emails $vdata/emails #move attachments to media and create link echo "Moving/linking attachments..." cp -rp $vdata/attachments $mdata 2>&1 >/tmp/cpemail.out if [ -s /tmp/cpemail.out ] then echo "Copying attachments failed. Leaving attachments in place." cleanexit 53 fi #mv $vdata/attachments $vdata/attachments.$$ rm -r $vdata/attachments ln -s $mdata/attachments $vdata/attachments #starup email process echo "Starting up email..." luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.email\"} >/dev/null 2>&1 echo echo "SUCCESSFUL: Confirm you can access your email." echo echo "NOTE: First time you run email," echo "it may ask if you want to add " echo "accounts. Press Done." } #end of link email function #-------------------------------------------------------------------------# # function: unlinkemail - move email and attachments to /media #-------------------------------------------------------------------------# unlinkemail() { vdata=/var/luna/data mdata=/media/internal/.data if [ ! -d $mdata/emails ] then echo "no email on media" cleanexit 60 fi if [ ! -h $vdata/emails ] then echo "email link does not exist on /var" cleanexit 61 fi echo "Closing email application and background service..." luna-send -n 1 palm://com.palm.applicationManager/running {} 2>&1 \ | tr '{' '\n' | grep com.palm.app.email |cut -d: -f3 |cut -d"\"" -f2 \ | while read it do echo $it luna-send -n 1 "palm://com.palm.applicationManager/close" "{\"processId\":\"$it\"}" done echo "Do not close Terminal during restore." echo "Restore could take several minutes." echo "Restoring email to /var..." # rm the email link rm $vdata/emails # cp email from media to var cp -rp $mdata/emails $vdata 2>&1 >/tmp/cpemail.out if [ -s /tmp/cpemail.out ] then echo "copying email back to /var failed." cleanexit 62 fi rm -r $mdata/emails echo "Restoring attachments to /var..." # rm the attachment link rm $vdata/attachments # cp attachments from media to var cp -rp $mdata/attachments $vdata 2>&1 >/tmp/cpemail.out if [ -s /tmp/cpemail.out ] then echo "copying attachments back to /var failed." cleanexit 63 fi rm -r $mdata/attachments #starup email process echo "Starting up email..." luna-send -n 1 palm://com.palm.applicationManager/launch {\"id\":\"com.palm.app.email\"} >/dev/null 2>&1 echo echo "SUCCESSFUL: Confirm you can access your email." } #end of unlinkemail function #-------------------------------------------------------------------------# # function: search - search for partial app names #-------------------------------------------------------------------------# search() { echo for i in `ls -dt $VAR/*${APP}* $MEDIA/*${APP}* |sort ` do export TITLE="" if [ -f $i/appinfo.json ] then TITLE=`grep title $i/appinfo.json |cut -d: -f2 |cut -d\" -f2` fi echo "Found...." echo $TITLE APP=`basename $i` echo $APP echo if [ -h $VAR/$APP ] then echo "App is currently linked to media." else if [ -d $MEDIA/$APP ] then echo "App is on media drive but has no link." else echo "App is in original location, not linked." fi fi echo -e "\nWould you like to link/unlink/clean/skip this app? [l/u/c/S/q]: \c" read answer case $answer in l) mvapp link $APP;; u) mvapp unlink $APP;; c) mvapp clean $APP;; q) cleanexit 0;; esac echo -e "\n\n---------------------\n" done echo } #end of search function #-------------------------------------------------------------------------# # function: removelinks - remove links from var app dir #-------------------------------------------------------------------------# removelinks() { echo "This will remove all links from /var" echo -e "Are you sure you want to continue? [y/N]:\c" read answer case $answer in [yY]*) continue;; *) cleanexit 0;; esac cd $VAR count=1 ls |while read app do if [ -h $app ] then echo "$count - $app has a link" count=`expr $count + 1` fi done } #-------------------------------------------------------------------------# # function: post135 - move apps to /media/cryptofs #-------------------------------------------------------------------------# post135() { echo "This will copy all linked apps" echo "to the new app location." echo echo "Large applications may take up" echo "to a minute or so each to copy." echo echo "Do not close the Terminal app." echo if [ ! -d /media/cryptofs/apps/usr/palm/applications ] then echo "/media/cryptofs does not exist" cleanexit 70 fi if [ ! -d /media/internal/.apps ] then echo "media/internal/.apps does not exist" cleanexit 71 fi cd /media/internal/.apps numapps=`ls |wc -l` echo "Copying $numapps linked" echo "applications to new app home..." error=0 count=$numapps ls |while read app do echo "$count - $app" cp -rp $app /media/cryptofs/apps/usr/palm/applications if [ $? -ne 0 ] then echo "Copy failed. Check PreCentral thread." export error=`expr $error +1` fi count=`expr $count - 1` done echo if [ $error != 0 ] then echo "There were $error copy error(s)." echo "Ask on PreCentral mvapp thread." cleanexit 1 fi echo "Copy complete." echo "Check applications." echo "If issues, see PreCentral mvapp thread." removelinks } #-------------------------------------------------------------------------# # function: backup - perform tar backups #-------------------------------------------------------------------------# backup() { echo "Performing backups of all apps..." cd /var/usr/palm/applications tar cvzf /media/internal/varappbackups.tgz . if [ -d /media/internal/.apps] then cd /media/internal/.apps tar cvzf /media/internal/mediaappbackups.tgz . fi if [ -d /media/internal/.data ] then echo "Backing up email and attachments." cd /media/intenral/.data tar cvzf /media/internal/mediaemail.tgz . fi echo "You may now perform the webOS update." } #-------------------------------------------------------------------------# # function: checkfd - check if fair dinkum is installed #-------------------------------------------------------------------------# checkfd() { if [ -f /usr/local/bin/ipkg ] then echo "Fair Dinkum is installed and enabled." else echo "Fair Dinkum is NOT installed or enabled." fi ipkg -o /var list_installed |grep ipkgservice ipkg -o /var list_installed |grep preware } #-------------------------------------------------------------------------# # function: install latest development version #-------------------------------------------------------------------------# installdev() { echo "Installing latest development version." echo "Use \"ma\" instead of \"mvapp\"." cd /tmp wget http://gitorious.org/webos-internals/mvapp/blobs/raw/master/mvapp chmod 755 mvapp mv mvapp /usr/local/bin/ma echo "Done. Type... ma" } #end of installdev function #-------------------------------------------------------------------------# # function: updatepreware - update to latest version of preware #-------------------------------------------------------------------------# updatepreware() { cd /tmp rm prew* rm org.webos* wget http://gitorious.org/webos-internals/bootstrap/blobs/raw/master/preware-bootstrap.sh #Alternatively, you can use this tiny URL: http://bit.ly/dDEMO sh preware-bootstrap.sh echo echo "PreWare update complete..." } #-------------------------------------------------------------------------# # function: updateterminal - update to latest version of terminal #-------------------------------------------------------------------------# updateterminal() { cd /tmp ipkg -o /var update ipkg -o /var install org.webosinternals.termplugin ipkg -o /var install org.webosinternals.terminal } #-------------------------------------------------------------------------# # function: startup - startup items #-------------------------------------------------------------------------# startup() { clear echo echo "mvapp version: $VERSION" mount -o remount,rw / #create shortcut 'm' if [ ! -h /usr/local/bin/m ] then echo echo "Created shortcut to mvapp." echo "Can now use just 'm' to run 'mvapp'." echo ln -s /usr/local/bin/mvapp /usr/local/bin/m fi df |grep /media/internal 2>&1 >/dev/null if [ $? != 0 ] then echo "USB drive is mounted to computer. You must unmount from USB to use mvapp." code=100 cleanexit $code fi } # end of startup function #-------------------------------------------------------------------------# # commander - command handler via command line or menu #-------------------------------------------------------------------------# commander() { COMMAND=$1 case $COMMAND in c|"clean") cleanapp ;; ls|"list") listapps ;; lm|"listmoved") listmoved ;; ln|"link") linkapp ;; ul|"unlink") unlinkapp ;; bm|"bulkmv") bulkmv ;; ra|"restoreall") restoreall ;; "ftr") # force tar restore BACKUP=1 unlinkapp ;; "rtb") # remove all tar backups removetarbackups ;; i|"info") info ;; d|"doctor"|"diag") diag |tee /media/internal/diagreport.rtf ;; "le"|"linkemail") linkemail ;; "ue"|"unlinkemail") unlinkemail ;; "s"|"search") search ;; "cl"|"checklinks") checklinks ;; "dev") installdev ;; "cfd"|"checkfd") checkfd ;; "upw"|"updatepreware") updatepreware ;; "upt"|"updateterminal") updateterminal ;; "backup") backup ;; "post135") post135 ;; "rl") removelinks ;; "q") cleanexit 0 ;; esac } #-------------------------------------------------------------------------# # mainmenu - the main menu #-------------------------------------------------------------------------# mainmenu () { while true do clear echo "xorg tools - Power Tools for Power Users" echo "xt - $VERSION" cat << EOF d) diagnostics ma) mvapp functions db) debian tools op) optware tools q) quit cp) command prompt EOF echo -e "Enter Selection: \c" read answer commander $answer echo -e "Press ENTER to continue: \c" read junk done cleanexit 0 } #-------------------------------------------------------------------------# # main - begins here #-------------------------------------------------------------------------# startup if [ $COMMAND ] then commander $COMMAND else mainmenu fi cleanexit $code