-
Notifications
You must be signed in to change notification settings - Fork 5
/
install-adapter.sh
executable file
·59 lines (47 loc) · 1.09 KB
/
install-adapter.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
#!/bin/bash
WORK_DIR=`dirname $0`
pushd $WORK_DIR
WORK_DIR=`pwd`
popd
WSMANCMD="/etc/maas/templates/power/wsmancmd.py"
VERSION=$(dpkg-query -W maas 2>/dev/null | awk '{print $2}')
MAAS19="^1.9"
if [ -z "$VERSION" ]
then
echo "MAAS is not installed"
exit 1
fi
PATCH_FILE="$WORK_DIR/patch.diff"
if [[ $VERSION =~ $MAAS19 ]]
then
PATCH_FILE="$WORK_DIR/maas-1.9.patch"
fi
function CheckError() {
ERRCODE=$?
if [ $ERRCODE -ne 0 ]
then
echo $1
exit $ERRCODE
fi
}
sudo apt-get update
CheckError "Failed to run update"
sudo apt-get -y install python-pip git
CheckError "Failed to install python-pip"
sudo pip install git+https://github.com/cloudbase/pywinrm
CheckError "Failed to install pywinrm"
pushd /
echo "Patching MaaS to enable Hyper-V power adapter"
sudo patch -p1 < $PATCH_FILE
CheckError "Failed to patch maas"
if [ -f "$WSMANCMD" ]
then
sudo chmod +x "$WSMANCMD"
fi
echo "Restarting Apache2"
sudo /etc/init.d/apache2 restart
CheckError "Failed to restart Apache2"
sleep 3
sudo restart maas-clusterd
CheckError "Failed to restart maas-clusterd"
popd