-
Notifications
You must be signed in to change notification settings - Fork 33
/
backup.sh
1325 lines (1211 loc) · 41.7 KB
/
backup.sh
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ubuntu 20.04 更换阿里云源
cp /etc/apt/sources.list /etc/apt/sources.list.default
echo 'deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
' >/etc/apt/sources.list
# java
sed -i '/JAVA_HOME/d' ~/.bashrc
echo 'export JAVA_HOME="/usr/local/jdk-11" PATH="$PATH:/usr/local/jdk-11/bin"' >>~/.bashrc
. ~/.bashrc
rm -rf $JAVA_HOME
curl -L "https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz" | tar xz -C "/usr/local"
# Hadoop2
sed -i '/HADOOP_HOME/d' ~/.bashrc
echo 'export HADOOP_HOME=/usr/local/hadoop-2.10.2' >>~/.bashrc
echo 'export HADOOP_INSTALL=$HADOOP_HOME' >>~/.bashrc
echo 'export HADOOP_MAPRED_HOME=$HADOOP_HOME' >>~/.bashrc
echo 'export HADOOP_COMMON_HOME=$HADOOP_HOME' >>~/.bashrc
echo 'export HADOOP_HDFS_HOME=$HADOOP_HOME' >>~/.bashrc
echo 'export YARN_HOME=$HADOOP_HOME' >>~/.bashrc
echo 'export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native' >>~/.bashrc
echo 'export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin' >>~/.bashrc
. ~/.bashrc
rm -rf $HADOOP_HOME
curl -L "https://dlcdn.apache.org/hadoop/common/hadoop-2.10.2/hadoop-2.10.2.tar.gz" | tar xz -C "/usr/local"
# spark
curl -L "https://dlcdn.apache.org/spark/spark-3.3.0/spark-3.3.0-bin-hadoop3.tgz" | tar xz -C "/usr/local"
# maven
sed -i '/MAVEN_HOME/d' ~/.bashrc
echo 'export MAVEN_HOME="/usr/local/apache-maven-3.8.2" PATH="$PATH:/usr/local/apache-maven-3.8.2/bin"' >>~/.bashrc
. ~/.bashrc
rm -rf $MAVEN_HOME
curl -L "https://dlcdn.apache.org/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz" | tar xz -C "/usr/local"
# mysql
sed -i '/MYSQL_HOME/d' ~/.bashrc
echo 'export MYSQL_HOME="/usr/local/mysql" PATH="$PATH:/usr/local/mysql/bin"' >>~/.bashrc
. ~/.bashrc
rm -rf $MYSQL_HOME
curl -L "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.17-x86_64-minimal-rebuild.tar.xz" | tar xJ -C "/usr/local"
mv /usr/local/mysql-8.0.26-linux-glibc2.17-x86_64-minimal-rebuild/ $MYSQL_HOME
apt install libncurses5 -y
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
mysqld --initialize --user=mysql
mysql_ssl_rsa_setup
cp support-files/mysql.server /etc/init.d/mysql.server
## change password
mysqld_safe --skip-grant-tables --skip-networking --user=mysql >/dev/null 2>&1 &
# FLUSH PRIVILEGES;
# ALTER USER 'root'@'localhost' IDENTIFIED BY 'hjuhWRfduHhpZ5NW';
## create test database
# create database test;
# use test;
# \q
pkill mysql*
service mysql.server start
# ruby
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
rvm install 3.0.0
rvm use 3.0.0 --default
# rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sed '/cargo/d' ~/.bashrc
echo '. $HOME/.cargo/env' >>~/.bashrc
. ~/.bashrc
rustup target add aarch64-unknown-linux-musl \
arm-unknown-linux-musleabi \
mipsel-unknown-linux-musl \
mips-unknown-linux-musl \
mips64el-unknown-linux-muslabi64 \
mips64-unknown-linux-muslabi64 \
x86_64-unknown-linux-musl \
i686-unknown-linux-musl \
x86_64-pc-windows-gnu \
i686-pc-windows-gnu \
armv7-linux-androideabi \
aarch64-linux-android
echo '[build]
target = "x86_64-unknown-linux-musl"
rustflags = [
"-C", "link-arg=-static",
"-C", "link-arg=-s",
"-C", "target-feature=+crt-static",
]
[target.i686-pc-windows-gnu]
linker = "i686-w64-mingw32-gcc"
rustflags = [
"-C", "panic=abort",
]
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
[target.mipsel-unknown-linux-gnu]
linker = "mipsel-linux-gnu-gcc"
[target.mips-unknown-linux-gnu]
linker = "mips-linux-gnu-gcc"
[target.mips64el-unknown-linux-gnuabi64]
linker = "mips64el-linux-gnuabi64-gcc"
[target.mips64-unknown-linux-gnuabi64]
linker = "mips64-linux-gnuabi64-gcc"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.arm-unknown-linux-gnueabi]
linker = "arm-linux-gnueabi-gcc"
[target.x86_64-unknown-linux-gnu]
linker = "x86_64-linux-gnu-gcc"
[target.i686-unknown-linux-gnu]
linker = "i686-linux-gnu-gcc"
[target.mipsel-unknown-linux-musl]
linker = "mipsel-linux-musl-gcc"
[target.mips-unknown-linux-musl]
linker = "mips-linux-musl-gcc"
[target.mips64el-unknown-linux-muslabi64]
linker = "mips64el-linux-musl-gcc"
[target.mips64-unknown-linux-muslabi64]
linker = "mips64-linux-musl-gcc"
[target.arm-unknown-linux-musleabi]
linker = "arm-linux-musleabi-gcc"
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
[target.i686-unknown-linux-musl]
linker = "i686-linux-musl-gcc"
[target.armv7-linux-androideabi]
linker = "arm-linux-androideabi-gcc"
rustflags = [
"-C", "link-arg=-s",
"-C", "link-arg=-pthread"
]
[target.aarch64-linux-android]
linker = "aarch64-linux-android-gcc"
rustflags = [
"-C", "link-arg=-s",
"-C", "link-arg=-pthread"
]' >~/.cargo/config
# android ndk https://github.com/android/ndk/issues/1390#issuecomment-740154546
sed -i '/ANDROID_NDK_HOME/d' ~/.bashrc
echo 'export ANDROID_NDK_HOME="/usr/local/android-ndk-r23" PATH="$PATH:/usr/local/android-ndk-r23:/usr/local/android-ndk-r23/toolchains/llvm/prebuilt/linux-x86_64/bin"' >>~/.bashrc
. ~/.bashrc
rm -rf $ANDROID_NDK_HOME
curl -O "https://dl.google.com/android/repository/android-ndk-r23-linux.zip"
bsdtar -C "/usr/local" -xf android-ndk-r23-linux.zip
rm -f android-ndk-r23-linux.zip
## soft link toolchain standalone
for target in aarch64-linux-android armv7a-linux-androideabi i686-linux-android x86_64-linux-android; do
TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
for llvm_tool in $(ls $TOOLCHAIN/bin/llvm-* | awk -F 'llvm-' '{print $2}'); do
ln -sf $TOOLCHAIN/bin/llvm-$llvm_tool $TOOLCHAIN/bin/$target-$llvm_tool
done
ln -sf $TOOLCHAIN/bin/llvm-ar $TOOLCHAIN/bin/$target-ar
ln -sf $TOOLCHAIN/bin/${target}31-clang $TOOLCHAIN/bin/$target-gcc
ln -sf $TOOLCHAIN/bin/${target}31-clang $TOOLCHAIN/bin/$target-as
ln -sf $TOOLCHAIN/bin/${target}31-clang++ $TOOLCHAIN/bin/$target-g++
ln -sf $TOOLCHAIN/bin/ld $TOOLCHAIN/bin/$target-ld
done
## add empty libpthread librt
for path in $(find $ANDROID_NDK_HOME -name libc.so -exec dirname {} \;); do
touch $path/libpthread.so
touch $path/libpthread.a
touch $path/librt.so
touch $path/librt.a
done
# golang
version=$(curl https://go.dev/dl/ | grep -m1 -Eo "go[.0-9]+linux-amd64.tar.gz")
rm -rf /usr/local/go
curl -L "https://dl.google.com/go/$version" | tar xz -C "/usr/local"
sed -i '/GOROOT/d' ~/.bashrc
echo 'export GOROOT="/usr/local/go" PATH="$PATH:/usr/local/go/bin:'$HOME'/go/bin" GOPATH="'$HOME'/go" GOBIN="'$HOME'/go/bin"' >>~/.bashrc
. ~/.bashrc
mkdir -p $GOPATH/src $GOPATH/pkg $GOPATH/bin
#install openwrt-mips-sdk
curl -L "https://www.pangubox.com/pandorabox/19.01/targets/ralink/mt7620/PandoraBox-SDK-ralink-mt7620_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64-2018-12-31-git-4b6a3d5ca.tar.xz" | tar xJ
mv PandoraBox-SDK-ralink-mt7620_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64-2018-12-31-git-4b6a3d5ca /usr/local/openwrt-mips
export PATH="$PATH:/usr/local/openwrt-mips/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.5.0_uClibc-1.0.x/bin"
echo 'export PATH="$PATH:/usr/local/openwrt-mips/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.5.0_uClibc-1.0.x/bin"' >>~/.bashrc
#musl toolchain
for chain in x86_64-linux-musl-native i686-linux-musl-native mipsel-linux-musl-cross mips-linux-musl-cross mips64el-linux-musl-cross mips64-linux-musl-cross aarch64-linux-musl-cross arm-linux-musleabi-cross; do
curl -O "http://musl.cc/$chain.tgz"
rm -rf /usr/local/$chain
tar xf $chain.tgz -C /usr/local
rm -f $chain.tgz
sed -i "/$chain/d" ~/.bashrc
echo "export PATH=\$PATH:/usr/local/$chain/bin" >>~/.bashrc
. ~/.bashrc
done
# libressl 与 openssl 的兼容性不好
# curl -L "https://github.com/libressl-portable/portable/archive/refs/tags/v3.3.3.tar.gz" | tar xz
# cd portable-3.3.3
# ./autogen.sh
# ## build
# for host in armv7a-linux-androideabi \
# aarch64-linux-android \
# i686-linux-gnu \
# x86_64-linux-gnu; do
# ./configure --host $host --disable-shared --prefix=/usr/local/cross-compile/$host &&
# make -j $(nproc) &&
# make install
# make clean >/dev/null 2>&1
# done
## clean
rm -rf $(pwd)
cd ..
# boringssl
git clone https://boringssl.googlesource.com/boringssl
cd boringssl
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
rm -f CMakeCache.txt
cmake -DCMAKE_SYSTEM_PROCESSOR=${host%%-*} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_C_COMPILER=$host-gcc \
-DCMAKE_CXX_COMPILER=$host-g++ \
-DCMAKE_INSTALL_PREFIX=/usr/local/cross-compile/$host . &&
make crypto ssl -j $(nproc) &&
cp -rf ./include/openssl/ /usr/local/cross-compile/$host/include/ &&
cp -f ./ssl/libssl.a ./crypto/libcrypto.a /usr/local/cross-compile/$host/lib/
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# lzo
curl -L "http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz" | tar xz
cd lzo-2.10
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host $host --disable-shared --prefix=/usr/local/cross-compile/$host &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# lz4
curl -L "https://github.com/lz4/lz4/archive/v1.9.2.tar.gz" | tar xz
cd lz4-1.9.2
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
make CC=$host-gcc -j $(nproc) &&
make install PREFIX=/usr/local/cross-compile/$host
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# pkcs11-helper
curl -L "https://github.com/OpenSC/pkcs11-helper/releases/download/pkcs11-helper-1.27/pkcs11-helper-1.27.0.tar.bz2" | tar xj
cd pkcs11-helper-1.27.0
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host $host --disable-shared --prefix=/usr/local/cross-compile/$host \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# openvpn
git clone https://github.com/OpenVPN/openvpn.git
cd openvpn
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host $host --prefix=/usr/local/cross-compile/$host \
--disable-shared --enable-lzo --enable-pkcs11 \
--disable-plugin-auth-pam --disable-plugin-down-root --disable-unit-tests \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" \
PKG_CONFIG_LIBDIR="/usr/local/cross-compile/$host/lib/pkgconfig" &&
make LIBS='-all-static' -j $(nproc) &&
make install-strip
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# pcre
curl -L "https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz" | tar xz
cd pcre-8.43
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host $host --disable-shared --prefix=/usr/local/cross-compile/$host CFLAGS='-fPIC' &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# zlib
curl -L "https://zlib.net/fossils/zlib-1.2.11.tar.gz" | tar xz
cd zlib-1.2.11
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
CC=$host-gcc AR=$host-ar RANLIB=$host-ranlib CFLAGS='-fPIC' \
./configure --static --prefix=/usr/local/cross-compile/$host &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# lighttpd
curl -L "https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.59.tar.gz" | tar xz
cd lighttpd-1.4.59
./autogen.sh
## edit
sed -i 's|ifdef _DIRENT_HAVE_D_TYPE|ifdef _ABCD_DIRENT_HAVE_D_TYPE|g' ./src/mod_webdav.c
mods=$(sed -n '/^do_build=/,/^"/p' ./configure | perl -ne 'print "$1\n" while /(mod_\w+)/g')
check_mods=$(perl -e 'undef $/; while(<>){ print $1 if /lighttpd_SOURCES(.*?)lighttpd_CPPFLAGS/s; }' src/Makefile.am)
echo -n '' >src/plugin-static.h
for mod in $mods; do
echo "PLUGIN_INIT($mod)" >>src/plugin-static.h
if ! echo "$check_mods" | grep -q $mod; then
sed -i "s|^lighttpd_SOURCES =|lighttpd_SOURCES = $mod.c|" src/Makefile.am
fi
done
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
LIGHTTPD_STATIC=yes CPPFLAGS=-DLIGHTTPD_STATIC ./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" \
--with-openssl --with-zlib &&
make LIBS='-ldl -all-static' -j $(nproc) &&
make install-strip
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# apache
ac_cv_file__dev_zero=yes \
ac_cv_func_setpgrp_void=yes \
apr_cv_process_shared_works=yes \
apr_cv_mutex_robust_shared=yes \
apr_cv_tcp_nodelay_with_cork=yes \
ap_cv_void_ptr_lt_long=no
# libxml2
curl -L "http://xmlsoft.org/download/libxml2-2.9.12.tar.gz" | tar xz
cd libxml2-2.9.12
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared --without-lzma --without-python \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# sqlite3
curl -L "https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz" | tar xz
cd sqlite-autoconf-3360000
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# php
curl -L "https://www.php.net/distributions/php-7.4.23.tar.gz" | tar xz
cd php-7.4.23
## edit
sed -i 's|getdtablesize()|sysconf(_SC_OPEN_MAX)|g' ./ext/standard/php_fopen_wrapper.c
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host \
--disable-shared --disable-phpdbg --disable-cgi \
--with-openssl --with-zlib --with-pcre-jit --enable-bcmath --enable-calendar --enable-mbstring \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" &&
sed -i "s|/usr/include|/usr/local/cross-compile/$host/include|g" ./Makefile &&
make LDFLAGS="-L/usr/local/cross-compile/$host/lib -ldl -all-static" -j $(nproc)
$host-strip sapi/cli/php &&
mv sapi/cli/php /usr/local/cross-compile/$host/bin
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# dnsmasq
curl -L "http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.85.tar.gz" | tar xz
cd dnsmasq-2.85
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
LDFLAGS="-static" && echo "$host" | grep -q "android" && LDFLAGS="-llog"
make CC=$host-gcc CFLAGS="-D__USE_BSD" LDFLAGS="-s $LDFLAGS" -j $(nproc)
mv src/dnsmasq /usr/local/cross-compile/$host/bin
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
#android busybox
tar xf github/busybox.tar.gz
cd busybox-1.30.1
make menuconfig -j $(nproc)
make -j $(nproc)
mv busybox ..
cd ..
tar -czf github/busybox.tar.gz busybox-1.30.1
rm -rf busybox-1.30.1
# libevent2
curl -L "https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz" | tar xz
cd libevent-2.1.12-stable
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib"
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# redsocks
git clone https://github.com/darkk/redsocks.git
cd redsocks
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
make CC=$host-gcc -j $(nproc) \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-s -static -L/usr/local/cross-compile/$host/lib"
mv redsocks /usr/local/cross-compile/$host/bin
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# pdnsd
curl -L "https://fossies.org/linux/misc/dns/pdnsd-1.2.9a-par.tar.gz" | tar xz
cd pdnsd-1.2.9a
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host \
LDFLAGS='-s -static'
make -j $(nproc)
mv src/pdnsd /usr/local/cross-compile/$host/bin
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# libssh2
curl -L "https://github.com/libssh2/libssh2/releases/download/libssh2-1.10.0/libssh2-1.10.0.tar.gz" | tar xz
cd libssh2-1.10.0
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared --disable-examples-build \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib"
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# libcurl
git clone https://github.com/curl/curl.git
cd curl
## build
autoreconf -fi
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --with-openssl --with-libssh2 --disable-shared \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib"
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# libzip
curl -L "https://github.com/nih-at/libzip/releases/download/v1.8.0/libzip-1.8.0.tar.gz" | tar xz
cd libzip-1.8.0
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
CC=$host-gcc \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" \
cmake -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local/cross-compile/$host \
-DBUILD_TOOLS=OFF \
-DBUILD_EXAMPLES=OFF .
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# libonig
curl -L "https://github.com/kkos/oniguruma/releases/download/v6.9.7.1/onig-6.9.7.1.tar.gz" | tar xz
cd onig-6.9.7
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# libuv
curl -L "https://github.com/libuv/libuv/archive/v1.42.0.tar.gz" | tar xz
cd libuv-1.42.0
./autogen.sh
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# smartdns
git clone https://github.com/pymumu/smartdns.git
cd smartdns
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-s -static -L/usr/local/cross-compile/$host/lib" \
./package/build-pkg.sh \
--platform linux \
--arch=$host \
--cross-tool $host-
mv ./src/smartdns /usr/local/cross-compile/$host/bin/
done
## clean
rm -rf $(pwd)
cd ..
# zstd
git clone https://github.com/facebook/zstd.git
cd zstd/
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
CC=$host-gcc \
CXX=$host-g++ \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-L/usr/local/cross-compile/$host/lib" \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/cross-compile/$host \
-DZSTD_BUILD_STATIC=ON \
-DZSTD_BUILD_SHARED=OFF \
./build/cmake/ &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
#v2ray 手动构建
https://github.com/golang/go/issues/8877#issuecomment-300937986
sed -i 's|^+||g' /usr/local/go/src/net/dnsconfig_unix.go
rm -rf v2ray-core
git clone https://github.com/v2fly/v2ray-core.git
cd v2ray-core && go mod download
sed -i '220iif strings.Compare(domain, "res.res.res.res") != 0 {' app/dispatcher/default.go
sed -i '224i}' app/dispatcher/default.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o $HOME/v2ray_arm -trimpath -ldflags "-s -w -buildid=" ./main
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $HOME/v2ray_arm64 -trimpath -ldflags "-s -w -buildid=" ./main
curl -O 'https://raw.githubusercontent.com/v2ray/geoip/master/main.go'
go build main.go && mv main /bin/geoip
curl -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=JvbzLLx7qBZT&suffix=zip" | bsdtar -xf-
mv GeoLite2* geoip
cd geoip
sed -i '2,$d' GeoLite2-Country-Locations-en.csv
echo '1814991,en,AS,Asia,CN,China,0' >>GeoLite2-Country-Locations-en.csv
sed -i '2,$d' GeoLite2-Country-Blocks-IPv6.csv
awk -F',' '{if($3==1814991){print $0}}' GeoLite2-Country-Blocks-IPv4.csv >a
sed -i '2,$d' GeoLite2-Country-Blocks-IPv4.csv
cat a >>GeoLite2-Country-Blocks-IPv4.csv
geoip --country=GeoLite2-Country-Locations-en.csv --ipv4=GeoLite2-Country-Blocks-IPv4.csv --ipv6=GeoLite2-Country-Blocks-IPv6.csv
#x64 json-c
git clone https://github.com/json-c/json-c.git
cd json-c
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
CC=$host-gcc \
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/cross-compile/$host \
-DBUILD_SHARED_LIBS=OFF . &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# expat
git clone https://github.com/libexpat/libexpat.git
cd libexpat
## build
autoreconf -fi ./expat
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./expat/configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# c-ares
git clone https://github.com/c-ares/c-ares.git
cd c-ares
## build
autoreconf -fi
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host --prefix=/usr/local/cross-compile/$host --disable-shared &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# aria2c
git clone https://github.com/aria2/aria2.git
cd aria2
## build
autoreconf -fi
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
./configure --host=$host \
--prefix=/usr/local/cross-compile/$host \
--without-libxml2 \
ARIA2_STATIC=yes \
CFLAGS="-I/usr/local/cross-compile/$host/include" \
CXXFLAGS="-I/usr/local/cross-compile/$host/include" \
LDFLAGS="-s -L/usr/local/cross-compile/$host/lib" &&
make -j $(nproc) &&
make install
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
# LuaJIT
git clone https://github.com/LuaJIT/LuaJIT.git
cd LuaJIT
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
if
echo 'void main(){}' | $host-gcc -x c -
file a.out | grep -q '32-bit'
then
HOST_CC=i686-linux-gnu-gcc
else
HOST_CC=x86_64-linux-gnu-gcc
fi
make HOST_CC=$HOST_CC CROSS=$host- LDFLAGS='-static' BUILDMODE=static -j $(nproc) &&
make install PREFIX=/usr/local/cross-compile/$host &&
mv /usr/local/cross-compile/$host/bin/luajit* /usr/local/cross-compile/$host/bin/luajit
make clean >/dev/null 2>&1
done
## env
sed -i '/LUA_PATH/d' ~/.bashrc
cat >>~/.bashrc <<EOF
# LUA_PATH
export LUA_PATH=/usr/local/cross-compile/x86_64-linux-gnu/share/luajit-2.1.0-beta3/?.lua
EOF
. ~/.bashrc
## clean
rm -rf $(pwd)
cd ..
# wrk
git clone https://github.com/wg/wrk.git
cd wrk
## build
for host in armv7a-linux-androideabi \
aarch64-linux-android \
i686-linux-gnu \
x86_64-linux-gnu; do
make CC=$host-gcc -j $(nproc) \
LDFLAGS="-static -L/usr/local/cross-compile/$host/lib" \
CFLAGS="-I/usr/local/cross-compile/$host/include -I/usr/local/cross-compile/$host/include/luajit-2.1" \
WITH_LUAJIT=/usr/local/cross-compile/$host \
WITH_OPENSSL=/usr/local/cross-compile/$host &&
mv wrk /usr/local/cross-compile/$host/bin
make clean >/dev/null 2>&1
done
## clean
rm -rf $(pwd)
cd ..
#x64 libmnl
wget "https://netfilter.org/projects/libmnl/files/libmnl-1.0.4.tar.bz2"
tar xf libmnl-1.0.4.tar.bz2
cd libmnl-1.0.4
./configure --enable-static
make install-strip -j $(nproc)
rm -rf $(pwd)
cd ..
#android libmnl
wget "https://netfilter.org/projects/libmnl/files/libmnl-1.0.4.tar.bz2"
tar xf libmnl-1.0.4.tar.bz2
cd libmnl-1.0.4
#arm
./configure --host=arm-linux-androideabi --prefix=/usr/local/cross-compile/android-arm --enable-static
make install-strip -j $(nproc)
make clean >/dev/null 2>&1
#arm64
./configure --host=aarch64-linux-android --prefix=/usr/local/cross-compile/android-arm64 --enable-static
make install-strip -j $(nproc)
rm -rf $(pwd)
cd ..
#x64 wg
git clone git://git.zx2c4.com/wireguard-tools
cd wireguard-tools/src
make LDLIBS='-s -l:libmnl.a' -j $(nproc)
mv wg ../..
cd ../..
rm -rf wireguard-tools
#x64 wget
curl -L "http://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz" | tar xz
cd wget-1.20.3
./configure --with-ssl=openssl
make install-strip -j $(nproc)
rm -rf $(pwd)
cd ..
#x64 boost
curl -L "https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz" | tar xz
cd boost_1_79_0
./bootstrap.sh --with-libraries=all --with-toolset=gcc
./b2 toolset=gcc threading=multi
./b2 install
ldconfig
rm -rf $(pwd)
cd ..
#android boost
curl -L "https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz" | tar xz
cd boost_1_79_0
#arm
./bootstrap.sh --with-libraries=all --prefix=/usr/local/cross-compile/android-arm
sed -i 's|using gcc.*|using gcc : : /usr/local/android-arm/bin/arm-linux-androideabi-gcc ;' project-config.jam
./b2 threading=multi
./b2 install
#arm64
./bootstrap.sh --with-libraries=all --prefix=/usr/local/cross-compile/android-arm64
sed -i 's|using gcc.*|using gcc : : /usr/local/android-aarch64/bin/aarch64-linux-android-gcc ;' project-config.jam
./b2 threading=multi
./b2 install
rm -rf $(pwd)
cd ..
#精简 boost
curl -L "https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz" | tar xz
cd boost_1_79_0
./bootstrap.sh
./b2 tools/bcp
mkdir boost_
./dist/bin/bcp boost/asio.hpp boost_
./dist/bin/bcp boost/property_tree/ptree.hpp boost_
./dist/bin/bcp boost/property_tree/json_parser.hpp boost_
#android arm iproute2
curl -L "https://github.com/shemminger/iproute2/archive/v5.1.0.tar.gz" | tar xz
cd iproute2-5.1.0
sed -i 's/SUBDIRS=.*/SUBDIRS=lib ip/' Makefile
make CC=arm-linux-androideabi-gcc LDFLAGS=-s -j4
#asio
curl -L "http://downloads.sourceforge.net/project/asio/asio/1.18.0 (Stable)/asio-1.18.0.tar.gz" | tar xz
cd asio-1.18.0/
./configure --without-boost
# android dropbear ./dropbear -r ./dropbear_rsa_host_key -F -G root -U root -p 0.0.0.0:1122 -a -A -T ./public_key -s
curl -L "https://github.com/mkj/dropbear/archive/DROPBEAR_2018.76.tar.gz" | tar xz
cd dropbear-DROPBEAR_2018.76/
curl -OL "https://raw.githubusercontent.com/ubiquiti/dropbear-android/master/android-compat.patch"
curl -OL "https://raw.githubusercontent.com/ubiquiti/dropbear-android/master/config.guess"
curl -OL "https://raw.githubusercontent.com/ubiquiti/dropbear-android/master/config.sub"
autoreconf
patch -p1 <android-compat.patch
./configure --host=arm-linux-gnueabi --disable-utmp --disable-wtmp --disable-utmpx --disable-zlib --disable-syslog
make LDFLAGS=-static -j $(nproc)
cp dropbear dropbearkey dropbearconvert dbclient ..
arm-linux-gnueabi-strip dropbear dropbearkey dropbearconvert dbclient
rm -rf $(pwd)
cd ..
# dropbear
curl -L 'https://github.com/mkj/dropbear/archive/refs/tags/DROPBEAR_2022.82.tar.gz' | tar xz
cd dropbear-DROPBEAR_2022.82
LDFLAGS='-s' ./configure --host=$host --enable-static --disable-zlib --disable-harden
make -j$(nproc)
# wsl2 kernel
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel
apt install g++ make flex bison libssl-dev libelf-dev bc -y
make KCONFIG_CONFIG=Microsoft/config-wsl menuconfig # 图形化的安装界面,键入 / 进行搜索,NETFILTER_XTABLES
make KCONFIG_CONFIG=Microsoft/config-wsl bzImage -j $(nproc)
cp arch/x86/boot/bzImage ../kernel
rm -rf $(pwd)
cd ..
# openwrt
## 公钥登录
## 宽带
## WIFI
## dnsmasq 并发
## WiFi定时关闭
## ssh内网穿透
## 拨号脚本 + DDNS
## 增加 kmod-mtd-rw
## 增加 luci-app-usb-printer