-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathafterboot
More file actions
286 lines (261 loc) · 8.45 KB
/
afterboot
File metadata and controls
286 lines (261 loc) · 8.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/system/bin/sh
#
# W.I.P. script, by USBhost. made for the Nexus 9.
#
# I use busybox for some commands because
# some of them are newer.
#
# Load Symbols
. /system/etc/FI.d/symbols
# Script pacific Symbol
LC="afterboot"
# -----------------------<Start>------------------------ #
# Fix FC of startup wizard
if [ ! -f /data/Zmlyc3Rib290.FI ]; then
$LOGCATI$LC "Enable wifi for first boot";
svc wifi enable;
touch /data/Zmlyc3Rib290.FI;
fi
# Give some time for the system to boot
if [ "$1" != "s" ]; then
$BB sleep 30;
fi
# -------------------------<TCP>------------------------- #
# Fix ping loops when adblocking.
iptables -I INPUT 1 -i lo -p tcp --dport 443 -j REJECT;
# --------------------<User Options>-------------------- #
# overclocking.
# CPU 2.5 ghz
# GPU 0.984 ghz
## (0 = disabled) (1 = enabled) ##
oc=0
# CPU Interactive Governor fix.
# this will increase battery life.
# Note: but adding some lag.
gfix=0 ## (0 = disabled) (1 = enabled) ##
gpfix=70 # % until the cpu jumps frequencies
# (debugging).
# FSync
# This helps reduce data corruption but
# lowers performance.
## (0 = disabled) (1 = default/enabled) ##
fs=1
# USB Fast Charge.
## (0 = kernel default/disabled) (1 = enabled) ##
fc=1
# ------------------------<MEMORY>----------------------- #
# Kernel Samepage Merging
# This tries to save memory by scaning/searching for pages that are the same.
# Then it merges them into one page... saving memory.
# ---- NOTE ----
# 1. This does not work vary well with ZRAM/SWAP
# because it doesn't scan swap pages.
# 2. This may or may not add lag.
# 3. This uses a small/medium amount of cpu.
# ---- Check savings ----
# /system/xbin/bash -c "echo $[$(cat /sys/kernel/mm/ksm/pages_shared)*4096/1024 ]KB"
## (0 = disabled) (1 = enabled) ##
ksm=0
# SWAP wait.
# This controls if you want swap to be at a certain percent
# full until lmk starts killing.
# ---- NOTE ----
# "swait" will account free swap in lmk if enabled.
# (0 = kernel default/disabled) (1 = enabled)
# "swaitp" will choose which percent killing is allowed.
## 1=0% 2=50% 3=66% 4=75% 5=80% 10=90% 0=100% 00=off ##
swait=0
swaitp=00
# ZRAM (ONLY).
# This will make a compressed ram block
# that is used as swap to make more usable ram.
# (Google ZRAM for more info)
# ---- NOTE ----
# "aswap" will be null if enabled.
# This uses a fair amount of cpu.
# "zswap" is in MB.
## (0 = disabled) ##
zswap=512
# /cache swap file.
# This make's a swap file.
# ---- NOTE ----
# "cswap" must not go over 150MB if /cache is formated to f2fs.
# "cswap" is in MB.
## (0 = disabled) ##
cswap=0
# /cache all swap.
# This will make /cache completely swap.
# ---- NOTE ----
# "cswap" will be null if enabled.
# The size of /cache is 256MB.
# Swap will be 256MB or 512MB if "raid" = 1 .
# Cache will be formated to swap.
# Your EMMC will be used a lot aka shorter lifespan.
## (0 = disabled) (1 = enabled) ##
aswap=0
# Raid 0
# This will Split memory evenly across "zswap" and "cswap"
# that makes "cswap" or "aswap" about ~100% faster.
# ---- NOTE ----
# If it's set too big you will get a lot of lag.
# This uses a small to fair amount of cpu.
# This can be used on "cswap" or "aswap".
## (0 = disabled) (1 = enabled) ##
raid=0
# ------------------------<EXPERT>----------------------- #
# Load override
# This is where you would put all your desired settings into (if you want to)
# "/sdcard/override", so you don't have to edit system on every Kernel update.
# Note: be vary careful with what you put in it, this runs as root.
# Use with caution!
if [ -e "$ORID" ]; then
$LOGCATI$LC " $ORID; loading ";
. $ORID;
else
# we must skip or an error will close the script.
$LOGCATI$LC " no override; skipping ";
fi
MCACHE;
$BB swapoff -a; # to keep things clean
echo 1 > $ZRS/reset; # to keep things clean
if [ "$cswap" -ge "1" ] && [ "$aswap" == "0" ] && [ "$MCACHE" == "$CACHE" ]; then
CSIZE;
if [ ! -e "$CSWAP" ] || [ "$CSIZE" != "$cswap" ]; then # to make or change cswap
# if cswap is more than the free space left in cache then this will loop on every reboot which is vary bad.
# if you get "cache; is out of space" error please lower cswap size.
# FIXME: try to fix this problem.
if [ -e $CSWAP ] && [ "$CSIZE" != "$cswap" ]; then
$LOGCATI$LC " cache; changing cswap size to $cswap ";
fi
$BB dd if=/dev/zero of=$CSWAP bs="$cswap"M count=1;
format="1"; # if cswap size changed and/or was made we must format it to swap.
CSIZE;
if [ "$cswap" != "$CSIZE" ]; then # if so this is bad!
cswap="0"; # stop cswap from being used so the user can know sooner.
format="0";
$LOGCATW$LC " cache; is out of space ";
reason="out of space";
fi
fi
if [ "$cswap" != "0" ]; then # if so all is good!
chmod 600 $CSWAP; # make sure root can only read and write to it.
if [ "$format" == "1" ]; then
$BB mkswap $CSWAP;
fi
if [ "$raid" == "1" ]; then
$BB swapon -p 1 $CSWAP; # raid 0
elif [ "$raid" == "0" ]; then
$BB swapon $CSWAP; # cswap
fi
if [ "$raid" == "1" ] && [ "$cswap" -ge "1" ]; then
echo 1 > $ZRS/reset;
echo 1 > $ZRS/max_comp_streams;
echo lz4 > $ZRS/comp_algorithm;
echo "$cswap"M > $ZRS/disksize;
$BB mkswap $ZRB;
$BB swapon -p 1 $ZRB;
fi
elif [ "$cswap" == "0" ]; then # if so this is bad!
$LOGCATW$LC " cswap; will not run; $reason";
fi
fi
if [ "$zswap" == "0" ] && [ "$aswap" == "1" ]; then
MCACHE;
if [ "$MCACHE" == "$CACHE" ]; then # if mounted unmount it.
$BB umount /cache;
MCACHE;
if [ "$MCACHE" == "" ]; then
$LOGCATI$LC " cache; unmount success ";
aswap="1";
format="1"; # format is needed
elif [ "$MCACHE" == "$CACHE" ]; then
$LOGCATW$LC " cache; unmount failed ";
reason="cache is still mounted";
aswap="0";
fi
elif [ "$MCACHE" == "" ]; then # cache was not mounted; can be swap.
aswap="1";
format="0"; # do not format
fi
if [ "$aswap" == "1" ] && [ "$format" == "1" ]; then
# FIXME: stop the mount if the format failed.
$BB mkswap $CACHE || $LOGCATW$LC " format failed ";
fi
if [ "$aswap" == "1" ]; then
$BB mount -t tmpfs -o rw,mode=1777 tmpfs /cache;
$BB swapon -p 1 $CACHE || $LOGCATW$LC " swapon failed ";
if [ "$raid" == "1" ]; then
echo 1 > $ZRS/reset;
echo 1 > $ZRS/max_comp_streams;
echo lz4 > $ZRS/comp_algorithm;
echo "$PSIZE"M > $ZRS/disksize;
$BB mkswap $ZRB;
$BB swapon -p 1 $ZRB;
fi
elif [ "$aswap" == "0" ]; then # if so this is bad!
$LOGCATI$LC "aswap skipped; $reason";
fi
fi
if [ "$zswap" -ge "1" ] && [ "$aswap" == "0" ] && [ "$cswap" == "0" ]; then
echo 1 > $ZRS/reset;
echo "$CORE" > $ZRS/max_comp_streams;
echo lz4 > $ZRS/comp_algorithm;
echo "$zswap"M > $ZRS/disksize;
$BB mkswap $ZRB;
$BB swapon $ZRB;
fi
if [ -e /sys/kernel/mm/ksm/run ]; then
# VM_MERGEABLE , page checking
# This is meant for ksm that has page checking.
echo 100 > /sys/kernel/mm/ksm/pages_to_scan;
echo 100 > /sys/kernel/mm/ksm/sleep_millisecs;
echo 1 > /sys/kernel/mm/ksm/deferred_timer;
echo 1 > /sys/kernel/mm/ksm/mark_new_vma;
echo 1 > /sys/kernel/mm/ksm/use_zero_pages;
if [ "$ksm" == "1" ]; then
echo 1 > /sys/kernel/mm/ksm/run;
elif [ "$ksm" == "0" ]; then
echo 0 > /sys/kernel/mm/ksm/run;
fi
fi
if [ "$swait" == "1" ]; then
echo Y > /sys/module/lowmemorykiller/parameters/swap_wait;
if [ "$raid" == "1" ] || [ "$zswap" -gt "$PSIZE" ]; then
# use swap as much as posable if not you will get a lot more lag.
# because in flounder if free memory gets vary low things will get lagy!
echo 100 > /proc/sys/vm/swappiness;
fi
if [ "$swaitp" != "00" ]; then
echo $swaitp > /sys/module/lowmemorykiller/parameters/swap_wait_percent;
fi
fi
if [ "$oc" == "1" ]; then
echo 2499000 > /sys/module/cpu_tegra/parameters/cpu_user_cap # This must be set to oc
elif [ "$oc" == "0" ]; then
# the gpu starts at the max frequency so set it back to the stock frequency.
echo 1 > /sys/kernel/tegra_gpu/gpu_cap_state
echo 852000000 > /sys/kernel/tegra_gpu/gpu_cap_rate
fi
if [ "$gfix" == "1" ]; then
echo 510000 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq;
echo "$gpfix" > /sys/devices/system/cpu/cpufreq/interactive/target_loads;
fi
if [ "$fs" == "0" ]; then
echo 0 > /sys/module/sync/parameters/fsync_enabled;
fi
if [ "$fc" == "1" ]; then
echo 1 > /sys/kernel/fast_charge/force_fast_charge;
fi
if [ -e "$CSWAP" ] && [ "$cswap" == "0" ]; then
CSIZE;
if [ "$CSIZE" -ge "150" ]; then
rm $CSWAP;
fi
fi
# Turn on led
echo 1 > /sys/class/htc_sensorhub/sensor_hub/led_en;
sleep 2;
echo 0 > /sys/class/htc_sensorhub/sensor_hub/led_en;
# Allow suspend
echo fi_lock > /sys/power/wake_unlock;
$LOGCATI$LC " Done ";