Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- OTA=com.lab126.blanket.ota
- LOG=/mnt/us/Komic_update_log.txt
- LOCALSTORAGE=/mnt/us/extensions/komic/bin/resource/LocalStorage/file__0.localstorage
- GALLERY="/mnt/us/documents/Komic"
- OLDGALLERY="/mnt/us/documents/Gallery"
- KOMIC="/mnt/us/extensions/komic"
- UPSTART="/etc/upstart/komic_event_handler.conf"
- progress()
- {
- lipc-send-event $OTA otaSplashProgress -i $1
- local x=48
- local y=11
- eips 0 $y " ";
- eips $((($x - $(expr length "$2")) / 2)) $y "$2"
- sleep 3
- }
- fail()
- {
- lipc-send-event $OTA otaSplashError -s "${1}"
- sleep 10
- exit 1;
- }
- progress 25 "Checking if Komic is installed"
- varkomic=$(sqlite3 /var/local/appreg.db "select handlerId from handlerIds where handlerId='com.silver18.komic001'")
- varmemory=$(sqlite3 /var/local/appreg.db "select handlerId from properties where handlerId='com.silver18.komic001' and name='memUnloadLevel'")
- mesquite=$(sqlite3 /var/local/appreg.db "select value from properties where handlerId='com.silver18.komic001' and name='command'" | grep mesquite)
- varbaseus=$(sqlite3 /var/local/appreg.db "select value from properties where handlerId='com.silver18.komic001' and name='command'" | grep base)
- if [[ -n "$varkomic" ]]
- then
- echo "Komic is already installed" >> $LOG
- komicinstalled=1
- if [[ -z "$mesquite" ]]
- then
- echo "Komic is not yet updated to mesquite" >> $LOG
- sqlite3 /var/local/appreg.db "delete from properties where handlerId='com.silver18.komic001' and name='command'"
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','command','/usr/bin/mesquite -l com.silver18.komic001 -c /mnt/us/extensions/komic/bin/')"
- else
- echo "Komic is already updated to mesquite" >> $LOG
- if [[ ! -z "$varbaseus" ]]
- then
- echo "Moving installation folder to /mnt/us" >> $LOG
- sqlite3 /var/local/appreg.db "delete from properties where handlerId='com.silver18.komic001' and name='command'"
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','command','/usr/bin/mesquite -l com.silver18.komic001 -c /mnt/us/extensions/komic/bin/')"
- fi
- fi
- if [ -d "$KOMIC" ]
- then
- echo "Komic folder present" >> $LOG
- komicpresent=1
- else
- echo "Komic folder not present" >> $LOG
- fi
- else
- echo "Komic is not yet installed" >> $LOG
- sqlite3 /var/local/appreg.db "INSERT INTO handlerIds VALUES ('com.silver18.komic001')"
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','command','/usr/bin/mesquite -l com.silver18.komic001 -c /mnt/us/extensions/komic/bin/')"
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','unloadPolicy','unloadOnPause')"
- fi
- if [[ -n "$varmemory" ]]
- then
- echo "Bigger memory space already present" >> $LOG
- else
- echo "Bigger memory space not present" >> $LOG
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','memUnloadLevel','150000')"
- sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('com.silver18.komic001','memWarnLevel','71680')"
- fi
- progress 50 "Copying Komic"
- echo "--------------------------------" >> $LOG
- if [[ -n "$komicinstalled" ]]
- then
- echo "Updating Komic and managing file__0.localstorage" >> $LOG
- if [[ -n "$komicpresent" ]]
- then
- echo "Removing old Komic and unzipping new Komic" >> $LOG
- rm -rf $KOMIC || fail "Unable to delete Komic folder"
- unzip komic.zip -d /mnt/us/extensions/ || fail "Unable to unzip Komic"
- else
- echo "Unzipping new Komic" >> $LOG
- unzip komic.zip -d /mnt/us/extensions/ || fail "Unable to unzip Komic"
- fi
- if [[ -n "$localstoragepresent" ]]
- then
- echo "Restoring old file__0.localstorage" >> $LOG
- mv /mnt/us/file__0.localstorage $LOCALSTORAGE || fail "Unable to replace old file__0.localstorage"
- rm -f /mnt/us/file__0.localstorage || fail "Unable to delete old file__0.localstorage"
- else
- echo "Placing new file__0.localstorage" >> $LOG
- mv file__0.localstorage $LOCALSTORAGE || fail "Unable to place new file__0.localstorage"
- fi
- echo "Updating upstart script" >> $LOG
- rm -rf $UPSTART || fail "Unable to delete upstart script"
- mv komic_event_handler.conf $UPSTART || fail "Unable to place upstart script"
- sqlite3 /mnt/us/extensions/komic/bin/resource/LocalStorage/file__0.localstorage "INSERT INTO ItemTable (key, value) VALUES ('komicStatus', 'updated')"
- else
- echo "Installing Komic, placing plain file__0.localstorage and upstart script" >> $LOG
- unzip -o komic.zip -d /mnt/us/extensions/ || fail "Unable to unzip Komic"
- mv file__0.localstorage $LOCALSTORAGE || fail "Unable to place new file__0.localstorage"
- mv komic_event_handler.conf $UPSTART || fail "Unable to place upstart script"
- sqlite3 /mnt/us/extensions/komic/bin/resource/LocalStorage/file__0.localstorage "INSERT INTO ItemTable (key, value) VALUES ('komicStatus', 'firstRun')"
- fi
- progress 75 "Creating Komic documents folder"
- if [ -d "$OLDGALLERY" ]
- then
- echo "Old Komic documents folder present, renaming it" >> $LOG
- mv $OLDGALLERY $GALLERY
- GALLERY="/mnt/us/documents/Komic"
- fi
- if [ -d "$GALLERY" ]
- then
- echo "Komic documents folder present" >> $LOG
- unzip -o =README=.zip -d $GALLERY/ || fail "Unable to unzip README"
- else
- echo "Creating Komic documents folder" >> $LOG
- mkdir -p $GALLERY
- unzip -o =README=.zip -d $GALLERY/ || fail "Unable to unzip README"
- fi
- progress 100 "Installation complete."
- echo "Installation complete" >> $LOG
- mv $LOG /mnt/us/extensions/komic/bin/resource/Logs/Komic_update_log.txt
Add Comment
Please, Sign In to add comment