-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmksock.sh
72 lines (56 loc) · 1.48 KB
/
mksock.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
#!/bin/bash
appdata="$(cmd.exe /C set APPDATA | tr -d '\r\n' | cut -d= -f2- | tr '\\' '/' 2>/dev/null)"
sudo tee /etc/systemd/system/wsl-glue.servce <<EOF
[Unit]
Description=User Session
Requires=user@$(id -u).service
[Service]
User=$USER
Group=$(id -gn)
ExecStart=/bin/bash -c 'while true; do sleep 300; done'
[Install]
WantedBy=basic.target
EOF
if [ -z "$appdata" ]; then
echo "Unable to find AppData"
exit 1
fi
sockets="X0 gpg-agent gpg-agent.browser gpg-agent.extra gpg-agent.ssh scdaemon uiserver dirmngr"
for s in $sockets; do
unit="$(echo $s|tr '.' '-')"
systemctl --user disable --now ${unit}.socket
pipeargs="-ei -ep -a"
pipe="$appdata/gnupg/S.${s}"
socket="%t/gnupg/S.${s}"
if [ "$s" == "X0" ]; then
socket="/tmp/.X11-unix/X0"
pipeargs="-s -ei -ep -nt"
pipe="6000"
fi
if [ "$s" == "gpg-agent.ssh" ]; then
pipeargs="-ei -ep"
pipe="//./pipe/ssh"
fi
sudo tee /etc/systemd/user/${unit}.socket <<EOF
[Socket]
ListenStream=${socket}
SocketMode=0600
DirectoryMode=0700
Accept=yes
[Install]
WantedBy=sockets.target
EOF
sudo tee /etc/systemd/user/${unit}@.service <<EOF
[Service]
EnvironmentFile=/etc/default/wsl
ExecStart=/mnt/c/npiperelay.exe ${pipeargs} ${pipe}
StandardInput=socket
EOF
done
sudo systemctl daemon-reload
sudo systemctl enable --now wsl-glue.service
systemctl --user daemon-reload
for s in $sockets; do
unit="$(echo $s|tr '.' '-')"
systemctl --user enable --now ${unit}.socket
done