Hello!
As some of you know, pvyParts and I have been working on a custom stock-based ROM, T.E.A.M., which was initially released as a themed ROM to offer transparency and replace the Theme Chooser that we haven't been able to port properly, giving endless options on custom backgrounds (since your wallpaper is the system background).
As the ROM evolved and custom kernels became available, I wanted to tweak it using init.d scripts.
As all good developers here do, I searched the Android Software and Hacking General section,
browsed other devices' forums and came up with some tweaks that were really good -on paper.
To my disappointment, most of these did not work.
And I am not saying this because I didn't "feel" a difference
or because I could not spread my X10's smoothness on a cracker.
There is actually a way to test if a script runs with no errors, a.k.a actually works.
Without further adieu, here is how:
1. Place the script you want to test (let's say test.sh)
in /system and give it all permissions,
either with Root Explorer or via adb:
Code:
adb shell chmod 777 /system/test.sh
NOTE: Sometimes scripts don't have an extension (sh).
It's OK, you can still test it with this method.
2. Now install an app like Script Manager and run the script.
Or, do it via adb:
Code:
adb shell sh /system/test.sh
3. Now there are 3 things you might face:
- If you get an error in return, it means the script doesn't work,
so no point in placing it in init.d and running it at every boot, right?
- Some scripts include debug, so you may get a message saying Done, Success, or whatever, which means you are good to go.
- You might not get any output at all, but still that means the script ran fine.
For the latter two cases, you can safely run the script at boot by placing it in init.d folder.
The reason this thread is in development, is because I feel that since the X10 is getting old and many developers have left,
(but luckily new ones still appear, which is plainly AWESOME ), quality of ROMs is very important.
We have fewer choices, so let's make them worthwhile!
Doing it right now.
BTW- I'm first! Again!
Prodigy said:
Doing it right now.
BTW- I'm first! Again!
Click to expand...
Click to collapse
Let us know how it went!
its good to see dev sharing their dev knowledge and skills. this will make more dev for x10. more dev, more improvement we can do on our phone. Thanks My Immortal / iridaki. you're awsome
Thank
cause script stress me well
Now i can see if work or not
X10-tripmiui,iris,00
so if my rom has a init.d folder, does it means it supports or run script (on init.d folder) at boot? is there a way to check if my rom has init.d support??
draiyan said:
so if my rom has a init.d folder, does it means it supports or run script (on init.d folder) at boot? is there a way to check if my rom has init.d support??
Click to expand...
Click to collapse
Yes, support at boot.
To my less knowledge, just look if there is a init. d folder in system/etc/
When you make an own rom check if the kernel you wanna use,has init. d support.
Hope I didn't talk crap and this is right
Sent from my X10i using Tapatalk
but im really confuse here, i found this script,
Code:
/etc/init.d/03sdcardspeedfix
at some line of this script, it reads;
READ_AHEAD_KB="2048"
Click to expand...
Click to collapse
i know some c++ programming, and from what i know the value 2048 is assigned to read_ahead_kb, so i assume its the same in android. BUT, after reboot, i jumped to
Code:
/sys/devices/virtual/bdi/179:0/read_ahead_kb
to found out that its still 128, then i started thinking that the script didnt run, but the dev says the rom is init.d supported.
is there a way to test if init.d is reallty working? like at terminal emulator?
sure man !
you have two way for run tweak
in install-recovery.sh
or ini.d folder
but for be sure
create a file in system/etc
name it "install-recovery.sh"
copy this in and give all permission.
#!/system/bin/sh
#Mount Points
busybox mount -o remount,rw,noatime,nodiratime / -t rootfs
busybox mount -o remount,rw,noatime,nodiratime /sys -t sysfs
busybox mount -o remount,rw,noatime,nodiratime /system
busybox mount -o remount,rw,noatime,nodiratime /data
busybox mount -o remount,rw,noatime,nodiratime /cache
#init.d support
busybox run-parts /system/etc/init.d
run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1
now put your tweak in ini.d folder and reboot
be carefull !
if you have zipalign tweak
this tweak kill all tweak at boot because it unmount partition
and make it r/o instead of r/w
well,
tweak cannot access system or data like VM or sdcard tweak like read-ahead kb 2048.
now go in data/local/tmp
and check the log
to see if all it ok
but if ini.d does not run,
you could
insert tweak in install-recovery.sh
like this
#!/system/bin/sh
#give system permissions
busybox mount -o remount,rw /system
chmod 777 /system
#init.d support
busybox run-parts /system/etc/init.d
run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1
#uncap fps
mount -t debugfs debugfs /sys/kernel/debug
echo '0' > /sys/kernel/debug/msm_fb/0/vsync_enable
#th config
echo '0' > /sys/kernel/debug/msm_fb/0/hw_vsync_mode
echo '0' > /sys/kernel/debug/msm_fb/0/sw_refreshing_enable
echo '2' > /sys/kernel/debug/msm_fb/0/ref_cnt
echo '8' > /sys/kernel/debug/msm_fb/0/backbuff
echo '6000' > /sys/kernel/debug/msm_fb/0/refx100
#echo '1' > /sys/power/wake_lock *dangerous
#echo '1' > /sys/kernel/debug/kgsl/cache_enable *dangerous
echo '8192' > /sys/block/mmcblk0/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk0/queue/max_sectors_kb
echo '8192' > /sys/block/mmcblk1/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk1/queue/max_sectors_kb
#rm -f -rf /data/idd
#rm -f -rf /data/semc-checkin
umount /sys/kernel/debug
echo 0 > /sys/kernel/logger/log_main/enable
echo 0 > /sys/kernel/logger/log_event/enable
echo 0 > /sys/kernel/logger/log_radio/enable
echo 1024 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo 1024 > /sys/devices/virtual/bdi/default/read_ahead_kb
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 30 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load
# Delay the Media Scanner to help boot times
pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
sleep 80 && pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
#I/O Scheduler Tweaks
mount -o remount,noatime / -t rootfs
mount -o remount,noatime /dev -t devpts
mount -o remount,noatime /proc -t proc
mount -o remount,noatime /sys -t sysfs
mount -o remount,noatime /mnt/asec -t tmpfs
mount -o remount,noatime /system -t yaffs2
mount -o remount,noatime /data -t yaffs2
mount -o remount,noatime /cache -t yaffs2
mount -o remount,noatime /mnt/sdcard -t vfat
mount -o remount,noatime /mnt/secure/asec -t vfat
mount -o remount,noatime /mnt/sdcard/.android_secure -t tmpfs
i=`ls -d /sys/block/mtdblock3/queue/scheduler`;
STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
TFSR=`ls -d /sys/block/tfsr*`;
DM=`ls -d /sys/block/dm*`;
MTD=`ls -d /sys/block/mtd*`;
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;
SYSDEV=`mount | grep '/system' | cut -d '/' -f 4`;
IO_SCHEDULER=`echo "noop" > /sys/block/mtdblock3/queue/scheduler/queue/rotational`;
for i in `busybox ls -1 /sys/block/mtdblock*`; do
echo "deadline" > $i/queue/scheduler;
done;
for k in $(busybox mount | cut -d " " -f3)
do
sync;
busybox mount -o remount,noatime,nodiratime $k;
done;
echo "deadline" > /sys/block/mmcblk0/queue/scheduler
echo "deadline" > /sys/block/dm-0/queue/scheduler
echo "deadline" > /sys/block/dm-1/queue/scheduler
for i in $MMC $MTD $LOOP; do
echo 0 > $i/queue/rotational;
done;
for i in $MMC $MTD; do
echo "deadline" > $i/queue/scheduler;
done;
for i in $MMC; do
echo 4096 > $i/queue/read_ahead_kb;
echo 0 > $i/queue/rotational;
echo 1 > $i/queue/iosched/low_latency;
echo 16 > $i/queue/iosched/quantum;
echo 8192 > $i/queue/nr_requests;
echo 1000000000 > $i/queue/iosched/back_seek_max;
for i in $STL $BML $MMC;
do
echo $IO_SCHEDULER > $i/queue/scheduler;
case $IO_SCHEDULER in
"deadline")
echo 1 > $i/queue/iosched/fifo_batch;;
"cfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"bfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"noop")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
esac;
done;
#Dalvik Cache
if [ ! -d /cache/dalvik-cache ]
then
busybox rm -rf /cache/dalvik-cache /data/dalvik-cache
mkdir /cache/dalvik-cache /data/dalvik-cache
fi
#Dalvik Cache
busybox chown 1000:1000 /cache/dalvik-cache
busybox chmod 0771 /cache/dalvik-cache
#bind mount dalvik-cache so we can still boot without the sdcard
busybox mount -o bind /cache/dalvik-cache /data/dalvik-cache
busybox chown 1000:1000 /data/dalvik-cache
busybox chmod 0771 /data/dalvik-cache
#Remove
busybox rm -rf /data/tombstones/*
#Zipalign
mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
cd /system/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
cd /data/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
#Phone Lag Tweaks
MAX_PHONE() {
pidphone=`pidof com.android.phone`;
if [ $pidphone ]; then
echo -17 > /proc/$pidphone/oom_adj;
renice -20 $pidphone;
exit;
else
sleep 5;
MAX_PHONE;
fi;
}
(while [ 1 ]; do
sleep 10;
MAX_PHONE;
done &);
if [ $ENABLE_MAXPHONE -eq 1 ];
then
PROC_ADJUST "com.android.phone" "-20" &
fi;
for j in $DM $MTD $LOOP $RAM; do
echo 0 > $j/queue/rotational;
done;
strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time
#CPUTweak's Variables
last_source="unknown";
charging_source=$(cat /sys/class/power_supply/battery/charging_source);
capacity=$(cat /sys/class/power_supply/battery/capacity);
if [ $ENABLE_SWITCH -eq 1 ];
then
ALLFREQS=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`;
(while [ 1 ];
do
cat /sys/power/wait_for_fb_wake;
AWAKE_MODE;
cat /sys/power/wait_for_fb_sleep;
SLEEP_MODE;
done &)
fi;
BAT_SLEEP_GOV="powersave"
USB_SLEEP_GOV="powersave"
POW_SLEEP_GOV="powersave"
#CPUTweak's Functions
Battery() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $BAT_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 100 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $BAT_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3
}
USB() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $USB_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $USB_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}
Power() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $POW_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $POW_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}
#
# Loopy Smoothness Tweak for X10
#
for n in 1 2
do
USER_LAUNCHER="com.sonyericsson.home" # Change this to your launcher app
NUMBER_OF_CHECKS=35 # Total number of rechecks before ending 1st loop
SLEEP_TIME=3 # Number of seconds between rechecking processes
PROCESSES_TOTAL=4 # Must be edited to match the number of processes to be checked
DEBUG_ECHO=0 # Debug on/off
CHECK_COUNT=0 # Don't edit
P_CHECK=0 # Don't edit
CHECK_OK=0 # Unused
PROCESS_1=0; PROCESS_2=0; PROCESS_3=0; PROCESS_4=0; PROCESS_5=0; PROCESS_6=0;
PROCESS_7=0; PROCESS_8=0; PROCESS_9=0; PROCESS_10=0; PROCESS_11=0; PROCESS_12=0;
PROCESS_13=0; PROCESS_14=0; PROCESS_15=0; PROCESS_16=0; PROCESS_17=0; PROCESS_18=0;
PROCESS_19=0; PROCESS_20=0; PROCESS_21=0; PROCESS_22=0; PROCESS_23=0; PROCESS_24=0;
if [ $n -eq "1" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo ""
echo "LST Debug: $(date)"
echo "LST Debug: Initiate"
fi;
# Pause and then loop until kswapd0 is found, which should be instant anyway
sleep 1
SWAP_SLEEP_TIME=3; SWAP_NUMBER_OF_CHECKS=30; SWAP_CHECK_COUNT=0; SWAP_CHECK_COUNT_OK=0; while [ $SWAP_CHECK_COUNT -lt $SWAP_NUMBER_OF_CHECKS ]; do if [ `pidof kswapd0` ]; then renice 19 `pidof kswapd0`; SWAP_CHECK_COUNT=$SWAP_NUMBER_OF_CHECKS; SWAP_CHECK_COUNT_OK=1; else sleep $SWAP_SLEEP_TIME; fi; SWAP_CHECK_COUNT=`expr $SWAP_CHECK_COUNT + 1`; done; if [ $SWAP_CHECK_COUNT_OK -lt 1 ]; then echo "LST Debug: 'kswapd0' expired after `expr $SWAP_CHECK_COUNT \* $SWAP_SLEEP_TIME` seconds"; fi;
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)";
echo "LST Debug: kswapd0 found";
fi;
fi;
# Check briefly one more time
if [ $n -eq "2" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: 2nd loop"
fi;
NUMBER_OF_CHECKS=6 # Editing not recommended
SLEEP_TIME=5 # Editing not recommended
fi;
while [ $CHECK_COUNT -lt $NUMBER_OF_CHECKS ];
do
# Resident system apps
if [ $PROCESS_1 -eq "0" ]; then PNAME="com.android.phone"; NICELEVEL=-20; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_1=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_2 -eq "0" ]; then PNAME="$USER_LAUNCHER"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_2=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_3 -eq "0" ]; then PNAME="com.sonyericsson.conversations"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_3=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_4 -eq "0" ]; then PNAME="com.sonyericsson.music"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_4=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
# If all processes are done, loop can finish early
if [ $P_CHECK -ge $PROCESSES_TOTAL ]; then CHECK_COUNT=$NUMBER_OF_CHECKS; else sleep $SLEEP_TIME; fi;
CHECK_COUNT=`expr $CHECK_COUNT + 1`;
done
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)"
if [ $PROCESS_1 -eq "0" ]; then echo "LST Debug: PROCESS_1 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_2 -eq "0" ]; then echo "LST Debug: PROCESS_2 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
echo "LST Debug: Checking complete"
fi;
done
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: Done"
echo ""
fi;
this is an exemple!
but you could use it !
it improve speed of your phone hahaha !!!
bip
i tried install-recovery but i got no file at local/temp??? there should be a log file in it rigth?
Another tip - add this command to the top of the script:
Code:
set -xv
This will give full command echoing when you run the script so you can see where the error is. The android shell doesn't report lines accurately, I think it's because it doesn't count comments as lines. It will also make easily visible syntax errors that dont error but cause a conditional to report incorrect, e.g. if you accidentally use == instead of = or forget double-quotes when comparing strings.
Hi,
i tried to translate a MIUI for Galaxy Nexus rom into french (can also be an other language)
i wrote an unix script to automate the process.
What i do is quite simple:
i get a specific MIUI V4 version for my device and the same translated version for the nexus S (because the nexus S has a french version)
i decompile each apk from the french rom, an put the french files into to decompile galaxy nexus directories
i recompile each apk
and i copy the compiled resources into the origin galaxy nexus apks
and i build the new ROM
but i get a bootloop any ideas ?
here is my script
if there are any part of this script that isn't clear, i could try to explain them.
of course this script could also be used on other device or other translation with some changes.
Thanks in advance .
Code:
#!/bin/bash
# MIUI-FRENCH TRANSLATE SCRIPT FOR GNEX V1.0 By Alain57
BASE_DIR=$PWD
FRENCH_DIR=$BASE_DIR/french_rom
ORIGINAL_DIR=$BASE_DIR/original_rom
OUTPUT_ROM_DIR=$BASE_DIR/output_rom
OUT_DIR=$BASE_DIR/out
WORK_DIR=$BASE_DIR/workdir
ORIGIN_APK_DIR=$WORK_DIR/origin
TRANSLATION_DIR=$WORK_DIR/translation
DECODED_APK_DIR=$WORK_DIR/decoded
LOG_FILE=$BASE_DIR/log.txt
TEMP_DIR=$BASE_DIR/temp
# clean the log file and create the missing directories if they don't exist (for exemple on first run)
function cleanLog(){
rm -fr $LOG_FILE
ARRAY_DIR=( $FRENCH_DIR $ORIGINAL_DIR $OUTPUT_ROM_DIR $OUT_DIR $WORK_DIR $ORIGIN_APK_DIR $TRANSLATION_DIR $DECODED_APK_DIR $TEMP_DIR )
echo "creating missing directoriesi if needed"
for DIR in ${ARRAY_DIR[@]}; do
if [ ! -d $DIR ]; then
mkdir $DIR
fi
done
}
# configure apktool to use framework-res and framework-miui-res
function setFramework(){
cd $FRENCH_DIR
echo "<- apktool if system/framework/framework-res.apk ->" >> $LOG_FILE
apktool if framework-res.apk >> $LOG_FILE 2>&1
echo "<- apktool if system/framework/framework-miui-res.apk ->" >> $LOG_FILE
apktool if framework-miui-res.apk >> $LOG_FILE 2>&1
}
#decompile all apk file from the english Gnex miui rom
function decompileOriginFiles(){
cd $ORIGINAL_DIR
COUNT_ORIGINAL_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_ORIGINAL_ZIP" -eq "1" ]; then
mv *.zip en.zip
echo "unzip the original rom"
unzip -q -o en.zip
echo "copy the apks to the origin dir"
cp -a system/framework/*.apk $ORIGIN_APK_DIR
cp -a system/app/*apk $ORIGIN_APK_DIR
cd $ORIGIN_APK_DIR
for F in *.apk; do
echo "decompiling origianl file $F ..." | tee -a $LOG_FILE
apktool d $F $DECODED_APK_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there need to be ONE zip file in the original directory"
exit
fi
}
# decompile all apk files from the french Nexus S ROM
function decompileTranslatedFiles(){
cd $FRENCH_DIR
COUNT_FRENCH_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_FRENCH_ZIP" -eq "1" ]; then
mv *.zip fr.zip
echo "unzip the french rom"
unzip -q -o fr.zip
setFramework
echo "copy the apks to the working dir"
cp -a system/framework/*.apk $WORK_DIR
cp -a system/app/*.apk $WORK_DIR
cd $WORK_DIR
for F in *.apk; do
echo "decompiling french file $F ..." | tee -a $LOG_FILE
apktool d $F $TRANSLATION_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there neeed to be ONE zip file in the french directory"
exit
fi
}
# Delete the given directory, because it is not needed
function deleteDirectoryWithoutTranslation(){
echo " ---> directory useless, removed"
cd $TRANSLATION_APK_DIR
rm -fr $1
}
# delete all useless data from the french apks
function cleanTranslatedFiles(){
cd $TRANSLATION_DIR
for d in *; do
echo "cleaning the directory $d"
cd $TRANSLATION_DIR/$d
if [ -d "res" ]; then
ls . | grep -v res | xargs -o rm -fr
cd "res"
CONTAINS_FRENCH_TRANSLATION=`ls .| grep '\-fr' | wc -l`
if [ "$CONTAINS_FRENCH_TRANSLATION" -eq "0" ]; then
deleteDirectoryWithoutTranslation $d
else
echo "---> transltation here, clean it"
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
fi
else
echo "no res directory"
deleteDirectoryWithoutTranslation $d
fi
if [ ! -f $ORIGIN_APK_DIR/$d.apk ];then
echo "directory not in original rom $d"
deleteDirectoryWithoutTranslation $d
fi
done
}
# merge the decoded translation in the decoded english files
function mergeTranslations(){
cd $DECODED_APK_DIR
mv $TRANSLATION_DIR/* .
cd $WORK_DIR
rm -f *.apk
}
# compile new apks including french files
function compileApk(){
cd $ORIGIN_APK_DIR
for f in *.apk; do
echo "compiling $f"
echo "apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f"
apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f >> $LOG_FILE 2>&1
done
}
# delete apk in work directory and put the original apks there
function deleteWorkFileAndCopyOriginalApk(){
cd $WORK_DIR
rm -f *.apk
cp -a $ORIGIN_APK_DIR/*.apk .
}
# put the compiled modified files in the original apk files
function finalMerge(){
cd $DECODED_APK_DIR
for F in *.apk; do
echo "doing final build $F"
cd $TEMP_DIR
rm -fr *
unzip -q $DECODED_DIR/$F
ls . | grep -v 'res\|classes.dex\|resources.arsc\|\./\|\.\./' | xargs -o rm -fr
if [ -d res ]; then
cd res
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
HAS_FR=`ls . | grep '\-fr' | wc -l`
if [ "$HAS_FR" -eq "0" ]; then
cd ..
rm -fr res
else
cd ..
fi
fi
zip -r $WORK_DIR/$F *
done
}
#replace the english apk files with the new french apk files, change the build.prop value and create an unsigned zip that can be flashed
function createRom(){
cd $OUTPUT_ROM_DIR
mv $ORIGINAL_DIR/system $ORIGINAL_DIR/boot.img $ORIGINAL_DIR/META-INF .
mv $WORK_DIR/*.apk system/app
mv system/app/framework*.apk system/framework
mv system/build.prop build.prop
sed 's/=en/=fr/g' build.prop > build1.prop
rm -f build.prop
sed 's/=US/=FR/g' build1.prop > system/build.prop
rm -f build1.prop
zip -r $BASE_DIR/new_rom.zip *
}
cleanLog
decompileTranslatedFiles
decompileOriginFiles
cleanTranslatedFiles
mergeTranslations
compileApk
deleteWorkFileAndCopyOriginalApk
finalMerge
createRom
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Moving to Q&A
I have two of these devices sitting around and I was wondering how people were repurposing them. I just picked up a Raspberry Pi with the intention of setting up a home automation system. Isn't the Eris also an ARMv6 processor? Could they be used as smart WiIP video security cameras? Is there a Linux distro somewhere? Anyone have any experience?
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
roirraW "edor" ehT said:
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
Click to expand...
Click to collapse
http://www.4shared.com/zip/uiPl7NhN/ubuntu.html Link to Ubuntu.img
to mount you can use this:
linuxboot.sh
#option if you wish to load a different file than the rc_enter just replace the rc_enter.sh with the script file you want to run
# i.e init.sh below this script I will post the initl.ls if you wan to replace the rc_enter.sh
Code:
#!/system/bin/sh
(
# If $BINDS does not exist, then done of the others are set iether.
if [ -z "$BINDS" ]; then
export DIST="debian squeeze"
export FILESYSTEM=/sdcard/ubuntu.img
export MOUNTPOINT=/sdcard/linux
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
export FS=ext3
export busybox="/data/data/com.galoula.LinuxInstall/bin/busybox"
export BINDS="1"
unset TMPDIR
fi
createLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/proc")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
fi
else
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
if $busybox [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
$busybox mkdir -p $MOUNTPOINT 2> /dev/null
if $busybox [ ! -d $MOUNTPOINT ]; then
echo "F: It was not possible to create the missing mount location ($MOUNTPOINT)"
return 0
fi
fi
if $busybox [ -f "$FILESYSTEM" ]
then
# Android places loop devices in /dev/block/ instead of root /dev/
# If there are none in /dev/ we create links between /dev/loopX and /dev/block/loopX so that losetup will work as it should.
if $busybox [ ! -e /dev/block/loop0 ]; then
i=0
while [ $i -le 8 ]
do
$busybox mknod /dev/block/loop$i b 7 $i
let i=1+$i
done
fi
# Locate the current loop device file
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$($busybox losetup -f)
$busybox losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "F: It was not possible to attach the device to a loop device file"
return 0
fi
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Mount the filesystem
$busybox mount -t $FS $loblk $MOUNTPOINT 2> /dev/null
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
# /sdcard/Mon mount/Linux
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
#for i in $BINDS
#do
# # Bind the dirs if they are not already binded
# if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
# # Create any missing dirs in the mountpoint
# if $busybox [ ! -d $MOUNTPOINT/$i ]; then
# $busybox mkdir -p $MOUNTPOINT/$i
# fi
# $busybox mount -o bind $i $MOUNTPOINT$i
# fi
#done
else
echo "F: It was not possible to mount $DIST at the specified location ($MOUNTPOINT)"
return 0
fi
fi
fi
# FIX the "stdin: is not a tty" error in direct hadware case.
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox mount -t devpts devpts $MOUNTPOINT/dev/pts
fi
# For the network.
#sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
# Cleanup tmp folder.
$busybox rm -rf $MOUNTPOINT/tmp/*
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_mount.sh ]; then
# Execute the mount init file, if it exists
echo "I: Executing /etc/init.android/rc_mount.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_mount.sh
fi
echo "I: Entering chroot..."
return 1
}
removeLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts 2> /dev/null
fi
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
else
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo "W: $DIST is already unmounted"
else
echo "I: Unmounting $DIST..."
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_unmount.sh ]; then
echo "I: Executing /etc/init.android/rc_unmount.sh"
# Execute the unmount init script, if it exist.
$busybox chroot $MOUNTPOINT /etc/init.android/rc_unmount.sh
fi
sync
# Make sure that we have an loop device file to use
if $busybox [ -f "$FILESYSTEM" ]
then
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
echo "E: Could not locate the loop device file. $DIST was not unmounted successfully"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts
fi
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
sync && sleep 1
# Unmount the device
$busybox umount $MOUNTPOINT 2> /dev/null && sleep 1
# If the device could not be unmounted
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "E: $DIST could not be unmounted. Trying to kill attached processes..."
# Try to kill all processes holding the device
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill $i 2> /dev/null; echo; done
fuser -k -9 $MOUNTPOINT
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill -9 $i 2> /dev/null; echo; done
# Use umount with the -l option to take care of the rest
$busybox umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
if $busybox [ -f "$FILESYSTEM" ]
then
# Try to detach the device from the loop device file
$busybox losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
else
echo "E: $DIST could not be unmounted successfully"
fi
fi
fi
}
if $busybox [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if $busybox [ $? -eq 1 ]; then
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_enter.sh ]; then
echo "I: Executing /etc/init.android/rc_enter.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_enter.sh
else
echo "I: To run command when enterring Linux create executable file at /etc/init.android/rc_enter.sh"
fi
$busybox chroot $MOUNTPOINT /bin/bash -i
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_leave.sh ]; then
echo "I: Executing /etc/init.android/rc_leave.sh ..."
$busybox chroot $MOUNTPOINT /etc/init.android/rc_leave.sh
else
echo "I: To run command when leaving Linux create executable file at /etc/init.android/rc_leave.sh"
fi
echo "Q: Do you want to unmount the $DIST environment, or leave it as is ? Y will kill all process as required; any other key will leave services running."
read REPLY
if $busybox [ "y$REPLY" = "yy" ] || $busybox [ "y$REPLY" = "yY" ]; then
removeLinuxBoot
fi
fi
fi
)
or you can mount it with this linuxboot.sh:
Code:
# Check Permissions
if [ $(whoami) != root ]; then
echo "This script must be run as root."
exit
fi
# Script Variables
NAME=ubuntu
PATH=$(dirname $0)
# Enviroment Variables
export BIN=/system/bin
export HOME=/root
export MOUNT=/data/local/mnt/$NAME
export PATH=$BIN:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export TERM=linux
export USER=root
# Change Directory
cd $PATH
# Create Mount Point
mkdir -p $MOUNT
# Remount System Read/Write
mount -o remount,rw /system
# Check Loop Block Device
if [ ! -b /dev/block/loop_$NAME ]; then
# Create Loop Block Device
mknod /dev/block/loop_$NAME b 7 255
fi
# Setup Loop Block Device
losetup /dev/block/loop_$NAME $NAME.img
# Mount Loop Block Device To Mount Point
mount -t ext3 /dev/block/loop_$NAME $MOUNT
# Add Mount Points
mount -o bind /dev $MOUNT/dev
mount -o bind /dev/pts $MOUNT/dev/pts
mount -o bind /dev/shm $MOUNT/dev/shm
mount -o bind /sdcard $MOUNT/media
mount -t proc none $MOUNT/proc
mount -t sysfs none $MOUNT/sys
# Set Options
echo "127.0.0.1 localhost" > $MOUNT/etc/hosts
echo "nameserver 8.8.4.4" > $MOUNT/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $MOUNT/etc/resolv.conf
rm -rf $MOUNT/lost+found
sysctl -w net.ipv4.ip_forward=1 > /dev/null
sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
# Enter Linux
chroot $MOUNT /bin/bash -c "source /etc/profile; bash"
# Remove Mount Points
umount $MOUNT/sys
umount $MOUNT/proc
umount $MOUNT/media
umount $MOUNT/dev/shm
umount $MOUNT/dev/pts
umount $MOUNT/dev
# Clean Up
umount $MOUNT
losetup -d /dev/block/loop_$NAME
rm /dev/block/loop_$NAME
rmdir $MOUNT
this is not the init.sh.
the init.sh is iniside the ubuntu.img so to boot using the init.sh you can edit the rc_enter.sh to start init.sh like so:
./init.sh
you can also start a service like so:
service hostname start
HI, I'm trying to extract initramfs from zImage by following this excellent thread:
http://forum.xda-developers.com/showthread.php?t=901152
I have followed carefully all the steps but i am getting the following error while executing the extraction script :
# sh repack-zImage.sh -u
repack-zImage.sh: 99: Syntax error: "(" unexpected
How can i resolve this please.
here is the sript :
Code:
#!/bin/bash
version="Version 6, by mizch <[email protected]>
Time-stamp: <2011-05-03 20:14:30 hcz>
Please refer to the thread on http://www.xda-developers.com for
questions and remarks about this program."
# Copyright (C) 2011 by Heike C. Zimmerer <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License. For
# details see <http://www.gnu.org/licenses/>.
### Preparation:
# You should have received cpio_set0 along with this program.
# Copy it into /usr/local/bin.
#
# The program will run without this (and emit an info message about
# using the normal cpio). However, the compession result of the
# initramfs will be smaller and consistent if you use it.
### What the program does:
usage(){
echo "\
Usage: $pname [-v] -u|-p|-z [<file name, default: zImage>]
Function: [Un]Pack a zImage (for modification, mainly of the initramfs)
Opts:
-u unpack an Image
-p pack an image from a directory structure created by
a previous unpack
-z create <file name>.tar from <file name> (simple tar, nothing fancy)
--version print version info
--help print this help
Play with the following three options to get best compression results:
-s use standard cpio (default: uses cpio_set0 if available)
-g use gen_init_cpio instead of cpio/cpio_set0 (ignores -s)
-r don't reorder initramfs according to the original layout
Debugging:
-v verbose (show commands and results as they are executed)
-x script debug (set -x)
Options to help nail down which modified part causes booting to fail.
Lower numbers override higher numbered options:
-1 Use original piggy.gz+piggy_trailer
-2 Use original piggy.gz
-3 Use original piggy
-4 Use original initramfs(_gz)+part3
-5 Use original initramfs_cpio"
exit $1
}
### Graphical display of the unpack process:
#
# Each of the indented items on the same level is derived from the
# single item one level higher.
#
# zImage
# (split)
# +---- decompression_code
# +---- piggy.gz+piggy_trailer
# (split)
# +---- piggy.gz
# | (gunzip)
# | +---- piggy
# | ===== either (compressed initramfs) ====
# | |
# | (split via gunzip limits)
# | +---- kernel.img
# | +---- initramfs_gz+part3
# | (split)
# | +---- initramfs.cpio.gz
# | | (gunzip)
# | | +---- initramfs.cpio
# | | (cpio -i)
# | | +---- initramfs/
# | +---- padding3
# | +---- part3
# | ===== or (uncompressed initramfs) =====
# | |
# | (split at "0707")
# | +---- kernel.img
# | +---- initramfs+part3
# | (split after "TRAILER!!!")
# | +---- initramfs.cpio
# | | (cpio -i)
# | | +---- initramfs/
# | +---- padding3
# | +---- part3
# +---- padding_piggy
# +---- piggy_trailer
#
#
pname="${0##*/}"
args=("[email protected]")
cur_dir="$(pwd)"
# file names:
decompression_code="decompression_code"
piggy_gz_piggy_trailer="piggy.gz+piggy_trailer"
piggy="piggy"
piggy_gz="piggy.gz"
padding_piggy="padding_piggy"
piggy_trailer="piggy_trailer"
ramfs_gz_part3="initramfs.cpio+part3"
ramfs_cpio_gz="initramfs.cpio.gz"
padding3="padding3"
part3="part3"
kernel_img="kernel.img"
ramfs_cpio="initramfs.cpio"
ramfs_dir="initramfs"
sizes="sizes"
ramfs_part3="ramfs+part3"
ramfs_list="initramfs_list"
cpio_t="cpio-t"
cpio="cpio_set0"
# We dup2 stderr to 3 so an error path is always available (even
# during commands where stderr is redirected to /dev/null). If option
# -v is set, we dup2 sterr to 9 also so commands (and some of their
# results if redirected to &9) are printed also.
exec 9>/dev/null # kill diagnostic ouput (will be >&2 if -v)
exec 3>&2 # an always open error channel
#
########### Start of functions
#
# Emit an error message and abort
fatal(){
# Syntax: fatal <string ...>
# Output error message, then abort
echo >&3
echo >&3 "$pname: $*"
kill $$
exit 1
}
# Execute a command, displaying the command if -v:
cmd(){
# Syntax: cmd <command> <args...>
# Execute <command>, echo command line if -v
echo >&9 "$*"
"[email protected]"
}
# Execute a required command, displaying the command if -v, abort on
# error:
rqd(){
# Syntax: cmd <command> <args...>
# Execute <command>, echo commandline if -v, abort on error
cmd "[email protected]" || fatal "$* failed."
}
relpath(){
# Syntax: relpath <absolute_path>
# Function: print a path below $cur_dir as relative path on stdout
if [ "${1#$cur_dir}" != "$1" ]; then
echo -n ".${1#$cur_dir}"
else # not below cur_dir
echo -n "$1"
fi
}
findByteSequence(){
# Syntax: findByteSequence <fname> [<string, default: gzip header>]
# Returns: position (offset) on stdout, empty string if nothing found
file="$1"
local opt
if [ "$2" = "lzma" ]; then
srch=$'\x5d....\xff\xff\xff\xff\xff'
opt=
else
srch="${2:-$'\x1f\x8b\x08'}" # Default: search for gzip header
opt="-F"
fi
pos=$(LC_ALL=C grep $opt -a --byte-offset -m 1 --only-matching -e "$srch" -- "$file")
echo ${pos%%:*}
}
getFileSize(){
# Syntax: getFileSize <file>
# Returns size of the file on stdout.
# Aborts if file doesn't exist.
rqd stat -c %s "$1"
}
recordPackingFileSize()(
# Syntax: recordPackingFileSize <file-var> ...
#
# dump out a file size from the packing directory for debugging.
# Note that the whole function is running in a subshell, so we can
# cd here.
rqd cd "$packing"
for file in "[email protected]"; do
eval local fnam=\$$file
local size=$(getFileSize "$fnam")
printf 'size_%s=%d # %#x\n' $file $size $size
done >> "$sizes"
)
recordFileSize(){
# Syntax: recordFileSize <file-var> ...
# Dump a file size from the current directory into $sizes for
# later sourcing as a shell script.
for file in "[email protected]"; do
eval local fnam=\$$file
local size=$(getFileSize "$fnam")
printf 'size_%s=%d # %#x\n' $file $size $size
done >> "$sizes"
}
recordVars(){
# Syntax dumpVar <var-name>
# Dumps var into file $sizes for later sourcing as a shell script
for var in "[email protected]"; do
eval printf '"%s=\"%s\"\n"' $var \$$var \$$var
done >> "$sizes"
}
checkNUL(){
# Syntax: checkNUL file offset
# Returns true (0) if byte there is 0x0.
[ "$(rqd 2>/dev/null dd if="$1" skip=$2 bs=1 count=1)" = $'\0' ]
}
# We can tell from the magic number where the start of a gzipped
# section is. We cannot tell its exact end. We could only know the
# end if we could get at the kernel's zeropage variables - which we
# can't since their position varies between versions and
# architectures. The following function separates the gzipped part
# from trailing bytes (which can be possibly garbage, but who knows?)
# via successive aproximation.
gunzipWithTrailer(){
# Syntax gunzipWithTrailer <file> <gzip name, sans .gz> <padding> <trailer>
#
# <file>: the input file
# <gzip name, sans .gz>, <padding>, <trailer>:
# The output files. For the gzipped part, both the
# compressed and the uncompressed output is generated, so we have
# 4 output files.
local file="$1"
local gz_result="$2.gz"
local result="$2"
local padding="$3"
local trailer="$4"
local tmpfile="/tmp/gunzipWithTrailer.$$.gz"
local original_size=$(getFileSize "$file")
local d=$(( (original_size+1) / 2))
local direction fini at_min=0
local results_at_min=()
local size=$d
local at_min=0
echo "Separating gzipped part from trailer in '$(relpath "$file")'"
echo -n "Trying size: $size"
while :; do
rqd dd if="$file" of="$tmpfile" bs=$size count=1 2>/dev/null
cmd gunzip >/dev/null 2>&1 -c "$tmpfile"
res=$?
if [ "$d" -eq 1 ]; then
: $((at_min++))
results_at_min[$size]=1
[ "$at_min" -gt 3 ] && break
fi
d=$(((d+1)/2))
case $res in
# 1: too small
1) size=$((size+d)); direction="↑";;
# 2: trailing garbage
2) size=$((size-d)); direction="↓";;
# OK
0) break;;
*) fatal "gunzip returned $res while checking '$(relpath "$file")'";;
esac
echo -n " $size"
done
if [ "$at_min" -gt 3 ]; then
echo -e "\ngunzip result is oscillating between 'too small' and 'too large' at size: ${!results_at_min[*]}"
echo -n "Trying lower nearby values: "
fini=
for ((d=1; d < 30; d++)); do
: $((size--))
echo -n " $size"
rqd dd if="$file" of="$tmpfile" bs=$size count=1 2>/dev/null
if cmd gunzip >/dev/null 2>&1 -c "$tmpfile"; then
echo -n " - OK"
fini=1
break
fi
done
[ -z "$fini" ] && fatal 'oscillating gunzip result, giving up.'
fi
# We've found the end of the gzipped part. This is not the real
# end since gzip allows for some trailing padding to be appended
# before it barfs. First, go back until we find a non-null
# character:
echo -ne "\npadding check (may take some time): "
real_end=$((size-1))
while checkNUL "$file" $real_end; do
: $((real_end--))
done
# Second, try if gunzip still succeeds. If not, add trailing
# null(s) until it succeeds:
while :; do
rqd dd if="$file" of="$tmpfile" bs=$real_end count=1 2>/dev/null
gunzip >/dev/null 2>&1 -c "$tmpfile"
case $? in
# 1: too small
1) : $((real_end++));;
*) break;;
esac
done
real_next_start=$size
# Now, skip NULs forward until we reach a non-null byte. This is
# considered as being the start of the next part.
while checkNUL "$file" $real_next_start; do
: $((real_next_start++))
done
echo $((real_next_start - real_end))
echo
rm "$tmpfile"
# Using the numbers we got so far, create the output files which
# reflect the parts we've found so far:
rqd dd 2>&9 if="$file" of="$gz_result" bs=$real_end count=1
rqd dd 2>&9 if="$file" of="$padding" skip=$real_end bs=1 count=$((real_next_start - real_end))
rqd dd 2>&9 if="$file" of="$trailer" bs=$real_next_start skip=1
rqd gunzip -c "$gz_result" > "$result"
}
# See the comment for gunzipWithTrailer (above) for what this function
# does:
unlzmaWithTrailer(){
# Syntax unlzmaWithTrailer <file> <gzip name, sans .gz> <padding> <trailer>
#
# <file>: the input file
# <gzip name, sans .gz>, <padding>, <trailer>:
# The output files. For the lzma'd part, both the
# compressed and the uncompressed output is generated, so we have
# 4 output files.
local file="$1"
local gz_result="$2.gz"
local result="$2"
local padding="$3"
local trailer="$4"
local tmpfile="/tmp/unlzmaWithTrailer.$$.gz"
local original_size=$(getFileSize "$file")
local d=$(( (original_size+1) / 2))
local direction fini at_min=0
local results_at_min=()
local size=$d
local at_min=
echo "Separating lzma'd part from trailer in '$(relpath "$file")'"
echo -n "Trying size: $size"
while :; do
rqd dd if="$file" of="$tmpfile" bs=$size count=1 2>/dev/null
cmd unlzma >/dev/null 2>&1 -S '' -c "$tmpfile"
res=$?
if [ "$d" -eq 1 ] && [ "$res" -eq 1 ]; then
at_min=yes # we're 1 below the result
fi
d=$(((d+1)/2))
case $res in
# 1: too small
1) size=$((size+d)); direction="↑";;
# 0: too large (or OK if d==1)
0) if [ "$at_min" ]; then
break
fi
size=$((size-d)); direction="↓";;
*) fatal "unlzma returned $res while checking '$(relpath "$file")'";;
esac
echo -n " $size"
done
# Now, skip NULs forward until we reach a non-null byte. This is
# considered as being the start of the next part.
echo
echo -n "Detecting padding: "
real_end="$size"
real_next_start="$size"
while checkNUL "$file" $real_next_start; do
: $((real_next_start++))
done
echo $((real_next_start - real_end))
echo
rm "$tmpfile"
# Using the numbers we got so far, create the output files which
# reflect the parts we've found so far:
rqd dd 2>&9 if="$file" of="$gz_result" bs=$real_end count=1
rqd dd 2>&9 if="$file" of="$padding" skip=$real_end bs=1 count=$((real_next_start - real_end))
rqd dd 2>&9 if="$file" of="$trailer" bs=$real_next_start skip=1
rqd unlzma -c -S '' "$gz_result" > "$result"
}
padTo(){
# Syntax: padTo <file> <size>
# Pads <file> to <size> with trailung 0x0s
# Does nothing if file matches size.
# Aborts if <file> too large for the operation.
local size=$(getFileSize "$1")
local tmp="/tmp/$pname.$$.zeroes"
if [ "$size" -eq "$2" ]; then
echo "$(relpath "$1"): size matches ($size)"
elif [ "$size" -gt "$2" ]; then
fatal "Size of '$(relpath "$1")' too large ($size > $2) (+$((size - $2)))"
else
echo "Padding '$(relpath "$1")' to $2 bytes (+$(($2 - size)))"
rqd dd 2>&9 if=/dev/zero of="$tmp" count=1 bs=$(($2 - size))
rqd cat "$tmp" >> "$1"
rqd rm -f "$tmp"
fi
}
padToMod(){
# Syntax: padTo <modulo> <file>
# Pads <file> until (size mod <modulo>) == 0.
local modulo=$1
local file="$2"
local size=$(getFileSize "$file")
local rest=$((size % modulo))
if [ "$rest" -ne 0 ]; then
padTo "$file" $((size + modulo - rest))
fi
}
buildZImageTar(){
# Syntax: buildZImageTar <path>
# Generates tarred file from <path> into the same directory.
# The file in the archive doesn't contain the path.
# Also copies the result to /home/Shared if it detects
# that it is running at home.
local dir="${1%/*}"/
[ "$dir" = "$1/" ] && dir="$(pwd)/"
(
cd "$dir"
rqd tar cf zImage.tar zImage
)
echo "Generated file: '$(relpath "${dir}$zImage.tar")'"
if [ "$HOSTNAME:$USER" = "Xelzbrot:hcz" ]; then
cp "${dir}zImage.tar" /home/Shared
echo "also copied to '/home/Shared'."
fi
}
reorderInitramfsList(){
# This is some black magic to get about the same compression
# result as the original initramfs.cpio. We reorder the files in
# our initramfs (which is to be created) so that they appear in
# the same order as in the original initramfs.
#
# Syntax: reorderInitramfsList <initramfs_list_file> <reordering_template_file>
#
# Reorders <initramfs_list_file> so that enries are in the order
# given by <reordering_template_file> (which comes from cpio -t).
# Files in <initramfs_list_file> but not in
# <reordering_template_file> are moved in sorted order to the end.
# Comments and empty lines are discarded. The result is written
# to <initramfs_list_file>.
#echo >&2 "Reordering initramfs list"
initramfs_list_file="$1"
reordering_template_file="$2"
declare -A ramfs_entries # make it an associative array
while read line; do
set -- $line
[ $# -eq 0 ] && continue # skip empty lines
[[ "$1" = \#* ]] && continue # skip comments
ramfs_entries["$2"]="$line" # else remember line, indexed by path
done < "$initramfs_list_file"
echo "# reordered ramfs entries" > "$initramfs_list_file"
# now spit the lines out in the order given by the reordering_template_file:
while read path; do
echo "${ramfs_entries["$path"]}"
unset ramfs_entries["$path"] # remove written lines from the array
done < "$reordering_template_file" >> "$initramfs_list_file"
# if there are any files left, append them in sorted order so directories
# come first:
for line in "${ramfs_entries[@]}"; do
echo "$line"
done \
| sort >> "$initramfs_list_file"
}
pack(){
if ! find >/dev/null 2>&1 "$unpacked" "$unpacked/$ramfs" "$unpacked/$sizes" -maxdepth 0; then
fatal "\
This does not look like a directory where a
previous unpack has been done."
fi
# create packing direcory
rqd mkdir -p "$packing"
sizes="$packing/sizes"
echo "# Packing sizes" > "$sizes"
# cd to unpacking directory (original and modified parts)
rqd cd "$unpacked"
# read in file size at the time of unpicking
rqd source sizes
if [ "$opt_1" ]; then
rqd cp "$piggy_gz_piggy_trailer" "$packing"
else
if [ "$opt_2" ]; then
rqd cp "$piggy_gz" "$packing"
else
if [ "$opt_3" ]; then
rqd cp "$piggy" "$packing"
compress_list=("$packing/$piggy") # compress it as a single file
else
if [ "$opt_4" ]; then
rqd cp "$ramfs_gz_part3" "$packing"
else
if [ "$opt_5" ]; then
rqd cp "$ramfs_cpio" "$packing"
else
echo "Generating initramfs"
if ! which >/dev/null "$cpio"; then
if [ -n "$compressed" ]; then
echo "Info: '$cpio' not found, using normal cpio."
echo " This only means that your compressed initramfs will be slightly larger"
echo " and its size will differ from invocation to invocation."
fi
cpio="cpio"
fi
for ftime in "" "-a" "-m"; do
find "$ramfs_dir" -exec touch $ftime -d @0 {} \;
done
rqd gen_initramfs_list.sh -u squash -g squash "$ramfs_dir" > "$packing/$ramfs_list"
cp "$packing/$ramfs_list" "$packing/$ramfs_list.orig"
if [ -z "$opt_r" ]; then
# reorder so files are arranged as in original initramfs:
reorderInitramfsList "$packing/$ramfs_list" "$cpio_t"
else
# sort so directories come before their content:
sort < "$cpio_t" > "$packing/$cpio_t.sorted"
reorderInitramfsList "$packing/$ramfs_list" "packing/$cpio_t.sorted"
fi
if [ -z "$opt_g" ]; then
# No -g: Use our own cpio routine
(
rqd cd "$ramfs_dir"
# extract the file names from our
# (possibly reordered) initramfs list
# and pass them to cpio:
while read line; do
set -- $line
[ $# -eq 0 ] && continue # skip empty lines
[[ "$1" = \#* ]] && continue # skip comments
echo "${2#/}"
done < "$packing/$ramfs_list" \
| rqd "$cpio" -H newc -R root:root -o > "$packing/$ramfs_cpio"
)
else
# -g set: use gen_init_cpio (from kernel tree)
rqd gen_init_cpio "$packing/$ramfs_list" > "$packing/$ramfs_cpio"
fi
recordPackingFileSize ramfs_cpio
fi # opt_5
if [ "$compressed" = "gz" ]; then
echo "Creating gzip compressed initramfs"
rqd gzip -8 < "$packing/$ramfs_cpio" > "$packing/$ramfs_cpio_gz"
padTo "$packing/$ramfs_cpio_gz" "$((size_ramfs_cpio_gz + size_padding3))"
rqd cat "$packing/$ramfs_cpio_gz" "$part3" > "$packing/$ramfs_gz_part3"
recordPackingFileSize ramfs_cpio_gz ramfs_gz_part3
elif [ "$compressed" = "lzma" ]; then
echo "Creating lzma compressed initramfs"
rqd lzma -9 < "$packing/$ramfs_cpio" > "$packing/$ramfs_cpio_gz"
padTo "$packing/$ramfs_cpio_gz" "$((size_ramfs_cpio_gz + size_padding3))"
rqd cat "$packing/$ramfs_cpio_gz" "$part3" > "$packing/$ramfs_gz_part3"
recordPackingFileSize ramfs_cpio_gz ramfs_gz_part3
else
echo "initramfs is not compressed"
fi
fi # opt_4
echo "Assembling piggy"
if [ -n "$compressed" ]; then
rqd cat "$kernel_img" "$packing/$ramfs_gz_part3" > "$packing/$piggy"
compress_list=("$packing/$piggy") # compress it as a single file
else
#touch "$packing/$padding3"
#padTo "$packing/$padding3" "$size_padding3"
padTo "$packing/$ramfs_cpio" $((size_ramfs_cpio + size_padding3))
# compress parts seperately (yields better compression results):
cat "$kernel_img" "$packing/$ramfs_cpio" "$part3" > "$packing/$piggy"
recordPackingFileSize "piggy"
compress_list=("$packing/$piggy")
fi
fi # opt_3
echo "Creating piggy.gz"
target_size=$((size_piggy_gz + size_padding_piggy))
# At first, use gzip -9 for compressing since it delivers
# better results with zImages most of the time:
rqd gzip -n -9 -c "${compress_list[@]}" > "$packing/$piggy_gz"
size1=$(getFileSize "$packing/$piggy_gz")
if [ "$size1" -gt "$target_size" ]; then
# too large. Try if we can get better results with
# gzip -8. If not, barf and abort:
rqd gzip -8 -n -c "${compress_list[@]}" > "$packing/$piggy_gz"
size2=$(getFileSize "$packing/$piggy_gz")
if [ "$size2" -gt "$target_size" ]; then
fatal "\
piggy.gz too large (gzip -9: +$((size1-target_size)), gzip -8: +$((size2-target_size)))
You might want to try a different combination of the -g, -r and -s options."
fi
fi
padTo "$packing/$piggy_gz" "$((size_piggy_gz + size_padding_piggy))"
recordPackingFileSize "piggy_gz"
fi # opt_2
echo "Assembling $zImage"
rqd cat "$packing/$piggy_gz" "$piggy_trailer" > "$packing/$piggy_gz_piggy_trailer"
fi # opt_1
rqd cat "$decompression_code" "$packing/$piggy_gz_piggy_trailer" \
> "$packing/$zImage"
echo "Successfully created '$(relpath "$packing/$zImage")'"
recordPackingFileSize zImage
buildZImageTar "$packing/$zImage"
}
unpack()(
[ -d "$unpacked" ] && echo "\
Warning: there is aready an unpacking directory. If you have files added on
your own there, the repacking result may not reflect the result of the
current unpacking process."
rqd mkdir -p "$unpacked"
rqd cd "$unpacked"
sizes="$unpacked/sizes"
echo "# Unpacking sizes" > "$sizes"
piggy_start=$(findByteSequence "$cur_dir/$zImage")
if [ -z "$piggy_start" ]; then
fatal "Can't find a gzip header in file '$zImage'"
fi
rqd dd 2>&9 if="$cur_dir/$zImage" bs="$piggy_start" count=1 of="$decompression_code"
rqd dd 2>&9 if="$cur_dir/$zImage" bs="$piggy_start" skip=1 of="$piggy_gz_piggy_trailer"
recordFileSize decompression_code piggy_gz_piggy_trailer
gunzipWithTrailer "$piggy_gz_piggy_trailer" \
"$piggy" "$padding_piggy" "$piggy_trailer"
recordFileSize "piggy" "piggy_gz" "padding_piggy" "piggy_trailer"
ramfs_gz_start=$( findByteSequence "$piggy" lzma)
if [ -n "$ramfs_gz_start" ]; then
echo "Found lzma compressed ramdisk."
compressed=lzma
else
ramfs_gz_start=$( findByteSequence "$piggy")
if [ -n "$ramfs_gz_start" ]; then
echo "Found gzip compressed ramdisk."
compressed=gz
fi
fi
if [ "$compressed" ]; then
rqd dd 2>&9 if="$piggy" of="$kernel_img" bs="$ramfs_gz_start" count=1
rqd dd 2>&9 if="$piggy" of="$ramfs_gz_part3" bs="$ramfs_gz_start" skip=1
if [ "$compressed" = "gz" ]; then
rqd gunzipWithTrailer "$ramfs_gz_part3" "$ramfs_cpio" "$padding3" "$part3"
else
rqd unlzmaWithTrailer "$ramfs_gz_part3" "$ramfs_cpio" "$padding3" "$part3"
fi
recordFileSize "kernel_img" "ramfs_cpio_gz" "padding3" "ramfs_gz_part3" "ramfs_cpio" "part3"
recordVars compressed
else
echo "Found uncompressed ramdisk."
compressed=""
initrd_start=$(findByteSequence "$piggy" "0707")
[ -z "$initrd_start" ] && fatal "Cannot find cpio header"
rqd dd 2>&9 if="$piggy" of="$kernel_img" bs="$initrd_start" count=1
rqd dd 2>&9 if="$piggy" of="$ramfs_part3" bs="$initrd_start" skip=1
initrd_end=$(findByteSequence "$ramfs_part3" "TRAILER!!!")
[ -z "$initrd_end" ] && fatal "Cannot find cpio trailer"
initrd_end=$((initrd_end + 10)) # skip trailer length
initrd_end=$(( (initrd_end | 0x1ff) + 1)) # round up to block size (512)
rqd dd 2>&9 if="$ramfs_part3" of="$ramfs_cpio" bs="$initrd_end" count=1
real_next_start=$initrd_end
echo -n "Detecting padding (may take some time): "
while checkNUL "$ramfs_part3" $real_next_start; do
: $((real_next_start++))
done
padding3_len=$((real_next_start - initrd_end))
echo $padding3_len
rqd dd 2>&9 if="$ramfs_part3" of="$padding3" skip="$initrd_end" count="$padding3_len" bs=1
rqd dd 2>&9 if="$ramfs_part3" of="$part3" bs="$real_next_start" skip=1
recordFileSize "kernel_img" "padding3" "ramfs_part3" "ramfs_cpio" "part3"
recordVars compressed
fi
echo "Unpacking initramfs"
rqd cpio -t < "$ramfs_cpio" > "$cpio_t"
rqd mkdir -p "$ramfs_dir"
(
rqd cd "$ramfs_dir"
rqd cpio -i -m --no-absolute-filenames -d -u < "../$ramfs_cpio"
)
echo
echo "Success."
echo "The unpacked files and the initramfs directory are in '$(relpath "$unpacked")'."
)
#### start of main program
while getopts xv12345sgrpuhtz-: argv; do
case $argv in
p|u|z|1|2|3|4|5|t|r|g) eval opt_$argv=1;;
v) exec 9>&2; opt_v=1;;
s) cpio="cpio";;
x) set -x;;
-) if [ "$OPTARG" = "version" ]; then
echo "$pname $version"
exit 0
else
usage
fi;;
h|-) usage;;
*) fatal "Illegal option";;
esac
done
shift $((OPTIND-1))
zImage="${1:-zImage}"
unpacked="$cur_dir/${zImage}_unpacked"
packing="$cur_dir/${zImage}_packing"
shift
if [ -n "$*" ]; then
fatal "Excess arguments: '$*'"
fi
if [ -n "$opt_z" ]; then
buildZImageTar "$zImage"
fi
if [ -n "$opt_u" ]; then
[ -f "$zImage" ] || fatal "file '$zImage': not found"
unpack
fi
if [ -n "$opt_p" ]; then
pack
fi
#if [ -n "$opt_t" ]; then # for testing
# reorderInitramfsList "$packing/$ramfs_list" "$unpacked/$cpio_t"
#fi
if [ -z "$opt_p$opt_u$opt_z$opt_t" ]; then
echo >&2 "$pname: Need at least one of -u, -p, or -z."
echo >&2 "$pname: Type '$pname --help' for usage info."
exit 1
fi
exit
Solved. (by using bash instead of sh)..
Hi,
for catching events I found:
http://forum.xda-developers.com/showthread.php?t=2233865
Now I want to build a shell were I can look for devices and then catch them and bind them to a action...
It's my first time I tried to write a shell script...
The script works if I don't have any devices witch sends continuously there daters:
Code:
#!/system/bin/sh
[...]
device1="/dev/input/event4"
device2="/dev/input/event0"
while :; do
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
done
Result="$?"
if [[ "$Result" == "11" ]] then
input keyevent 85 #KEYCODE_MEDIA_PLAY_PAUSE
fi
done
..mapping looks like:
Code:
Mapping() { # "${ev_path/:}" "$ev_code" "$ev_value" "$deviceX1" "$deviceX2" (...)
if [[ "$1" == "$4" && "$2" == "0139" && "$3" == "00000001" ]] then
return 11 #Play/Pause
fi
# (…) and so on
}
is there any way to write
Code:
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
to
Code:
getevent -q -t | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
if [ -n "$?" ]; then
>>>> exit / break /what ever
fi
done
I tried it with “exit”, “break” and “return” (and “kill $PID”) but getevent didn't want to exit :'(
any ideas?
(pleas be clement with my grammar.. it's not my native language )
kind regards, Veit