-
Notifications
You must be signed in to change notification settings - Fork 0
/
virt-install.sh
111 lines (102 loc) · 3.55 KB
/
virt-install.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
#!/bin/ash
# https://github.com/sundaqiang/alpine-qinglong
#初始化
export LANG=UTF-8
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export SHELL=/bin/bash
export PS1="\u@\h:\w \$ "
export QL_DIR=/ql
#开启ssh、替换为bash
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config \
&& sed -i 's/root:x:0:0:root:\/root:\/bin\/ash/root:x:0:0:root:\/root:\/bin\/bash/g' /etc/passwd \
&& service sshd restart
#修改默认源
sed -i '2,$d' /etc/apk/repositories \
&& echo http://mirrors.aliyun.com/alpine/v3.15/main/ >> /etc/apk/repositories \
&& echo http://mirrors.aliyun.com/alpine/v3.15/community/ >> /etc/apk/repositories
#安装系统依赖
apk update -f \
&& apk upgrade \
&& apk --no-cache add -f bash \
coreutils \
moreutils \
git \
curl \
wget \
tzdata \
perl \
openssl \
nginx \
nodejs \
npm \
python3 \
jq \
openssh \
py3-pip \
python2 \
g++ \
make
rm -rf /var/cache/apk/*
#修改npm和pip镜像源
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/ \
&& pip config set install.trusted-host mirrors.aliyun.com \
&& npm config set registry https://registry.npmmirror.com
#其他设置
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& touch ~/.bashrc \
&& git config --global user.email "qinglong@@users.noreply.github.com" \
&& git config --global user.name "qinglong" \
&& git config --global http.postBuffer 524288000 \
&& npm install -g pnpm \
&& pnpm add -g pm2 ts-node typescript tslib \
&& cd / && pnpm install --prod \
&& rm -rf /root/.npm \
&& rm -rf /root/.pnpm-store \
&& rm -rf /root/.cache
#安装qinglong
QL_MAINTAINER="whyour"
QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
QL_BRANCH=develop
QL_DIR=/ql
rm -rf ${QL_DIR}
git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
&& cd ${QL_DIR} \
&& cp -f .env.example .env \
&& chmod 777 ${QL_DIR}/shell/*.sh \
&& chmod 777 ${QL_DIR}/docker/*.sh \
&& cp -rf /node_modules ./ \
&& rm -rf /node_modules \
&& pnpm install --prod \
&& pnpm install ts-node typescript tslib date-fns axios ts-node typescript png-js crypto-js md5 ts-md5 tslib @types/node tough-cookie jsdom tunnel fs ws js-base64 got \
&& pip3 install requests \
&& pip3 install download \
&& pip3 install canvas \
&& pip3 install telethon \
&& rm -rf /root/.npm \
&& rm -rf /root/.pnpm-store \
&& rm -rf /root/.cache \
&& apk --purge del python2 g++ make \
&& git clone -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \
&& mkdir -p ${QL_DIR}/static \
&& cp -rf /static/* ${QL_DIR}/static \
&& rm -rf /static
#配置启动项
echo '#!/bin/bash' > /etc/local.d/QL.start \
&& echo '# https://github.com/sundaqiang/alpine-qinglong' >> /etc/local.d/QL.start \
&& echo '' >> /etc/local.d/QL.start \
&& echo 'export LANG=UTF-8' >> /etc/local.d/QL.start \
&& echo 'export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' >> /etc/local.d/QL.start \
&& echo 'export SHELL=/bin/bash' >> /etc/local.d/QL.start \
&& echo 'export PS1="\u@\h:\w \$ "' >> /etc/local.d/QL.start \
&& echo 'export QL_DIR=/ql' >> /etc/local.d/QL.start \
&& echo 'cd /ql' >> /etc/local.d/QL.start \
&& echo 'rm -rf /var/cache/apk/*' >> /etc/local.d/QL.start \
&& echo 'rm -rf /root/.npm' >> /etc/local.d/QL.start \
&& echo 'rm -rf /root/.cache' >> /etc/local.d/QL.start \
&& echo 'rm -rf /root/.pnpm-store' >> /etc/local.d/QL.start \
&& echo 'nohup ./docker/docker-entrypoint.sh &' >> /etc/local.d/QL.start
chmod +x /etc/local.d/QL.start
rc-update add local
#启动qinglong
./docker/docker-entrypoint.sh