-
Notifications
You must be signed in to change notification settings - Fork 86
/
libfuse_setup.sh
executable file
·228 lines (200 loc) · 5.63 KB
/
libfuse_setup.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
#!/bin/bash
YUM_OS_ARRAY=(Red Rocky Oracle Fedora CentOS AlmaLinux Alibaba Anolis Amazon)
get_gcc_version() {
old_lang=$LANG
LANG=en_US.UTF-8 && gcc -v 2>&1 | grep 'gcc version' | \
awk -F 'version' '{print $2}' | awk '{print $1}' | \
awk -F '.' '{print $1}'
LANG=$old_lang
}
apt_check_install_gcc() {
version=$1
pkg_gcc="gcc-$version"
pkg_cpp="g++-$version"
apt list $pkg_gcc 2>&1 | grep $pkg_gcc && apt install $pkg_gcc $pkg_cpp -y
}
apt_install_gcc() {
apt_check_install_gcc 7
if [ $? -ne 0 ]; then
apt_check_install_gcc 8
if [ $? -ne 0 ]; then
apt_check_install_gcc 9
fi
fi
}
apt_install_required_gcc() {
os_major_version=$1
apt install gcc g++ -y
if [ $? -ne 0 ]; then
apt_install_gcc $os_major_version
else
gcc_version=$(get_gcc_version)
if [ -z "$gcc_version" ] || [ "$gcc_version" -lt 4 ]; then
apt_install_gcc $os_major_version
fi
fi
}
yum_check_install_gcc() {
prefix=$1
version=$2
pkg_prefix="${prefix}toolset-${version}"
pkg_gcc="${pkg_prefix}-gcc"
pkg_cpp="${pkg_prefix}-gcc-c++"
yum list $pkg_gcc 2>&1 | grep "$pkg_gcc" && \
yum install $pkg_gcc $pkg_cpp -y && \
source /opt/rh/$pkg_prefix/enable
}
yum_install_gcc() {
os_major_version=$1
if [ $os_major_version -lt 8 ]; then
yum install centos-release-scl scl-utils-build -y
prefix='dev'
else
prefix='gcc-'
fi
yum_check_install_gcc "$prefix" 7
if [ $? -ne 0 ]; then
yum_check_install_gcc "$prefix" 8
if [ $? -ne 0 ]; then
yum_check_install_gcc "$prefix" 9
fi
fi
}
yum_install_required_gcc() {
os_major_version=$1
yum install gcc gcc-c++ -y
if [ $? -ne 0 ]; then
yum_install_gcc $os_major_version
else
gcc_version=$(get_gcc_version)
if [ -z "$gcc_version" ] || [ "$gcc_version" -lt 4 ]; then
yum_install_gcc $os_major_version
fi
fi
}
if [ -z "$LANG" ]; then
export LANG=en_US.UTF-8
fi
uname=$(uname)
if [ $uname = 'Linux' ]; then
osname=$(cat /etc/os-release | grep -w NAME | awk -F '=' '{print $2;}' | \
awk -F '"' '{if (NF==3) {print $2} else {print $1}}' | awk '{print $1}')
if [ $osname = 'CentOS' ]; then
osversion=$(cat /etc/system-release | awk '{print $4}')
fi
if [ -z $osversion ]; then
osversion=$(cat /etc/os-release | grep -w VERSION_ID | awk -F '=' '{print $2;}' | \
awk -F '"' '{if (NF==3) {print $2} else {print $1}}')
fi
os_major_version=$(echo $osversion | awk -F '.' '{print $1}')
if [ $osname = 'Fedora' ]; then
if [ $os_major_version -lt 20 ]; then
os_major_version=6
elif [ $os_major_version -lt 28 ]; then
os_major_version=7
elif [ $os_major_version -lt 34 ]; then
os_major_version=8
else
os_major_version=9
fi
elif [ $osname = 'Alibaba' ]; then
if [ $os_major_version -lt 3 ]; then
os_major_version=7
else
os_major_version=8
fi
elif [ $osname = 'Amazon' ]; then
if [ $os_major_version -le 2 ]; then
os_major_version=7
else
os_major_version=8
fi
fi
else
echo "Unsupport OS: $uname" 1>&2
exit 1
fi
if [[ " ${YUM_OS_ARRAY[@]} " =~ " ${osname} " ]] && [ $os_major_version -ge 7 ]; then
repo=$(rpm -q FastOSrepo 2>/dev/null)
if [ $? -ne 0 ]; then
if [ $os_major_version -eq 7 ]; then
rpm -ivh http://www.fastken.com/yumrepo/el7/x86_64/FastOSrepo-1.0.0-1.el7.centos.x86_64.rpm
else
rpm -ivh http://www.fastken.com/yumrepo/el8/x86_64/FastOSrepo-1.0.0-1.el8.x86_64.rpm
fi
fi
rpm -q fuse-devel >/dev/null && yum remove fuse-devel -y
rpm -q fuse >/dev/null && yum remove fuse -y
yum install fuse3-devel -y
exit 0
else
git_version=$(git --version 2>&1 | grep 'version' | awk '{print $3}')
make_version=$(make --version 2>&1 | grep 'Make' | awk '{print $3}')
PKG_CONFIG_PRG=$(which pkg-config 2>&1)
if [ $? -ne 0 ]; then
PKG_CONFIG_PRG=''
fi
gcc_version=$(get_gcc_version)
python_version=$(python3 --version 2>&1 | grep Python | awk '{print $2}')
pip3_version=$(pip3 --version 2>&1 | awk '{print $2}')
if [ $osname = 'Ubuntu' -o $osname = 'Debian' ]; then
if [ -z "$git_version" ]; then
apt install git -y
fi
if [ -z "$make_version" ]; then
apt install make -y
fi
dpkg -s libaio-dev >/dev/null 2>&1 || apt install libaio-dev -y
if [ -z "$PKG_CONFIG_PRG" ]; then
apt install pkg-config -y
fi
if [ -z "$python_version" ]; then
apt install python3 -y
fi
if [ -z "$pip3_version" ]; then
apt install python3-pip -y
fi
if [ -z "$gcc_version" ] || [ "$gcc_version" -lt 4 ]; then
apt_install_required_gcc
fi
else
if [ -z "$git_version" ]; then
yum install git -y
fi
if [ -z "$make_version" ]; then
yum install make -y
fi
if [ -z "$PKG_CONFIG_PRG" ]; then
yum install pkgconfig -y || yum install pkgconf-pkg-config -y
fi
if [ -z "$python_version" ]; then
yum install python3 -y || yum install python36 -y || yum install python38 -y || exit 2
fi
if [ -z "$pip3_version" ]; then
yum install python3-pip -y
fi
if [ -z "$gcc_version" ] || [ "$gcc_version" -lt 4 ]; then
yum_install_required_gcc
fi
fi
fi
MESON_PRG=$(which meson 2>&1)
if [ $? -ne 0 ]; then
pip3 install meson || exit
fi
NINJA_PRG=$(which ninja 2>&1)
if [ $? -ne 0 ]; then
pip3 install ninja || exit
fi
mkdir -p build; cd build
git clone https://gitee.com/mirrors/libfuse.git
cd libfuse/
git checkout fuse-3.10.1
rm -rf build/ && mkdir build/ && cd build/
meson ..
meson configure -D prefix=/usr
meson configure -D examples=false
ninja
ninja install
sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf
cd ..