Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[SCRIPT] Helium server PC download - separation

OP charles1510

18th July 2014, 02:11 PM   |  #1  
OP Member
Thanks Meter: 10
 
37 posts
Join Date:Joined: Jul 2012
More
This is simple linux script I've made to separate all apps from one big zip file made by Helium sever -> PC download. Helium wiki says to don't try to do anything with this file, but I didn't want to restore all that stuff that I've backuped before bootloader unlock on my nexus 4. I'm sure it can be writed better, but it's working

Just place script file and unziped backup folder (must be named "backup") in one directory. After execution of the script everything should be ready to copying to carbon folder on your sd card/internal memory and restoring like after normal backup.

Tested on Ubuntu 14.04.
I'm not responsible for data loss or any other problem. Use at your own risk.
Constructive criticism welcome.
Code:
#!/bin/bash

DIRECTORY='./backup'

if [ -f $DIRECTORY/backup.json ]; then

	cp $DIRECTORY/backup.json $DIRECTORY/temp.json
	sed -e "s/{\"packages\"://g" $DIRECTORY/temp.json > $DIRECTORY/temp2.json
	tr '[]' ' ' < $DIRECTORY/temp2.json | tee $DIRECTORY/temp.json
	tr '}' '\n' < $DIRECTORY/temp.json | tee $DIRECTORY/temp2.json
	sed -e "s/,{/{/g" $DIRECTORY/temp2.json > $DIRECTORY/temp.json
	sed -e 's/^[ \t]*//' $DIRECTORY/temp.json > $DIRECTORY/temp2.json
	sed '/^$/d' $DIRECTORY/temp2.json > $DIRECTORY/temp.json
	sed 's/\([^|]\)$/\1}/' $DIRECTORY/temp.json > $DIRECTORY/temp_last.json
fi;

count=`ls -1 $DIRECTORY/*.ab 2>/dev/null | wc -l`
if [ $count != 0 ]; then
	
	for i in $DIRECTORY/*.ab ; do

		AB=$(basename $i)
		mkdir -p $DIRECTORY/${AB%.*}
		mv -i $DIRECTORY/$AB $DIRECTORY/${AB%.*}/
		if [ -f $DIRECTORY/${AB%.*}.png ]; then 
			mv -i $DIRECTORY/${AB%.*}.png $DIRECTORY/${AB%.*}/._${AB%.*}.png
		fi;
		if [ ! -f $DIRECTORY/${AB%.*}/${AB%.*}.json ];then
		touch $DIRECTORY/${AB%.*}/${AB%.*}.json
		fi;

		while read p; do

   			if [[ "$p" =~ "${AB%.*}" ]]; then
				echo "$p" > $DIRECTORY/${AB%.*}/${AB%.*}.json
			fi;
	
		done <$DIRECTORY/temp_last.json

	done;
fi;
rm $DIRECTORY/temp.json
rm $DIRECTORY/temp2.json
rm $DIRECTORY/temp_last.json
exit;
Post Reply Subscribe to Thread

Tags
backup, helium, sever
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes