Skip to content

Commit d5fb55e

Browse files
committed
Enhancements and flashable zip generator
1 parent 6d48fbf commit d5fb55e

12 files changed

+90
-49
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
** text eol=lf
33

44
# Denote all files that are truly binary and should not be modified.
5+
*.zip binary
56
bin/** binary
6-
system/app/** binary

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
_builds
2-
_misc
31
*.zip
2+
update-binary
3+
customize.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#MAGISK

README.html

+6-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ <h2 id="license">License</h2>
5252

5353
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
5454
</code></pre>
55+
<h2 id="generate-a-magisk-module-flashable-zip">Generate a Magisk Module Flashable Zip</h2>
56+
<pre><code>sh /path/to/zip.sh
57+
</code></pre>
5558
<h2 id="installupgrade">Install/Upgrade</h2>
5659
<pre><code>Android (Magisk module)
57-
su -c sh /path/to/install.sh [--start]
60+
Flash the zip or run su -c sh /path/to/install.sh [--start]
5861

5962
GNU/Linux
6063
sudo sh /path/to/install.sh [--start]
@@ -74,7 +77,7 @@ <h2 id="config">Config</h2>
7477
/etc/zram-swap-manager.conf
7578
</code></pre>
7679
<h2 id="terminal">Terminal</h2>
77-
<pre><code>zram-swap-manager --help
80+
<pre><code>Run zsm or zram-swap-manager for help.
7881
</code></pre>
7982
<h2 id="benchmarks">Benchmarks</h2>
8083
<table>
@@ -139,7 +142,7 @@ <h2 id="benchmarks">Benchmarks</h2>
139142
</table>
140143
<h2 id="donations">Donations</h2>
141144
<ul>
142-
<li>Airtm Username: ivandro863auzqg</li>
145+
<li><a href="https://app.airtm.com/send-or-request/send">Airtm username: ivandro863auzqg</a></li>
143146
<li><a href="https://liberapay.com/vr25/">Liberapay</a></li>
144147
<li><a href="https://patreon.com/vr25/">Patreon</a></li>
145148
<li><a href="https://paypal.me/vr25xda/">PayPal</a></li>

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
1818

19+
## Generate a Magisk Module Flashable Zip
20+
sh /path/to/zip.sh
21+
1922
## Install/Upgrade
2023
Android (Magisk module)
21-
su -c sh /path/to/install.sh [--start]
24+
Flash the zip or run su -c sh /path/to/install.sh [--start]
2225

2326
GNU/Linux
2427
sudo sh /path/to/install.sh [--start]
@@ -38,7 +41,7 @@
3841
/etc/zram-swap-manager.conf
3942

4043
## Terminal
41-
zram-swap-manager --help
44+
Run zsm or zram-swap-manager for help.
4245

4346
## Benchmarks
4447
| Compressor | Ratio | Compression | Decompression |
@@ -53,7 +56,7 @@
5356
| lzf 3.6 -1 | 2.077 | 400 MB/s | 860 MB/s |
5457

5558
## Donations
56-
- Airtm Username: ivandro863auzqg
59+
- [Airtm username: ivandro863auzqg](https://app.airtm.com/send-or-request/send)
5760
- [Liberapay](https://liberapay.com/vr25/)
5861
- [Patreon](https://patreon.com/vr25/)
5962
- [PayPal](https://paypal.me/vr25xda/)

android/setup-busybox.sh renamed to busybox.sh

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Busybox Setup
2-
# Copyright 2019-2020, VR25
3-
# License: GPLv3+
4-
#
5-
# Usage: . $0
6-
7-
81
[ -x /dev/.vr25/busybox/ls ] || {
92
mkdir -p /dev/.vr25/busybox
103
chmod 0700 /dev/.vr25/busybox

install.sh

+47-11
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,77 @@
55
exit 2
66
}
77

8-
cd "${0%/*}" 2>/dev/null
8+
# set source code directory
9+
src="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
10+
11+
# for magisk
12+
SKIPUNZIP=1
913

1014
if [ -d /data/adb ]; then
15+
1116
# android
12-
. $PWD/android/setup-busybox.sh
17+
18+
# extract flashable zip if source code is unavailable
19+
[ -f $src/TODO ] || {
20+
src=/dev/.vr25-zsm-install
21+
on_exit() { rm -rf ${src:-//} 2>/dev/null; }
22+
on_exit
23+
trap on_exit EXIT
24+
mkdir $src
25+
unzip "${3:-${ZIPFILE}}" -d $src/ >&2
26+
}
27+
28+
. $src/busybox.sh
29+
1330
install_dir=/data/adb/modules/zram-swap-manager
1431
data_dir=/data/adb/vr25/zram-swap-manager-data
32+
1533
rm -rf $install_dir 2>/dev/null
1634
mkdir -p $install_dir/system/bin $data_dir
17-
cp $PWD/zram-swap-manager.sh $install_dir/
35+
36+
cp $src/zram-swap-manager.sh $install_dir/
1837
ln -sf $install_dir/zram-swap-manager.sh $install_dir/system/bin/zram-swap-manager
1938
ln -sf $install_dir/zram-swap-manager.sh $install_dir/system/bin/zsm
2039
ln -sf $install_dir/zram-swap-manager.sh /sbin/zram-swap-manager 2>/dev/null \
2140
&& ln -sf $install_dir/zram-swap-manager.sh /sbin/zsm
22-
[ -f $data_dir/config.txt ] || cp $PWD/zram-swap-manager.conf $data_dir/config.txt
23-
cp $PWD/uninstall.sh $install_dir/
41+
42+
[ -f $data_dir/config.txt ] || cp $src/zram-swap-manager.conf $data_dir/config.txt
43+
44+
cp $src/uninstall.sh $install_dir/
2445
ln -sf $install_dir/uninstall.sh $install_dir/system/bin/zram-swap-manager-uninstall
2546
ln -sf $install_dir/uninstall.sh /sbin/zram-swap-manager-uninstall 2>/dev/null
47+
2648
for i in $install_dir/*.sh; do
2749
sed -i 's|^#!/.*|#!/system/bin/sh|' $i
2850
done
51+
52+
i="$PWD"
53+
cd $src/
54+
cp busybox.sh module.prop service.sh $install_dir/
55+
cd "$i"
2956
unset i
30-
cp $PWD/android/* $install_dir/
3157
chmod +x $install_dir/*.sh
3258
[ ".$1" != .--start ] || $install_dir/service.sh
59+
3360
else
61+
3462
# gnu/linux
63+
3564
[ -f /etc/zram-swap-manager.conf ] && upgrade=true
36-
sh $PWD/uninstall.sh --keep-config >/dev/null 2>&1
65+
sh $src/uninstall.sh --keep-config >/dev/null 2>&1
3766
mkdir -p /usr/local/bin/
38-
install -m 644 $PWD/zram-swap-manager.service /etc/systemd/system/zram-swap-manager.service
39-
install -m 755 $PWD/zram-swap-manager.sh /usr/local/bin/zram-swap-manager
67+
68+
install -m 644 $src/zram-swap-manager.service /etc/systemd/system/zram-swap-manager.service
69+
70+
install -m 755 $src/zram-swap-manager.sh /usr/local/bin/zram-swap-manager
4071
ln -s /usr/local/bin/zram-swap-manager /usr/local/bin/zsm
41-
${upgrade:-false} || install -m 644 $PWD/zram-swap-manager.conf /etc/
42-
install -m 755 $PWD/uninstall.sh /usr/local/bin/zram-swap-manager-uninstall
72+
73+
${upgrade:-false} || install -m 644 $src/zram-swap-manager.conf /etc/
74+
install -m 755 $src/uninstall.sh /usr/local/bin/zram-swap-manager-uninstall
75+
4376
systemctl enable zram-swap-manager
4477
[ ".$1" != .--start ] || zram-swap-manager -r
78+
4579
fi
80+
81+
echo "Done!"
File renamed without changes.
File renamed without changes.

zip.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
3+
{ cd "${0%/*}"
4+
cp -u install.sh customize.sh
5+
cp -u install.sh META-INF/com/google/android/update-binary; } 2>/dev/null
6+
zip -r9 zsm-magisk-$(date +%Y%m%d%H%m%S).zip * .git* -x \*.zip -x .git/\*

zram-swap-manager.conf

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# : ${comp_algorithm:=lz4}
2-
# : ${comp_ratio:=210}
3-
# : ${mem_percent:=33}
1+
comp_algorithm=lz4
2+
comp_ratio=210
3+
mem_percent=33
44

5-
# : ${mem_total:=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)}
6-
# : ${mem_limit:=$(calc "$mem_total * $mem_percent / 100 * 1024")}
7-
# : ${disksize:=$(calc "$mem_limit * $comp_ratio / 100")}
5+
mem_total=$(awk '/^MemTotal:/{print $2' /proc/meminfo)
6+
mem_limit=$(calc "$mem_total * $mem_percent / 100 * 1024")
7+
disksize=$(calc "$mem_limit * $comp_ratio / 100")
88

9-
# : ${max_comp_streams:=$(( $(cut -d- -f2 /sys/devices/system/cpu/present) + 1 ))}
10-
# : ${swap_device:=$([ -d /data/adb ] && echo /dev/block/zram || echo /dev/zram)}
9+
max_comp_streams=$(( $(cut -d- -f2 /sys/devices/system/cpu/present) + 1 ))
10+
swap_device=$([ -d /data/adb ] && echo /dev/block/zram || echo /dev/zram)
1111

12-
# : ${dynamic_swappiness:=true}
13-
# : ${load_sampling_rate:=60}
14-
# : ${high_load_threshold:=90}
15-
# : ${high_load_swappiness:=80}
16-
# : ${medium_load_threshold:=45}
17-
# : ${medium_load_swappiness:=90}
18-
# : ${low_load_threshold:=0}
19-
# : ${low_load_swappiness:=100}
12+
dynamic_swappiness=true
13+
load_sampling_rate=60
14+
high_load_threshold=90
15+
high_load_swappiness=80
16+
medium_load_threshold=45
17+
medium_load_swappiness=90
18+
low_load_threshold=0
19+
low_load_swappiness=100
2020

21-
# ${vm:=swappiness=$high_load_swappiness}
21+
vm="swappiness=80 vfs_cache_pressure=200"
2222

23-
# android's low memory killer
23+
# android's low memory killer (deprecated in favor of lmkd in recent OS versions)
2424
# write /sys/module/lowmemorykiller/parameters/minfree "CUSTOM PARAMETERS GO HERE"

zram-swap-manager.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
version="v2021.10.24-beta (202110240)"
3+
version="v2021.10.26-beta (202110260)"
44
info="zRAM Swap Manager $version
55
Copyright (C) 2021, VR25
66
License: GPLv3+
@@ -135,8 +135,7 @@ do
135135
}
136136
done
137137

138-
[ -f $magisk_mod/setup-busybox.sh ] \
139-
&& . $magisk_mod/setup-busybox.sh
138+
[ -f $magisk_mod/busybox.sh ] && . $magisk_mod/busybox.sh
140139

141140
# default settings
142141

@@ -160,7 +159,7 @@ done
160159
: ${low_load_threshold:=0}
161160
: ${low_load_swappiness:=100}
162161

163-
: ${vm:=swappiness=$high_load_swappiness}
162+
: ${vm:=swappiness=80 vfs_cache_pressure=200}
164163

165164
case $1 in
166165
-*c) shift; edit_config "$@";;

0 commit comments

Comments
 (0)