feat: 新增根据环境变量修改用户名和密码的函数
This commit is contained in:
parent
37bcbde669
commit
e1ec3116cb
16
.cnb.yml
16
.cnb.yml
@ -12,7 +12,7 @@ $:
|
|||||||
- docker
|
- docker
|
||||||
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: btpanel/baota:nas-linux-amd64
|
IMAGE_TAG: btpanel/baota:fnnas-linux-amd64
|
||||||
stages:
|
stages:
|
||||||
- name: docker login
|
- name: docker login
|
||||||
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
||||||
@ -31,7 +31,7 @@ $:
|
|||||||
- docker
|
- docker
|
||||||
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: btpanel/baota:nas-linux-arm64
|
IMAGE_TAG: btpanel/baota:f n na s-linux-arm64
|
||||||
stages:
|
stages:
|
||||||
- name: docker login
|
- name: docker login
|
||||||
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWD"
|
||||||
@ -48,7 +48,7 @@ $:
|
|||||||
- docker
|
- docker
|
||||||
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
imports: https://cnb.cool/btpanel/secret/-/blob/main/docker.yml
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: btpanel/baota:nas
|
IMAGE_TAG: btpanel/baota:fnnas
|
||||||
stages:
|
stages:
|
||||||
- name: await the amd64
|
- name: await the amd64
|
||||||
type: cnb:await
|
type: cnb:await
|
||||||
@ -83,7 +83,7 @@ $:
|
|||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:nas-linux-amd64
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:fnnas-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 ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
||||||
@ -101,7 +101,7 @@ $:
|
|||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:nas-linux-arm64
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:fnnas-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 ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_DOCKER_REGISTRY}
|
||||||
@ -120,7 +120,7 @@ $:
|
|||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:nas
|
IMAGE_TAG: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:fnnas
|
||||||
stages:
|
stages:
|
||||||
- name: await the amd64
|
- name: await the amd64
|
||||||
type: cnb:await
|
type: cnb:await
|
||||||
@ -145,6 +145,6 @@ $:
|
|||||||
options:
|
options:
|
||||||
name: ${CNB_REPO_NAME}
|
name: ${CNB_REPO_NAME}
|
||||||
tags:
|
tags:
|
||||||
- nas-linux-amd64
|
- fnnas-linux-amd64
|
||||||
- nas-linux-arm64
|
- fnnas-linux-arm64
|
||||||
type: docker
|
type: docker
|
@ -25,7 +25,7 @@ RUN curl -sSO https://download.bt.cn/install/install_panel.sh \
|
|||||||
&& bash /lnmp/nginx.sh install 1.27 \
|
&& bash /lnmp/nginx.sh install 1.27 \
|
||||||
&& rm -rf /lnmp \
|
&& rm -rf /lnmp \
|
||||||
&& rm -rf /www/server/nginx/src \
|
&& rm -rf /www/server/nginx/src \
|
||||||
&& echo "docker_bt_nas" > /www/server/panel/data/o.pl \
|
&& echo "docker_bt_fnnas" > /www/server/panel/data/o.pl \
|
||||||
&& echo '["memuA", "memuAsite", "memuAwp", "memuAdatabase", "memuAcontrol", "memuAfiles", "memuAlogs", "memuAxterm", "memuAcrontab", "memuAsoft", "memuAconfig", "dologin", "memu_btwaf", "memuAssl"]' > /www/server/panel/config/show_menu.json \
|
&& echo '["memuA", "memuAsite", "memuAwp", "memuAdatabase", "memuAcontrol", "memuAfiles", "memuAlogs", "memuAxterm", "memuAcrontab", "memuAsoft", "memuAconfig", "dologin", "memu_btwaf", "memuAssl"]' > /www/server/panel/config/show_menu.json \
|
||||||
&& apt clean \
|
&& apt clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
44
bt.sh
44
bt.sh
@ -27,7 +27,6 @@ restore_panel_data() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
soft_start(){
|
soft_start(){
|
||||||
# 扫描并启动所有服务
|
|
||||||
init_scripts=$(ls ${init_path})
|
init_scripts=$(ls ${init_path})
|
||||||
for script in ${init_scripts}; do
|
for script in ${init_scripts}; do
|
||||||
case "${script}" in
|
case "${script}" in
|
||||||
@ -35,7 +34,6 @@ soft_start(){
|
|||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
${init_path}/${script} start
|
${init_path}/${script} start
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -56,15 +54,12 @@ soft_start(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_mysql(){
|
init_mysql(){
|
||||||
if [ "${O_pl}" != "docker_btlamp_nas" ] && [ "${O_pl}" != "docker_btlnmp_nas" ];then
|
if [ "${O_pl}" != "docker_btlamp_fnnas" ] && [ "${O_pl}" != "docker_btlnmp_fnnas" ];then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ -d "${Data_Path}" ]; then
|
if [ -d "${Data_Path}" ]; then
|
||||||
check_z=$(ls "${Data_Path}")
|
check_z=$(ls "${Data_Path}")
|
||||||
echo "check_z:"
|
|
||||||
echo ${check_z}
|
|
||||||
if [[ ! -z "${check_z}" ]]; then
|
if [[ ! -z "${check_z}" ]]; then
|
||||||
echo "check_z is not empty"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -86,6 +81,39 @@ start_mysql(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_bt_credentials() {
|
||||||
|
if [ -f "/www/server/panel/data/credentials_set" ]; then
|
||||||
|
echo "Credentials already set. Skipping."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$btuser" ] && [ -z "$btpwd" ]; then
|
||||||
|
echo "No credentials provided. Skipping."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Waiting for BT panel to be ready..."
|
||||||
|
while true; do
|
||||||
|
${init_path}/bt status >/dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
echo "Retrying..."
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$btuser" ]; then
|
||||||
|
echo "Updating username to $btuser..."
|
||||||
|
echo "$btuser" | ${init_path}/bt 6 || echo "Failed to update username."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$btpwd" ]; then
|
||||||
|
echo "Updating password..."
|
||||||
|
echo "$btpwd" | ${init_path}/bt 5 || echo "Failed to update password."
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch "/www/server/panel/data/credentials_set"
|
||||||
|
}
|
||||||
|
|
||||||
restore_panel_data > /dev/null
|
restore_panel_data > /dev/null
|
||||||
backup_database > /dev/null
|
backup_database > /dev/null
|
||||||
@ -93,5 +121,5 @@ is_empty_Data > /dev/null
|
|||||||
init_mysql > /dev/null
|
init_mysql > /dev/null
|
||||||
start_mysql > /dev/null
|
start_mysql > /dev/null
|
||||||
soft_start > /dev/null
|
soft_start > /dev/null
|
||||||
#tail -f /dev/null
|
check_bt_credentials > /dev/null
|
||||||
${init_path}/bt log
|
${init_path}/bt log
|
||||||
|
Loading…
x
Reference in New Issue
Block a user