forked from huahua132/skynet_fly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_centos.sh
117 lines (104 loc) · 2.49 KB
/
install_centos.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
#!/bin/bash
# 安装编译skynet依赖的一些库
install_dependencies() {
yum install -y git gcc autoconf automake make libtool curl centos-release-scl devtoolset-9-gcc* perl* cpan sudo
# centos8以上 dnf -y group install "Development Tools"
}
# 安装Perl
install_perl() {
chmod -R 744 "3rd/perl"
cd "3rd/perl" || exit
(
source /opt/rh/devtoolset-9/enable
echo $HOME
./Configure -des -Dprefix=$HOME/localperl
make -j4
make install
)
if [ -f /usr/bin/perl ]; then
sudo mv /usr/bin/perl /usr/bin/perl.old && echo "Moved perl successfully" || {
echo -e "\033[31m Failed to move perl \033[0m"
exit 1
}
fi
sudo cp -f $HOME/localperl/bin/perl /usr/local/bin/perl && echo "Copied perl successfully" || {
echo -e "\033[31m Failed to copy perl \033[0m"
exit 1
}
sudo ln -s /usr/local/bin/perl /usr/bin/perl && echo "Created symlink successfully" || {
echo -e "\033[31m Failed to create symlink \033[0m"
exit 1
}
echo "Perl $perl_version has been installed and linked successfully."
cd ../../
}
# 编译openssl-3.4.0
install_openssl() {
# 获取脚本当前目录
CURRENT_DIR="$(dirname "$BASH_SOURCE")"
ABSOLUTE_PATH="$(realpath "$CURRENT_DIR/3rd/openssl")"
chmod -R 744 "3rd/openssl"
cd "3rd/openssl" || exit
(
rm -f *.a
echo "ABSOLUTE_PATH:$ABSOLUTE_PATH"
# 激活 devtoolset-9
source /opt/rh/devtoolset-9/enable && echo "Enabled devtoolset-9 successfully" || {
echo -e "\033[31m Failed to enable devtoolset-9 \033[0m"
exit 1
}
# 配置 OpenSSL
./config --prefix="$ABSOLUTE_PATH" -fPIC no-shared && echo "OpenSSL configured successfully" || {
echo -e "\033[31m OpenSSL configuration failed \033[0m"
exit 1
}
# 编译
make -j4 && echo "Make completed successfully" || {
echo -e "\033[31m Make failed \033[0m"
exit 1
}
echo -e "\033[32m OpenSSL installed successfully! \033[0m"
)
cd ../../
}
# 编译zlib-1.3.1
install_zlib() {
chmod -R 744 "3rd/zlib"
cd "3rd/zlib" || exit
(
rm -f *.o libz.*
source /opt/rh/devtoolset-9/enable
./configure
make -j4
)
cd ../../
}
# 编译
compile() {
git submodule update --init
chmod -R 744 skynet
(
make cleanall
source /opt/rh/devtoolset-9/enable
make linux -j4
)
}
# 还原perl环境
revert_perl() {
(
sudo mv /usr/bin/perl.old /usr/bin/perl && echo "revert perl successfully" || {
echo -e "\033[31m Failed to revert perl \033[0m"
exit 1
}
)
}
# 主程序
main() {
install_dependencies
install_perl
install_openssl
install_zlib
compile
revert_perl
}
main