Commit 6137f736 authored by Kunkka王辉's avatar Kunkka王辉 😲

安装脚本优化

parent 97b029c3
...@@ -36,11 +36,19 @@ PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[ ...@@ -36,11 +36,19 @@ PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[
function php7() function php7()
{ {
docker run --rm -it --network galaxy-net -v $(pwd):/app harbor.galaxy-immi.com/galaxy-open-develop/php:7.4 php "$@" docker run --rm -it -e LANG="C.UTF-8" -e LC_ALL="en_US.UTF-8" --network galaxy-net -v $(pwd):/app harbor.galaxy-immi.com/galaxy-open-develop/php:7.4 php "$@"
}
function php8()
{
docker run --rm -it -e LANG="C.UTF-8" LANG="en_US.UTF-8" -e LC_ALL="en_US.UTF-8" --network galaxy-net -v $(pwd):/app harbor.galaxy-immi.com/galaxy-open-develop/php:8.0 php "$@"
} }
function composer() function composer()
{ {
docker run --rm -it --network galaxy-net -v $(pwd):/app harbor.galaxy-immi.com/galaxy-open-develop/php:7.4 composer "$@" docker run --rm -it --network galaxy-net -v $(pwd):/app harbor.galaxy-immi.com/galaxy-open-develop/php:7.4 composer "$@"
} }
function mvn()
{
docker run --rm --entrypoint 'mvn' -v $(pwd):/app/code -w /app/code -v maven-repo:/usr/share/maven/repo harbor.galaxy-immi.com/galaxy-open-develop/java:11 "$@"
}
...@@ -69,7 +69,7 @@ services: ...@@ -69,7 +69,7 @@ services:
ports: ports:
- "${PORT:-8118}:8081" - "${PORT:-8118}:8081"
- "${PORT_CRM:-8181}:8181" - "${PORT_CRM:-8181}:8181"
- "8290:8290" # 老crm 转发 - "${PORT_CRM_CLIENT:-8290}:8290" # 老crm 转发
restart: on-failure restart: on-failure
java-notice: java-notice:
image: harbor.galaxy-immi.com/galaxy-open-develop/java:11 image: harbor.galaxy-immi.com/galaxy-open-develop/java:11
......
#!/bin/bash #!/bin/bash
# 获取本机ip 192 ip # 获取本机ip 192 ip
HOST_IP=$(hostname -I | grep -E "192\.168\.[0-9]+\.[0-9]+" -o) HOST_IP=$(hostname -I | grep -E "192\.168\.[0-9]+\.[0-9]+" -o)
# CRM_PORT,DWP_PORT,CRM_CLIENT_PORT
CRM_PORT=8181
DWP_PORT=8118
CRM_CLIENT_PORT=8290
check_port() {
if [[ $1 =~ ^[0-9]+$ ]]; then
if [ $1 -lt 49152 ] && [ $1 -gt 1023 ]; then
return 0
fi
fi
return 1
}
#是否使用默认端口
printf "是否使用默认端口:CRM:$CRM_PORT,DWP:$DWP_PORT,CRM_CLIENT:$CRM_CLIENT_PORT :[Y/N] ";
read x ;
if [ $x == "N" ]; then
printf "设置CRM_PORT【当前8181】:" && read CRM_PORT
check_port $CRM_PORT || echo "CRM_PORT必须是整数范围[1024-49152]" || exit
printf "设置DWP_PORT【当前8118】:" && read DWP_PORT
check_port $DWP_PORT || echo "DWP_PORT必须是整数[1024-49152]" || exit
printf "设置CRM_CLIENT_PORT 【当前8290】:" && read CRM_CLIENT_PORT
check_port $CRM_CLIENT_PORT || echo "CRM_CLIENT_PORT必须是整数[1024-49152]" || exit
fi
OS_IS_LINUX='yes' OS_IS_LINUX='yes'
if [ $(uname -o) != "GNU/Linux" ]; then OS_IS_LINUX='no'; fi if [ $(uname -o) != "GNU/Linux" ]; then OS_IS_LINUX='no'; fi
DOCKER_YES='yes' DOCKER_YES='yes'
...@@ -17,7 +44,7 @@ fi ...@@ -17,7 +44,7 @@ fi
DOCKER_COMPOSE_YES='yes' DOCKER_COMPOSE_YES='yes'
if [ ! $(command -v docker-compose) ] && [ "$COMPOSE_CMD" != 'docker compose' ]; then DOCKER_COMPOSE_YES='no'; fi if [ ! $(command -v docker-compose) ] && [ "$COMPOSE_CMD" != 'docker compose' ]; then DOCKER_COMPOSE_YES='no'; fi
PORT_YES='yes' PORT_YES='yes'
if ss -tpl | grep -E '8118|8181' >/dev/null; then PORT_YES='no'; fi if ss -tpl | grep -E "$CRM_PORT|$DWP_PORT|$CRM_CLIENT_PORT" >/dev/null; then PORT_YES='no'; fi
cat <<EOF cat <<EOF
检查环境: 检查环境:
1. 是否是linux系统 $OS_IS_LINUX 1. 是否是linux系统 $OS_IS_LINUX
...@@ -25,7 +52,7 @@ cat <<EOF ...@@ -25,7 +52,7 @@ cat <<EOF
3. git $GIT_YES 3. git $GIT_YES
4. docker-compose/docker compose $DOCKER_COMPOSE_YES 4. docker-compose/docker compose $DOCKER_COMPOSE_YES
5. tar $TAR_YES 5. tar $TAR_YES
6. 端口8118,8181是否可用 $PORT_YES 6. 端口$CRM_PORT,$DWP_PORT,$CRM_CLIENT_PORT是否可用 $PORT_YES
8. 本机IP $HOST_IP 8. 本机IP $HOST_IP
EOF EOF
if echo "$TAR_YES$GIT_YES$DOCKER_COMPOSE_YES$OS_IS_LINUX$DOCKER_YES$PORT_YES" | grep no >/dev/null; then if echo "$TAR_YES$GIT_YES$DOCKER_COMPOSE_YES$OS_IS_LINUX$DOCKER_YES$PORT_YES" | grep no >/dev/null; then
...@@ -54,9 +81,15 @@ rm -f data.tgz ...@@ -54,9 +81,15 @@ rm -f data.tgz
echo 'storage 目录权限处理' echo 'storage 目录权限处理'
find ./ -type d -name 'storage' -exec chmod -R 0777 {} + find ./ -type d -name 'storage' -exec chmod -R 0777 {} +
cd $CODE_DIR/crm cd $CODE_DIR/crm
grep -rlZ 192.168.11.163 ./ | xargs -0 sed -i "s/192.168.11.163/$HOST_IP/g"
grep -rlZ 192.168.11.163:8118 ./ | xargs -0 sed -i "s/192.168.11.163:8118/$HOST_IP:$DWP_PORT/g"
grep -rlZ 192.168.11.163:8181 ./ | xargs -0 sed -i "s/192.168.11.163:8181/$HOST_IP:$CRM_PORT/g"
grep -rlZ 192.168.11.163:8290 ./ | xargs -0 sed -i "s/192.168.11.163:8290/$HOST_IP:$CRM_CLIENT_PORT/g"
cd $CODE_DIR/dwp/main cd $CODE_DIR/dwp/main
grep -rlZ 192.168.11.163 ./ | xargs -0 sed -i "s/192.168.11.163/$HOST_IP/g" grep -rlZ 192.168.11.163:8118 ./ | xargs -0 sed -i "s/192.168.11.163:8118/$HOST_IP:$DWP_PORT/g"
grep -rlZ 192.168.11.163:8181 ./ | xargs -0 sed -i "s/192.168.11.163:8181/$HOST_IP:$CRM_PORT/g"
grep -rlZ 192.168.11.163:8290 ./ | xargs -0 sed -i "s/192.168.11.163:8290/$HOST_IP:$CRM_CLIENT_PORT/g"
cd $CODE_DIR/../ cd $CODE_DIR/../
git clone http://gitlab.galaxy-immi.com/kunkka.wh/docker-test.git $BUILD_DIR git clone http://gitlab.galaxy-immi.com/kunkka.wh/docker-test.git $BUILD_DIR
cd $BUILD_DIR cd $BUILD_DIR
...@@ -64,8 +97,9 @@ cat <<EOF >.env ...@@ -64,8 +97,9 @@ cat <<EOF >.env
# 环境变量env dev,test,test1,test2等区分 # 环境变量env dev,test,test1,test2等区分
ENV=$ENV ENV=$ENV
# 服务宿主机的端口 # 服务宿主机的端口
PORT=8118 PORT=$DWP_PORT
PORT_CRM=8181 PORT_CRM=$CRM_PORT
PORT_CRM_CLIENT=$CRM_CLIENT_PORT
# 代码目录,含前后端 # 代码目录,含前后端
CODE_DIR=$CODE_DIR CODE_DIR=$CODE_DIR
JAVA_PROFILE=innerdev # java需要根据环境调整 JAVA_PROFILE=innerdev # java需要根据环境调整
...@@ -79,7 +113,7 @@ $COMPOSE_CMD up -d ...@@ -79,7 +113,7 @@ $COMPOSE_CMD up -d
cat <<EOF cat <<EOF
本地访问地址 本地访问地址
http://$HOST_IP:8118/ DWP http://$HOST_IP:$DWP_PORT/ DWP
http://$HOST_IP:8181/ CRM http://$HOST_IP:$CRM_PORT/ CRM
安装完成! 安装完成!
EOF EOF
FROM phpdockerio/php74-cli FROM phpdockerio/php74-cli
ENV TZ=Asia/Shanghai ENV TZ=Asia/Shanghai
ENV LANG=C.UTF-8
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# apt 国内镜像 # apt 国内镜像
COPY sources.list /etc/apt/sources.list COPY sources.list /etc/apt/sources.list
...@@ -14,6 +15,7 @@ echo "extension=xlswriter.so" > /etc/php/7.4/mods-available/xlswriter.ini && ln ...@@ -14,6 +15,7 @@ echo "extension=xlswriter.so" > /etc/php/7.4/mods-available/xlswriter.ini && ln
RUN apt-get remove --purge -y php7.4-dev php-pear build-essential && apt-get autoremove -y && \ RUN apt-get remove --purge -y php7.4-dev php-pear build-essential && apt-get autoremove -y && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer # buildkit apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer # buildkit
## 修改sock监听为ip端口 ## 修改sock监听为ip端口
RUN sed -i 's/^listen\s=.*sock/listen = 0.0.0.0:9000/g' /etc/php/7.4/fpm/pool.d/www.conf && \ RUN sed -i 's/^listen\s=.*sock/listen = 0.0.0.0:9000/g' /etc/php/7.4/fpm/pool.d/www.conf && \
cat /etc/php/7.4/fpm/pool.d/www.conf | grep -v ';' | grep -v -e '^$' cat /etc/php/7.4/fpm/pool.d/www.conf | grep -v ';' | grep -v -e '^$'
......
...@@ -123,7 +123,7 @@ server { ...@@ -123,7 +123,7 @@ server {
} }
location ^~ /newsystem/ { location ^~ /newsystem/ {
proxy_pass http://middle-platform.galaxy-immi.com:8291/; proxy_pass http://$HOST:$OLD_CRM_USER_HTTP_PORT/;
} }
#禁止访问的文件或目录 #禁止访问的文件或目录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment