-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcedar-14.sh
executable file
·186 lines (167 loc) · 3.78 KB
/
cedar-14.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
#!/bin/bash
exec 2>&1
set -e
set -x
# 使用阿里云镜像
sed -i -e 's/ports.ubuntu.com/mirrors.aliyun.com/g' \
-e 's/archive.ubuntu.com/mirrors.aliyun.com/g' \
-e 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list \
&& apt-get update
if [ $(arch) == "x86_64" ];then
apt-get install -y --force-yes \
autoconf \
bind9-host \
bison \
build-essential \
coreutils \
daemontools \
dnsutils \
ed \
git \
imagemagick \
language-pack-en \
libbz2-dev \
libcurl4-openssl-dev \
libevent-dev \
libglib2.0-dev \
libjpeg-dev \
libmysqlclient-dev \
libncurses5-dev \
libpq-dev \
libpq5 \
libreadline6-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
libffi6 \
libffi-dev \
netcat-openbsd \
openssh-client \
openssh-server \
python-imaging \
ruby \
ruby-dev \
syslinux \
tar \
zip vim curl \
zlib1g-dev \
libsqlite3-dev \
libfreetype6-dev \
libpng12-dev \
libXpm-dev \
freetds-dev \
libsasl2-dev \
language-pack-zh-hans \
language-pack-zh-hant \
language-pack-en \
libmcrypt-dev \
libmcrypt4 \
libmemcached10
elif [ $(arch) == "aarch64" ];then
apt-get install -y --force-yes \
autoconf \
bind9-host \
bison \
build-essential \
coreutils \
daemontools \
dnsutils \
ed \
git \
imagemagick \
language-pack-en \
libbz2-dev \
libcurl4-openssl-dev \
libevent-dev \
libglib2.0-dev \
libjpeg-dev \
libmysqlclient-dev \
libncurses5-dev \
libpq-dev \
libpq5 \
libreadline6-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
libffi6 \
libffi-dev \
openssh-client \
openssh-server \
python-imaging \
syslinux-common \
ruby \
ruby-dev \
tar \
zip vim curl \
zlib1g-dev \
libsqlite3-dev \
libfreetype6-dev \
libpng12-dev \
libXpm-dev \
freetds-dev \
libsasl2-dev \
language-pack-zh-hans \
language-pack-zh-hant \
language-pack-en \
libmcrypt-dev \
libmcrypt4 \
libmemcached10 \
libmagickwand-dev \
libmagickcore-dev
fi
# 解决python的PIL包无法找到lib问题
ln -s /lib/$(arch)-linux-gnu/libz.so.1 /lib/
ln -s /usr/lib/$(arch)-linux-gnu/libfreetype.so.6 /usr/lib/
ln -s /usr/lib/$(arch)-linux-gnu/libjpeg.so.62 /usr/lib/
# 解决php-5.3编译依赖问题
ln -s /usr/lib/$(arch)-linux-gnu/libXpm.a /usr/lib/libXpm.a
ln -s /usr/lib/$(arch)-linux-gnu/libXpm.so /usr/lib/libXpm.so
ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
cd /
rm -rf /var/cache/apt/archives/*.deb
rm -rf /root/*
rm -rf /tmp/*
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf \
/usr/share/doc \
/usr/share/man \
/usr/share/info \
/usr/share/locale \
/var/lib/apt/lists/* \
/var/lib/dpkg/info/* \
/var/log/* \
/var/cache/debconf/* \
/var/cache/apt/archives/*.deb \
/etc/systemd \
/lib/lsb \
/lib/udev \
/usr/lib/x86_64-linux-gnu/gconv/IBM* \
/usr/lib/x86_64-linux-gnu/gconv/EBC* && \
bash -c "mkdir -p /usr/share/man/man{1..8}"
# remove SUID and SGID flags from all binaries
function pruned_find() {
find / -type d \( -name dev -o -name proc \) -prune -o $@ -print
}
pruned_find -perm /u+s | xargs -r chmod u-s
pruned_find -perm /g+s | xargs -r chmod g-s
# remove non-root ownership of files
chown root:root /var/lib/libuuid
# display build summary
set +x
echo -e "\nRemaining suspicious security bits:"
(
pruned_find ! -user root
pruned_find -perm /u+s
pruned_find -perm /g+s
pruned_find -perm /+t
) | sed -u "s/^/ /"
echo -e "\nInstalled versions:"
(
git --version
ruby -v
gem -v
python -V
) | sed -u "s/^/ /"
echo -e "\nSuccess!"
exit 0