Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0dfa8afa44 | ||
![]() |
3fe6d5475e | ||
![]() |
b89da6715b | ||
![]() |
8df730200b | ||
![]() |
dd9befcd30 | ||
![]() |
6c77b8c2b9 | ||
![]() |
9d4a6b0d94 | ||
![]() |
ccdba79f39 | ||
![]() |
21a6d9f8d4 | ||
![]() |
c16e58d6af | ||
![]() |
3e00262bb5 | ||
![]() |
059280337d | ||
![]() |
6dbeed953b | ||
![]() |
c1b1d8749b | ||
![]() |
e76337a279 | ||
![]() |
d93c4bf0f7 | ||
![]() |
34b1e37bee | ||
![]() |
791c7fd497 | ||
![]() |
14a19fd4cf | ||
![]() |
0e7bb1d81b | ||
![]() |
64b63e0b3d | ||
![]() |
0171c8f1a7 | ||
![]() |
d72609ad4d | ||
![]() |
2536fafd20 | ||
![]() |
b916ca3611 | ||
![]() |
c4ba171095 | ||
![]() |
86df8d82dd | ||
![]() |
ff96ca34b8 | ||
![]() |
76a57bc4f1 | ||
![]() |
14f2f6f312 | ||
![]() |
2696b97d05 | ||
![]() |
a8981bd64e | ||
![]() |
dcc4f077f0 | ||
![]() |
f2173baad4 | ||
![]() |
4c04138e32 | ||
![]() |
0b517521b1 | ||
![]() |
eb6e8f8dda | ||
![]() |
e720b4e355 | ||
![]() |
373c0658c2 | ||
![]() |
d9cbf68384 | ||
![]() |
b016977fe8 | ||
![]() |
cd6a6e9b48 | ||
![]() |
451c68a393 | ||
![]() |
0f17616182 | ||
![]() |
4e66543487 |
102
.cnb.yml
102
.cnb.yml
@ -10,11 +10,12 @@ $:
|
|||||||
tags: cnb:arch:amd64
|
tags: cnb:arch:amd64
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest-linux-amd64
|
IMAGE_TAG: btpanel/baota:lamp-linux-amd64
|
||||||
stages:
|
stages:
|
||||||
- name: docker login
|
- name: docker login
|
||||||
script: docker login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
||||||
- name: docker build
|
- name: docker build
|
||||||
script: docker build -t ${IMAGE_TAG} .
|
script: docker build -t ${IMAGE_TAG} .
|
||||||
- name: docker push
|
- name: docker push
|
||||||
@ -26,14 +27,17 @@ $:
|
|||||||
|
|
||||||
- runner:
|
- runner:
|
||||||
tags: cnb:arch:arm64:v8
|
tags: cnb:arch:arm64:v8
|
||||||
|
cpus: 16
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest-linux-arm64
|
IMAGE_TAG: btpanel/baota:lamp-linux-arm64
|
||||||
stages:
|
stages:
|
||||||
- name: docker login
|
- name: docker login
|
||||||
script: docker login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
||||||
- name: docker build
|
- name: docker build
|
||||||
|
timeout: 3600s
|
||||||
script: docker build -t ${IMAGE_TAG} .
|
script: docker build -t ${IMAGE_TAG} .
|
||||||
- name: docker push
|
- name: docker push
|
||||||
script: docker push ${IMAGE_TAG}
|
script: docker push ${IMAGE_TAG}
|
||||||
@ -42,10 +46,14 @@ $:
|
|||||||
options:
|
options:
|
||||||
key: build-arm64
|
key: build-arm64
|
||||||
|
|
||||||
- services:
|
- runner:
|
||||||
|
tags: cnb:arch:amd64
|
||||||
|
cpus: 2
|
||||||
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest
|
IMAGE_TAG: btpanel/baota:lamp
|
||||||
stages:
|
stages:
|
||||||
- name: await the amd64
|
- name: await the amd64
|
||||||
type: cnb:await
|
type: cnb:await
|
||||||
@ -55,6 +63,80 @@ $:
|
|||||||
type: cnb:await
|
type: cnb:await
|
||||||
options:
|
options:
|
||||||
key: build-arm64
|
key: build-arm64
|
||||||
|
- name: manifest
|
||||||
|
image: cnbcool/manifest
|
||||||
|
settings:
|
||||||
|
username: $DOCKER_USERNAME
|
||||||
|
password: $DOCKER_PASSWD
|
||||||
|
target: ${IMAGE_TAG}
|
||||||
|
template: ${IMAGE_TAG}-OS-ARCH
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
- name: clear
|
||||||
|
image: lumir/remove-dockerhub-tag
|
||||||
|
args:
|
||||||
|
- --user
|
||||||
|
- $DOCKER_USERNAME
|
||||||
|
- --password
|
||||||
|
- $DOCKER_PASSWD
|
||||||
|
- ${IMAGE_TAG}-linux-amd64
|
||||||
|
- ${IMAGE_TAG}-linux-arm64
|
||||||
|
|
||||||
|
- runner:
|
||||||
|
tags: cnb:arch:amd64
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env:
|
||||||
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:lamp-linux-amd64
|
||||||
|
stages:
|
||||||
|
- name: docker login
|
||||||
|
script: docker login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
||||||
|
- name: docker build
|
||||||
|
script: docker build -t ${IMAGE_TAG} .
|
||||||
|
- name: docker push
|
||||||
|
script: docker push ${IMAGE_TAG}
|
||||||
|
- name: resolve
|
||||||
|
type: cnb:resolve
|
||||||
|
options:
|
||||||
|
key: cnb-build-amd64
|
||||||
|
|
||||||
|
- runner:
|
||||||
|
tags: cnb:arch:arm64:v8
|
||||||
|
cpus: 16
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env:
|
||||||
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:lamp-linux-arm64
|
||||||
|
stages:
|
||||||
|
- name: docker login
|
||||||
|
script: docker login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
||||||
|
- name: docker build
|
||||||
|
timeout: 3600s
|
||||||
|
script: docker build -t ${IMAGE_TAG} .
|
||||||
|
- name: docker push
|
||||||
|
script: docker push ${IMAGE_TAG}
|
||||||
|
- name: resolve
|
||||||
|
type: cnb:resolve
|
||||||
|
options:
|
||||||
|
key: cnb-build-arm64
|
||||||
|
|
||||||
|
- runner:
|
||||||
|
tags: cnb:arch:amd64
|
||||||
|
cpus: 2
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
env:
|
||||||
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:lamp
|
||||||
|
stages:
|
||||||
|
- name: await the amd64
|
||||||
|
type: cnb:await
|
||||||
|
options:
|
||||||
|
key: cnb-build-amd64
|
||||||
|
- name: await the arm64
|
||||||
|
type: cnb:await
|
||||||
|
options:
|
||||||
|
key: cnb-build-arm64
|
||||||
- name: manifest
|
- name: manifest
|
||||||
image: cnbcool/manifest
|
image: cnbcool/manifest
|
||||||
settings:
|
settings:
|
||||||
@ -65,3 +147,11 @@ $:
|
|||||||
platforms:
|
platforms:
|
||||||
- linux/amd64
|
- linux/amd64
|
||||||
- linux/arm64
|
- linux/arm64
|
||||||
|
- name: remove tag
|
||||||
|
type: artifact:remove-tag
|
||||||
|
options:
|
||||||
|
name: ${CNB_REPO_NAME}
|
||||||
|
tags:
|
||||||
|
- lamp-linux-amd64
|
||||||
|
- lamp-linux-arm64
|
||||||
|
type: docker
|
89
Dockerfile
89
Dockerfile
@ -1,13 +1,9 @@
|
|||||||
FROM debian:bookworm
|
FROM debian:bookworm
|
||||||
|
|
||||||
# 切换 Debian 镜像源为腾讯云源
|
# 切换 Debian 镜像源为腾讯云源,更新包列表并安装依赖
|
||||||
RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources
|
RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources \
|
||||||
|
&& apt update && apt upgrade -y \
|
||||||
# 更新包列表并升级系统中已经安装的软件包
|
&& apt install -y \
|
||||||
RUN apt update && apt upgrade -y
|
|
||||||
|
|
||||||
# 安装前置依赖
|
|
||||||
RUN apt install -y \
|
|
||||||
locales \
|
locales \
|
||||||
wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \
|
wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \
|
||||||
libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \
|
libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \
|
||||||
@ -15,53 +11,58 @@ RUN apt install -y \
|
|||||||
diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \
|
diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \
|
||||||
libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \
|
libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \
|
||||||
libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \
|
libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \
|
||||||
libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev
|
libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev iptables libudev-dev libldap2-dev \
|
||||||
|
&& apt clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# 配置区域设置
|
# 复制脚本
|
||||||
RUN locale-gen en_US.UTF-8
|
COPY ["bt.sh", "init_mysql.sh", "/"]
|
||||||
|
COPY ["phpmyadmin.sh", "/lamp/"]
|
||||||
|
|
||||||
ENV LANG en_US.UTF-8
|
# 转换启动脚本
|
||||||
ENV LANGUAGE en_US:en
|
RUN dos2unix /bt.sh && dos2unix /init_mysql.sh
|
||||||
ENV LC_ALL en_US.UTF-8
|
|
||||||
|
|
||||||
# 复制 bt.sh 文件
|
# 下载并安装宝塔面板及 lamp 环境
|
||||||
COPY bt.sh /bt.sh
|
|
||||||
|
|
||||||
# 转换 bt.sh 文件的换行符
|
|
||||||
RUN dos2unix /bt.sh
|
|
||||||
|
|
||||||
# 设置构建参数
|
|
||||||
ARG RANDOM_NAME
|
|
||||||
|
|
||||||
# 设置一个btd12-前缀的随机主机名
|
|
||||||
RUN echo "btd12-${RANDOM_NAME}" > /etc/hostname
|
|
||||||
|
|
||||||
# 下载并安装宝塔面板
|
|
||||||
RUN curl -sSO https://download.bt.cn/install/install_panel.sh \
|
RUN curl -sSO https://download.bt.cn/install/install_panel.sh \
|
||||||
&& echo y | bash install_panel.sh -P 8888 --ssl-disable
|
&& echo y | bash install_panel.sh -P 8888 --ssl-disable
|
||||||
|
|
||||||
# 配置宝塔面板安全入口和用户名及密码
|
RUN curl -o /lamp/apache.sh https://download.bt.cn/install/0/apache.sh \
|
||||||
|
&& sh /lamp/apache.sh install 2.4 \
|
||||||
|
&& curl -o /lamp/php.sh https://download.bt.cn/install/4/php.sh \
|
||||||
|
&& sh /lamp/php.sh install 8.3 \
|
||||||
|
&& curl -o /lamp/mysql.sh https://download.bt.cn/install/4/mysql.sh \
|
||||||
|
&& sh /lamp/mysql.sh install 8.0 \
|
||||||
|
&& sh /lamp/phpmyadmin.sh install 5.2 \
|
||||||
|
&& rm -rf /lamp \
|
||||||
|
&& rm -rf /www/server/php/83/src \
|
||||||
|
&& rm -rf /www/server/mysql/mysql-test \
|
||||||
|
&& rm -rf /www/server/mysql/src.tar.gz \
|
||||||
|
&& rm -rf /www/server/mysql/src \
|
||||||
|
&& rm -rf /www/server/data/* \
|
||||||
|
&& rm -rf /www/server/apache/src \
|
||||||
|
&& echo "docker_btlamp_d12" > /www/server/panel/data/o.pl \
|
||||||
|
&& echo '["memuA", "memuAsite", "memuAdatabase", "memuAcontrol", "memuAfiles", "memuAlogs", "memuAxterm", "memuAcrontab", "memuAsoft", "memuAconfig", "dologin", "memu_btwaf", "memuAssl"]' > /www/server/panel/config/show_menu.json \
|
||||||
|
&& apt clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& chmod +x /bt.sh \
|
||||||
|
&& chmod +x /init_mysql.sh
|
||||||
|
|
||||||
|
|
||||||
|
# 配置宝塔面板安全入口和用户名及密码,以及 SSH 密码
|
||||||
RUN echo btpanel | bt 6 \
|
RUN echo btpanel | bt 6 \
|
||||||
&& echo btpaneldocker | bt 5 \
|
&& echo btpaneldocker | bt 5 \
|
||||||
&& echo "/btpanel" > /www/server/panel/data/admin_path.pl
|
&& echo "/btpanel" > /www/server/panel/data/admin_path.pl \
|
||||||
|
&& echo "root:btpaneldocker" | chpasswd
|
||||||
|
|
||||||
# 设置 root 用户密码
|
# 打包宝塔面板,并清除www
|
||||||
RUN echo "root:btpaneldocker" | chpasswd
|
RUN bt 2 \
|
||||||
|
&& tar -zcf /www.tar.gz /www \
|
||||||
# 赋予 bt.sh 可执行权限
|
&& rm -rf /www
|
||||||
RUN chmod +x /bt.sh
|
|
||||||
|
|
||||||
# 清理缓存
|
|
||||||
RUN apt clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# 设置标识文件
|
|
||||||
RUN echo "dk_lib_test_d12" > /www/server/panel/data/o.pl
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh","-c","/bt.sh"]
|
ENTRYPOINT ["/bin/sh","-c","/bt.sh"]
|
||||||
|
|
||||||
# 暴漏所有端口
|
# 暴漏特定端口
|
||||||
EXPOSE 0-65535
|
EXPOSE 22 80 443 888 3306 8888
|
||||||
|
|
||||||
# 健康检查
|
# 健康检查
|
||||||
HEALTHCHECK --interval=5s --timeout=3s CMD curl -i http://127.0.0.1:$(cat /www/server/panel/data/port.pl)$(cat /www/server/panel/data/admin_path.pl) | grep -E '(200|404)' || exit 1
|
HEALTHCHECK --interval=5s --timeout=3s CMD prot="http"; if [ -f "/www/server/panel/data/ssl.pl" ]; then prot="https"; fi; curl -k -i $prot://127.0.0.1:$(cat /www/server/panel/data/port.pl)$(cat /www/server/panel/data/admin_path.pl) | grep -E '(200|404)' || exit 1
|
95
bt.sh
95
bt.sh
@ -1,5 +1,96 @@
|
|||||||
/etc/init.d/bt restart
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
init_path=/etc/init.d
|
||||||
|
Root_Path=`cat /var/bt_setupPath.conf`
|
||||||
|
Setup_Path=$Root_Path/server/mysql
|
||||||
|
Data_Path=$Root_Path/server/data
|
||||||
|
O_pl=$(cat /www/server/panel/data/o.pl)
|
||||||
|
|
||||||
|
backup_database() {
|
||||||
|
if [ -d "${Data_Path}" ] && [ ! -z "$(ls -A ${Data_Path})" ]; then
|
||||||
|
if [ ! -d "${Setup_Path}" ] || [ -z "$(ls -A ${Setup_Path})" ]; then
|
||||||
|
timestamp=$(date +"%s")
|
||||||
|
tar czf /www/server/data_backup_$timestamp.tar.gz -C ${Data_Path} .
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_panel_data() {
|
||||||
|
if [ -f /www.tar.gz ]; then
|
||||||
|
if [ ! -d /www ] || [ -z "$(ls -A /www)" ] || [ ! -d /www/server/panel ] || [ -z "$(ls -A /www/server/panel)" ] || [ ! -d /www/server/panel/pyenv ] || [ -z "$(ls -A /www/server/panel/pyenv)" ]; then
|
||||||
|
tar xzf /www.tar.gz -C / --skip-old-files
|
||||||
|
rm -rf /www.tar.gz
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
soft_start(){
|
||||||
|
# 扫描并启动所有服务
|
||||||
|
init_scripts=$(ls ${init_path})
|
||||||
|
for script in ${init_scripts}; do
|
||||||
|
case "${script}" in
|
||||||
|
"bt"|"mysqld"|"nginx"|"httpd")
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
${init_path}/${script} start
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f ${init_path}/nginx ]; then
|
||||||
|
${init_path}/nginx start
|
||||||
|
elif [ -f ${init_path}/httpd ]; then
|
||||||
|
${init_path}/httpd start
|
||||||
|
fi
|
||||||
|
|
||||||
|
${init_path}/bt stop
|
||||||
|
${init_path}/bt start
|
||||||
|
|
||||||
pkill crond
|
pkill crond
|
||||||
/sbin/crond
|
/sbin/crond
|
||||||
|
|
||||||
|
chmod 600 /etc/ssh/ssh_host_*
|
||||||
/usr/sbin/sshd -D &
|
/usr/sbin/sshd -D &
|
||||||
tail -f /dev/null
|
}
|
||||||
|
|
||||||
|
init_mysql(){
|
||||||
|
if [ "${O_pl}" != "docker_btlamp_d12" ] && [ "${O_pl}" != "docker_btlnmp_d12" ];then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -d "${Data_Path}" ]; then
|
||||||
|
check_z=$(ls "${Data_Path}")
|
||||||
|
echo "check_z:"
|
||||||
|
echo ${check_z}
|
||||||
|
if [[ ! -z "${check_z}" ]]; then
|
||||||
|
echo "check_z is not empty"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f /init_mysql.sh ] && [ -d "${Setup_Path}" ];then
|
||||||
|
sh /init_mysql.sh
|
||||||
|
rm -f /init_mysql.sh
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_empty_Data(){
|
||||||
|
return "$(ls -A ${Data_Path}/|wc -w)"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_mysql(){
|
||||||
|
if [ -d "${Setup_Path}" ] && [ -f "${init_path}/mysqld" ];then
|
||||||
|
chown -R mysql:mysql ${Data_Path}
|
||||||
|
chgrp -R mysql ${Setup_Path}/.
|
||||||
|
${init_path}/mysqld start
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_panel_data > /dev/null
|
||||||
|
backup_database > /dev/null
|
||||||
|
is_empty_Data > /dev/null
|
||||||
|
init_mysql > /dev/null
|
||||||
|
start_mysql > /dev/null
|
||||||
|
soft_start > /dev/null
|
||||||
|
#tail -f /dev/null
|
||||||
|
${init_path}/bt log
|
41
init_mysql.sh
Normal file
41
init_mysql.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
Root_Path=`cat /var/bt_setupPath.conf`
|
||||||
|
Setup_Path=$Root_Path/server/mysql
|
||||||
|
Data_Path=$Root_Path/server/data
|
||||||
|
|
||||||
|
Mysql_Initialize(){
|
||||||
|
if [ -d "${Data_Path}" ]; then
|
||||||
|
check_z=$(ls "${Data_Path}")
|
||||||
|
if [[ ! -z "${check_z}" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ${Data_Path}
|
||||||
|
chown -R mysql:mysql ${Data_Path}
|
||||||
|
chgrp -R mysql ${Setup_Path}/.
|
||||||
|
|
||||||
|
${Setup_Path}/bin/mysqld --initialize-insecure --basedir=${Setup_Path} --datadir=${Data_Path} --user=mysql
|
||||||
|
|
||||||
|
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
|
||||||
|
${Setup_Path}/lib
|
||||||
|
EOF
|
||||||
|
ldconfig
|
||||||
|
ln -sf ${Setup_Path}/lib/mysql /usr/lib/mysql
|
||||||
|
ln -sf ${Setup_Path}/include/mysql /usr/include/mysql
|
||||||
|
/etc/init.d/mysqld start
|
||||||
|
|
||||||
|
mysqlpwd=`cat /dev/urandom | head -n 16 | md5sum | head -c 16`
|
||||||
|
${Setup_Path}/bin/mysqladmin -u root password "${mysqlpwd}"
|
||||||
|
|
||||||
|
cd "${Setup_Path}"
|
||||||
|
rm -f src.tar.gz
|
||||||
|
rm -rf src
|
||||||
|
/etc/init.d/mysqld start
|
||||||
|
rm -rf /init_mysql.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
Mysql_Initialize
|
108
phpmyadmin.sh
Normal file
108
phpmyadmin.sh
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
public_file=/www/server/panel/install/public.sh
|
||||||
|
if [ ! -f $public_file ];then
|
||||||
|
wget -O $public_file https://download.bt.cn/install/public.sh -T 5;
|
||||||
|
fi
|
||||||
|
. $public_file
|
||||||
|
|
||||||
|
download_Url=$NODE_URL
|
||||||
|
Root_Path=`cat /var/bt_setupPath.conf`
|
||||||
|
Setup_Path=$Root_Path/server/phpmyadmin
|
||||||
|
webserver=""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Install_phpMyAdmin()
|
||||||
|
{
|
||||||
|
if [ -d "${Root_Path}/server/apache" ];then
|
||||||
|
webserver='apache'
|
||||||
|
elif [ -d "${Root_Path}/server/nginx" ];then
|
||||||
|
webserver='nginx'
|
||||||
|
elif [ -f "/usr/local/lsws/bin/lswsctrl" ];then
|
||||||
|
webserver='openlitespeed'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${webserver}" == "" ];then
|
||||||
|
echo "No Web server installed!"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
PHPVersion=""
|
||||||
|
for phpVer in 52 53 54 55 56 70 71 72 73 74 80 81 82 83;
|
||||||
|
do
|
||||||
|
if [ -d "/www/server/php/${phpVer}/bin" ]; then
|
||||||
|
PHPVersion=${phpVer}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z $PHPVersion ];then
|
||||||
|
echo "======================================"
|
||||||
|
echo "当前没有可用php,停止安装!"
|
||||||
|
echo "请先安装好php后再进行安装phpmyadmin!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget -O phpMyAdmin.zip $download_Url/src/phpMyAdmin-${1}.zip -T20
|
||||||
|
mkdir -p $Setup_Path
|
||||||
|
|
||||||
|
unzip -o phpMyAdmin.zip -d $Setup_Path/ > /dev/null
|
||||||
|
rm -f phpMyAdmin.zip
|
||||||
|
rm -rf $Root_Path/server/phpmyadmin/phpmyadmin*
|
||||||
|
|
||||||
|
|
||||||
|
phpmyadminExt=`cat /dev/urandom | head -n 32 | md5sum | head -c 16`;
|
||||||
|
mv $Setup_Path/databaseAdmin $Setup_Path/phpmyadmin_$phpmyadminExt
|
||||||
|
chmod -R 755 $Setup_Path/phpmyadmin_$phpmyadminExt
|
||||||
|
chown -R www.www $Setup_Path/phpmyadmin_$phpmyadminExt
|
||||||
|
chmod 755 /www/server/phpmyadmin
|
||||||
|
|
||||||
|
secret=`cat /dev/urandom | head -n 32 | md5sum | head -c 32`;
|
||||||
|
\cp -a -r $Setup_Path/phpmyadmin_$phpmyadminExt/config.sample.inc.php $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php
|
||||||
|
sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php
|
||||||
|
sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/libraries/config.default.php
|
||||||
|
|
||||||
|
echo $1 > $Setup_Path/version.pl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${webserver}" == "nginx" ];then
|
||||||
|
sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/nginx/conf/nginx.conf
|
||||||
|
rm -f $Root_Path/server/nginx/conf/enable-php.conf
|
||||||
|
\cp $Root_Path/server/nginx/conf/enable-php-$PHPVersion.conf $Root_Path/server/nginx/conf/enable-php.conf
|
||||||
|
sed -i "/pathinfo/d" $Root_Path/server/nginx/conf/enable-php.conf
|
||||||
|
if [ ! -f "/www/server/nginx/conf/enable-php.conf" ];then
|
||||||
|
touch /www/server/nginx/conf/enable-php.conf
|
||||||
|
fi
|
||||||
|
/etc/init.d/nginx reload
|
||||||
|
|
||||||
|
PMA_PORT=$(cat $Root_Path/server/nginx/conf/nginx.conf|grep "listen "|grep -oE '[0-9]+')
|
||||||
|
else
|
||||||
|
sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf
|
||||||
|
sed -i "0,/php-cgi/ s/php-cgi-\w*\.sock/php-cgi-${PHPVersion}.sock/" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf
|
||||||
|
/etc/init.d/httpd reload
|
||||||
|
|
||||||
|
PMA_PORT=$(cat /www/server/apache/conf/extra/httpd-vhosts.conf |grep "Listen "|grep -oE '[0-9]+')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ${PMA_PORT} > /www/server/phpmyadmin/port.pl
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstall_phpMyAdmin()
|
||||||
|
{
|
||||||
|
rm -rf $Root_Path/server/phpmyadmin/phpmyadmin*
|
||||||
|
rm -f $Root_Path/server/phpmyadmin/version.pl
|
||||||
|
rm -f $Root_Path/server/phpmyadmin/version_check.pl
|
||||||
|
}
|
||||||
|
|
||||||
|
actionType=$1
|
||||||
|
version=$2
|
||||||
|
|
||||||
|
if [ "$actionType" == 'install' ];then
|
||||||
|
Install_phpMyAdmin $version
|
||||||
|
elif [ "$actionType" == 'uninstall' ];then
|
||||||
|
Uninstall_phpMyAdmin
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user