# # ASSIGN BUILD VAL IF WITHOUT THOSE VAR # # - PROXY_SERVER #ARG http_proxy=${http_proxy:-"192.168.1.10:10810"} #ARG https_proxy=${https_proxy:-"192.168.1.10:10810"} #ARG all_proxy=${all_proxy:-"192.168.1.10:10810"} # - USER_ID ARG UID=${UID:-"1000"} ARG GID=${GID:-"1000"}
# # WX_ENV # WARNNING:DON'T MODIFY IT IF YOU DON'T KNOW WHAT YOU DO # # - ALL USER WILL USER '/root' AS THEIR HOME ENV wx_doc="$WINEPREFIX/drive_c/users/wx/Documents/WeChat Files"
# COPY FROM https://github.com/huan/docker-wechat/blob/main/dochat.sh#L39C4-L40C1 if [ "$EUID" -eq 0 ] && [ "${ALLOWROOT:-0}" -ne "1" ] then echo -e "${RED}[WARNNING]${NORMAL}Please do not run this script as root." exit 1 fi
functionhello () { cat <<'EOF'
______ ______ __ __ ______ __ __ ______ ______ /\__ _\ /\ __ \ /\ \_\ \ /\ ___\ /\ \_\ \ /\ __ \ /\__ _\ \/_/\ \/ \ \ \/\ \ \ \____ \ \ \ \____ \ \ __ \ \ \ __ \ \/_/\ \/ \ \_\ \ \_____\ \/\_____\ \ \_____\ \ \_\ \_\ \ \_\ \_\ \ \_\ \/_/ \/_____/ \/_____/ \/_____/ \/_/\/_/ \/_/\/_/ \/_/ NOTIFICATION: PLEASE PUT YOUR WECHAT INSTALLER INTO YOUR WECHAT DATA DIR THAT IS IN "/home/$USER//Documents/WeChatFiles"BY DEFAULT. AND THE INSTALLER's NAME **MUST BE** "WeChatSetup.exe". 提示: 请提前将微信安装包放置于微信的文件目录 默认位置为 "/home/$USER/Documents/WeChatFiles" 此外,微信安 装包名称**必须**为"WeChatSetup.exe" EOF } function pulseaudio_init () { if [ "$(pactl info | grep "Server Name" | awk '{print$NF}')" == "pulseaudio" ];then if [ -z "$(find /tmp -type s -regex '\/tmp\/pulseaudio.*' 2>/dev/null; find /tmp -type f -regex '\/tmp\/pulseaudio.*' 2>/dev/null)" ];then if [ -n "$(find /tmp -type d -regex '\/tmp\/pulseaudio.*' 2>/dev/null)" ];then echo -e "${CYAN}[PROCESSING]${NORMAL}THIS STEP IS TO CLEAN LAST STARTUP CACHE FOR CONTAINER,PLEASE ENTER YOUR PASSWORD" sudo rm -rf '/tmp/pulseaudio.socket' '/tmp/pulseaudio.client.conf' fi pactl load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket echo -e "${CYAN}[PROCESSING]${NORMAL}THIS STEP IS TO WRITE A PULSEAUDIO CONFIG FOR CONTAINER,PLEASE ENTER YOUR PASSWORD" sudo cat > '/tmp/pulseaudio.client.conf' <<EOF default-server = unix:/tmp/pulseaudio.socket # Prevent a server running in the container autospawn = no daemon-binary = /bin/true # Prevent the use of shared memory enable-shm = false EOF fi fi } function install_pulseaudio_edition () { if [ "$(pactl info | grep "Server Name" | awk '{print$NF}')" == "pulseaudio" ];then if [ -z "$(find /tmp -type s -regex '\/tmp\/pulseaudio.*' 2>/dev/null; find /tmp -type f -regex '\/tmp\/pulseaudio.*' 2>/dev/null)" ];then if [ -n "$(find /tmp -type d -regex '\/tmp\/pulseaudio.*' 2>/dev/null)" ];then rm -rf '/tmp/pulseaudio.socket' '/tmp/pulseaudio.client.conf' fi pactl load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket echo -e "${CYAN}[PROCESSING]${NORMAL}THIS STEP IS TO WRITE A PULSEAUDIO CONFIG FOR CONTAINER,PLEASE ENTER YOUR PASSWORD" sudo cat > '/tmp/pulseaudio.client.conf' <<EOF default-server = unix:/tmp/pulseaudio.socket # Prevent a server running in the container autospawn = no daemon-binary = /bin/true # Prevent the use of shared memory enable-shm = false EOF fi echo -e "${CYAN}[PROCESSING]${NORMAL}CREATING CONTAINER toyChat WITH PULSEAUDIO..." docker run \ -d \ --name toyChat-pulseaudio \ -e PULSE_SERVER=unix:/tmp/pulseaudio.socket \ -e PULSE_COOKIE=/tmp/pulseaudio.cookie \ -v /tmp/pulseaudio.socket:/tmp/pulseaudio.socket \ -v /tmp/pulseaudio.client.conf:/etc/pulse/client.conf \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ --ipc=host \ -u 1000 \ -e GTK_IM_MODULE=fcitx \ -e QT_IM_MODULE=fcitx \ -e XMODIFIERS=@im=fcitx \ -e DefaultIMModule=fcitx \ -e TZ="$TZ" \ -v "$WX_DOC":/root/wine64/drive_c/users/wx/Documents/WeChat\ Files:rw \ "$IMG" &>> /dev/null echo -e "${GREEN}[STATUS]${NORMAL}DONE" fi } function install_base_edition () { echo -e "${CYAN}[PROCESSING]${NORMAL}CREATING CONTAINER toyChat..." docker run \ -d \ --name toyChat-base \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ --ipc=host \ -u 1000 \ -e GTK_IM_MODULE=fcitx \ -e QT_IM_MODULE=fcitx \ -e XMODIFIERS=@im=fcitx \ -e DefaultIMModule=fcitx \ -e TZ="$TZ" \ -v "$WX_DOC":/root/wine64/drive_c/users/wx/Documents/WeChat\ Files:rw \ "$IMG" &>> /dev/null echo -e "${GREEN}[STATUS]${NORMAL}DONE" } function detect_instance () { if [ -n "$(docker ps -a | grep "toyChat")" ];then echo -e "${CYAN}[PROCESSING]${NORMAL}INSTANCE FOUND .. CONTAINER WILL START AFTER A WHILE" if [ -n "$(docker ps -a | grep "toyChat-pulseaudio")" ];then pulseaudio_init docker start toyChat-pulseaudio echo -e "${GREEN}[STATUS]${NORMAL}DONE" exit 0 else docker start toyChat echo -e "${GREEN}[STATUS]${NORMAL}DONE" exit 0 fi fi } function main () { xhost +local: hello detect_instance docker pull "$IMG" install_pulseaudio_edition if [ -z "$(docker ps -a | grep toychat)" ];then install_base_edition fi echo 'ALL DONE, ENJOY' echo 'IT WILL AUTO START IF YOU INSTALL IT FIRST TIME, JUST WAIT' echo 'USE `docker ps -a | grep -i toychat` TO FIND YOUR CONTAINER ' echo 'USE `docker start [CONTAINER NAME]` TO RUN IT' } main