-
Notifications
You must be signed in to change notification settings - Fork 203
/
dochat.sh
executable file
·153 lines (130 loc) · 3.82 KB
/
dochat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
#
# dochat.sh - Docker WeChat for Linux
#
# Author: Huan (李卓桓) <zixia@zixia.net>
# Copyright (c) 2020-now
#
# License: Apache-2.0
# GitHub: https://github.com/huan/docker-wechat
#
set -eo pipefail
#
# The defeault docker image version which confirmed that most stable.
# See: https://github.com/huan/docker-wechat/issues/29#issuecomment-619491488
#
# Updates:
# 2020-04-01: 2.7.1.85
# 2020-08-24: 3.3.0.115 (not working yet)
# 2020-09-01: 3.3.0.115 (alpha testing)
if [ "$EUID" -eq 0 ] && [ "${ALLOWROOT:-0}" -ne "1" ]
then
echo "Please do not run this script as root."
echo "see https://github.com/huan/docker-wechat/pull/209"
exit 1
fi
DEFAULT_WECHAT_VERSION=3.3.0.115
#
# Get the image version tag from the env
#
DOCHAT_IMAGE_VERSION="zixia/wechat:${DOCHAT_WECHAT_VERSION:-${DEFAULT_WECHAT_VERSION}}"
function hello () {
cat <<'EOF'
____ ____ _ _
| _ \ ___ / ___| |__ __ _| |_
| | | |/ _ \| | | '_ \ / _` | __|
| |_| | (_) | |___| | | | (_| | |_
|____/ \___/ \____|_| |_|\__,_|\__|
https://github.com/huan/docker-wechat
+--------------+
/| /|
/ | / |
*--+-----------* |
| | | |
| | 盒装 | |
| | 微信 | |
| +-----------+--+
| / | /
|/ |/
*--------------*
DoChat /dɑɑˈtʃæt/ (Docker-weChat) is:
📦 a Docker image
🤐 for running PC Windows WeChat
💻 on your Linux desktop
💖 by one-line of command
EOF
}
function pullUpdate () {
if [ -n "$DOCHAT_SKIP_PULL" ]; then
return
fi
echo '🚀 Pulling the docker image...'
echo
docker pull "$DOCHAT_IMAGE_VERSION"
echo
echo '🚀 Pulling the docker image done.'
}
function main () {
hello
pullUpdate
DEVICE_ARG=()
for DEVICE in /dev/video*; do
DEVICE_ARG+=('--device' "$DEVICE")
done
if [[ $(lshw -C display 2> /dev/null | grep vendor) =~ NVIDIA ]]; then
DEVICE_ARG+=('--gpus' 'all' '--env' 'NVIDIA_DRIVER_CAPABILITIES=all')
fi
echo '🚀 Starting DoChat /dɑɑˈtʃæt/ ...'
echo
# Issue #111 - https://github.com/huan/docker-wechat/issues/111
rm -f "$HOME/DoChat/Applcation Data/Tencent/WeChat/All Users/config/configEx.ini"
# Issue #165 - https://github.com/huan/docker-wechat/issues/165#issuecomment-1643063633
HOST_DIR_HOME_DOCHAT_WECHAT_FILES="$HOME/DoChat/WeChat Files/"
HOST_DIR_HOME_DOCHAT_APPLICATION_DATA="$HOME/DoChat/Applcation Data/"
mkdir "$HOST_DIR_HOME_DOCHAT_WECHAT_FILES" -p
mkdir "$HOST_DIR_HOME_DOCHAT_APPLICATION_DATA" -p
#
# --privileged: enable sound (/dev/snd/)
# --ipc=host: enable MIT_SHM (XWindows)
#
docker run \
"${DEVICE_ARG[@]}" \
--name DoChat \
--rm \
-i \
\
-v "$HOST_DIR_HOME_DOCHAT_WECHAT_FILES":'/home/user/WeChat Files/' \
-v "$HOST_DIR_HOME_DOCHAT_APPLICATION_DATA":'/home/user/.wine/drive_c/users/user/Application Data/' \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "/run/user/$(id -u)/pulse":"/run/pulse" \
\
-e DISPLAY \
-e DOCHAT_DEBUG \
-e DOCHAT_DPI \
\
-e XMODIFIERS \
-e GTK_IM_MODULE \
-e QT_IM_MODULE \
\
-e AUDIO_GID="$(getent group audio | cut -d: -f3)" \
-e VIDEO_GID="$(getent group video | cut -d: -f3)" \
-e GID="$(id -g)" \
-e UID="$(id -u)" \
\
--ipc=host \
--privileged \
--add-host dldir1.qq.com:127.0.0.1 \
\
"$DOCHAT_IMAGE_VERSION"
#
# Do not put any command between
# the above "docker run" and
# the below "echo"
# because we need to output error code $?
#
echo "📦 DoChat Exited with code [$?]"
echo
echo '🐞 Bug Report: https://github.com/huan/docker-wechat/issues'
echo
}
main