-
Notifications
You must be signed in to change notification settings - Fork 7
/
Setup.sh
executable file
·85 lines (73 loc) · 2.91 KB
/
Setup.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
#!/bin/bash
# Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -z $(which pwsh) ] ; then
while true; do
read -p "[QSI] pwsh command not found. Do you wish to install powershell?: [Y/N] " yn
case $yn in
[Yy]* )
# install the requirements
sudo apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl1.1 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
curl
sudo apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
lttng-ust
# Download the powershell '.tar.gz' archive
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-linux-alpine-x64.tar.gz -o /tmp/powershell.tar.gz
# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/7
# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7
# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/7/pwsh
# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh
break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# MacOS
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [ -z $(which brew) ] ; then
while true; do
read -p "[QSI] brew command not found. Do you wish to install brew?: [Y/N] " yn
case $yn in
[Yy]* ) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
if [ -z $(which pwsh) ] ; then
while true; do
read -p "[QSI] pwsh command not found. Do you wish to install powershell?: [Y/N] " yn
case $yn in
[Yy]* ) brew install --cask powershell; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# Windows
elif [ "$OSTYPE" -eq "cygwin" ] || [ "$OSTYPE" -eq "msys" ] || [ "$OSTYPE" -eq "win32" ]; then
./Setup.ps1 $@
exit 0
# Unknown
else
echo "[QSI] Unknown OS detected '$OSTYPE'"
fi
echo "[QSI] Redirect to pwsh"
pwsh ./Setup.ps1 $@