-
Notifications
You must be signed in to change notification settings - Fork 214
/
deploy.sh
67 lines (63 loc) · 2.51 KB
/
deploy.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
#!/bin/bash -e
# Check powershell available and if not install
silent=""
if ! [ -x "$(command -v pwsh)" ]; then
if [ -x "$(command -v lsb_release)" ]; then
if [ -n $silent ]; then
echo -e "\033[1;31mPwsh (Powershell) is not installed but required to deploy.\033[0m"
while true; do
read -p "Do you want to install Powershell (requires sudo privileges)? (y/n) " yn
case $yn in
[Yy]* ) break;;
* ) echo "You must install Powershell manually to continue..."; exit 1;;
esac
done
fi
# install powershell
ubuntuversion="$(lsb_release -rs)"
curl -O https://packages.microsoft.com/config/ubuntu/$ubuntuversion/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm -f packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y --no-install-recommends powershell
silent="yes"
else
echo "Error: Pwsh (Powershell) is not installed but required to deploy - please install it." >&2
exit 1
fi
fi
test=$(pwsh -Command "Get-Module -ListAvailable -Name Az.* | ForEach-Object Name")
if [ -z "$test" ]; then
if [ -n $silent ]; then
echo -e "\033[1;31mAz Powershell module is not installed but is required to deploy.\033[0m"
while true; do
read -p "Do you want to install Az module (requires sudo privileges)? (y/n) " yn
case $yn in
[Yy]* ) break;;
* ) echo "You must install Az Powershell module manually to continue..."; exit 1;;
esac
done
fi
sudo pwsh -Command "Set-psrepository -Name PSGallery -InstallationPolicy Trusted"
sudo pwsh -Command "Install-Module -Repository PSGallery -Name Az -AllowClobber"
silent="yes"
fi
test=$(pwsh -Command "Get-Module -ListAvailable -Name Microsoft.Graph | ForEach-Object Name")
if [ -z "$test" ]; then
if [ -n $silent ]; then
echo -e "\033[1;31mMicrosoft.Graph Powershell module is not installed but is required to deploy.\033[0m"
while true; do
read -p "Do you want to install Microsoft.Graph module (requires sudo privileges)? (y/n) " yn
case $yn in
[Yy]* ) break;;
* ) echo "You must install Microsoft.Graph Powershell module manually to continue..."; exit 1;;
esac
done
fi
sudo pwsh -Command "Set-psrepository -Name PSGallery -InstallationPolicy Trusted"
sudo pwsh -Command "Install-Module -Repository PSGallery -Name Microsoft.Graph -AllowClobber"
silent="yes"
fi
# Call powershell script
curdir="$( cd "$(dirname "$0")" ; pwd -P )"
pwsh -File $curdir/deploy/scripts/deploy.ps1 "$@"