-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·57 lines (54 loc) · 1.78 KB
/
install.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
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root (e.g. sudo $0)"
exit 0
fi
if [ ! -d "/etc/binfmt.d" ] || ( ! grep -iq 'interop' /etc/wsl.conf )
then
echo 'binfmt_misc and wslinterop do not appear to be enabled'
echo 'Please see "Interop settings" at https://learn.microsoft.com/en-us/windows/wsl/wsl-config'
exit 1
fi
script=$(readlink -f "${0}")
scriptPath=$(dirname "${script}")
files=( office.conf office-wrapper powershell.conf powershell-wrapper wsl.conf wslshim wsl-wrapper )
for i in "${files[@]}"
do
if [ ! -e "${scriptPath}/${i}" ]
then
echo "${i} is missing, exiting"
exit 1
fi
done
fail() {
echo copy failed, something went wrong
exit 1
}
echo -n 'Install wsl-wrapper to enable runnning windows executables with WSL paths? (Y/n) '
read check
if [[ "${check,,}" == "y"* ]] || [ -z "${check}" ]
then
cp "${scriptPath}/wsl.conf" "/etc/binfmt.d" || fail
cp "${scriptPath}/wsl-wrapper" "/usr/local/bin" || fail
chmod a+rx "/usr/local/bin/wsl-wrapper" || fail
fi
unset check
echo -n 'Install powershell-wrapper to enable runnning PowerShell scripts directly (e.g., myscript.ps1)? (Y/n) '
read check
if [[ "${check,,}" == "y"* ]] || [ -z "${check}" ]
then
cp "${scriptPath}/powershell.conf" "/etc/binfmt.d" || fail
cp "${scriptPath}/powershell-wrapper" "/usr/local/bin" || fail
chmod a+rx "/usr/local/bin/powershell-wrapper" || fail
fi
unset check
echo -n 'Install office-wrapper to enable runnning office documents directly (e.g., mydocument.docx)? (Y/n) '
read check
if [[ "${check,,}" == "y"* ]] || [ -z "${check}" ]
then
cp "${scriptPath}/office.conf" "/etc/binfmt.d" || fail
cp "${scriptPath}/office-wrapper" "/usr/local/bin" || fail
chmod a+rx "/usr/local/bin/office-wrapper" || fail
fi
echo Restarting system-binfmt...
systemctl restart systemd-binfmt