Skip to content

Commit

Permalink
feat: 🎸 尝试解决权限问题
Browse files Browse the repository at this point in the history
  • Loading branch information
danni-cool committed Jun 29, 2024
1 parent 6e7683e commit 36c7d28
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ RUN curl -fsSL https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-

RUN wget -O /home/docker/WeChatSetup-3.9.2.23.exe https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.9.2.23/WeChatSetup-3.9.2.23.exe

# 切换到 docker 用户
USER docker

COPY linux/bin /bin
COPY linux/.fluxbox /home/docker/.fluxbox
COPY linux/conf.d/* /etc/supervisor/conf.d/
COPY linux/sh/entrypoint.sh /etc/entrypoint.sh

RUN chmod +x /etc/entrypoint.sh

USER docker

ENTRYPOINT ["/bin/bash","/etc/entrypoint.sh"]

EXPOSE 8080 22 3001
41 changes: 25 additions & 16 deletions linux/sh/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

function check_vnc_pass {
if [[ -n $VNC_PASSWORD ]]; then
local VNC_PASSWD_PATH="/home/docker/.vnc/passwd"
rm -f $VNC_PASSWD_PATH
if [[ ! -d "/home/docker/.vnc" ]]; then mkdir -p /home/docker/.vnc;fi
if [[ ! -d "/home/docker/.vnc" ]]; then mkdir -p /home/docker/.vnc; fi
x11vnc -storepasswd "$VNC_PASSWORD" "$VNC_PASSWD_PATH"
export X11_ARGS="-rfbauth $VNC_PASSWD_PATH"
chown docker $VNC_PASSWD_PATH
Expand All @@ -12,25 +13,33 @@ function check_vnc_pass {
export X11_ARGS=""
fi
}
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
# Generate ssh key
ssh-keygen -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
fi

check_vnc_pass
# 切换回 root 用户来执行特权命令
if [ "$(id -u)" -eq 0 ]; then
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
# Generate ssh key
ssh-keygen -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
fi

if [[ -n $USER_PASSWORD ]];then
echo "docker:$USER_PASSWORD" | chpasswd
fi
if [[ -n $PUID ]]; then
usermod -u "$PUID" docker
fi
if [[ -n $PGID ]]; then
groupmod -g "$PGID" docker
check_vnc_pass

if [[ -n $USER_PASSWORD ]]; then
echo "docker:$USER_PASSWORD" | chpasswd
fi
if [[ -n $PUID ]]; then
usermod -u "$PUID" docker
fi
if [[ -n $PGID ]]; then
groupmod -g "$PGID" docker
fi

# 切换到 docker 用户
exec su docker -c "/etc/entrypoint.sh"
fi

# 从这里开始的命令都以 docker 用户执行
# Start Xvfb
Xvfb :0 -screen 0 1024x768x16 &

Expand Down

0 comments on commit 36c7d28

Please sign in to comment.