-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwine_entrypoint.bsh
More file actions
80 lines (71 loc) · 2.59 KB
/
wine_entrypoint.bsh
File metadata and controls
80 lines (71 loc) · 2.59 KB
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
#!/usr/bin/env bash
set -eu
: ${USER_ID=1000}
: ${GROUP_ID="${USER_ID}"}
groupadd -og "${GROUP_ID}" user
useradd -mou "${USER_ID}" -g "${GROUP_ID}" user
# The FAST_WINE_DIR variable can disable the correct ownership behavior
if [ -n "${FAST_WINE_DIR+set}" ]; then
: ${WINEPREFIX=/home/wine}
export WINEPREFIX
else
mkdir -p /home/.user_wine
# Handle docker often make a volume owned by root by default
chown user:user /home/.user_wine
# Link the dir in instead of mounting, cause then useradd won't populate skel
ln -s /home/.user_wine /home/user/.wine
# This would add about 6 seconds to start time
if [ ! -d "/home/user/.wine/drive_c" ]; then
echo "Initializing .wine directory..."
(
shopt -s dotglob;
# A copy is faster than a chown, due to how snapshots work. At least this
# is true on brtfs
gosu user cp -ra /home/wine/* /home/user/.wine/
)
echo "Done!"
else
if [ "$(stat -c %U /home/user/.wine/drive_c)" != "user" ]; then
echo "The wine directory does not appear to be owned by you."
echo "You probably changed your USER_ID and didn't to remove the wine volume"
echo "Re-chowning now... (This may take a while)"
chown -R user:user /home/user/.wine/
echo "Done"
fi
fi
fi
while [ "${1-unset}" == "--add" ]; do
# Remove the --add flag
shift 1
# Execute whatever the additional entrypoint is, with all the arguments
"${@}"
# Remove the entrypoint arguments itself. This is done so that the additional
# entrypoints can do one of three things:
# 1) Non zero exit, in which case this script would be over
# 2) Use the additional arguments for whatever means, and then continue
# 3) Not use and of the other extra, and not exit, in which case the rest of
# this entrypoint continues.
shift 1
done
if [ "${1-unset}" = "root" ]; then
# Remove the "root" marker
shift 1
exec bash ${@+"${@}"}
else
if [ -n "${DISPLAY:+set}" ]; then
if [ "${MSYS2_WINE_WORKAROUND}" = "0" ]; then
# Start wine
gosu user wine 'C:\msys64\usr\bin\mintty.exe' /usr/bin/bash --login ${@+"${@}"}
elif [ "${MSYS2_WINE_WORKAROUND}" = "1" ]; then
gosu user wineconsole cmd /c 'C:\msys64\usr\bin\mintty.exe' /usr/bin/bash --login ${@+"${@}"} \> nul
fi
# Wait for it to end
gosu user wineserver --wait
else
# There's a random bug I observed where bash in wineconsole using ncurses
# doesn't work on the first try, but does on the second. So make a dummy
# call to ncurses
gosu user wineconsole cmd /c :
gosu user wineconsole 'C:\msys64\usr\bin\bash.exe' --login ${@+"${@}"}
fi
fi