-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
executable file
·76 lines (66 loc) · 2.05 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
#!/bin/bash
#
# Description:
# Prepare the environment.
#
# History:
# v1.0 2020-02-04 charles.shih Init version
# v1.1 2020-02-05 charles.shih Setup Aliyun CLI and OSSUitl
# v1.2 2020-02-05 charles.shih Grant permission to the image path
# v1.2.1 2020-02-05 charles.shih Update some prompts and a typo
# v1.3 2020-02-05 charles.shih Add package qemu-system-x86 to checklist
# v1.4 2020-02-05 charles.shih Remove package qemu-system-x86 from checklist
# Get sudo access
sudo bash -c : || exit 1
# Check packages
echo -e "\nChecking packages..."
packages="
git
libguestfs
libguestfs-tools-c
libvirt
libvirt-client
"
for name in $packages; do
echo -e "\nLooking up package $name..."
rpm -q $name && continue
echo "Installing package $name..."
sudo dnf install -y $name
done
# Configure libvirt
echo -e "\nConfiguring libvirt..."
sudo chmod a+rwx /var/lib/libvirt/images/
#sudo sed -i 's/^#user = "root"/user = "root"/' /etc/libvirt/qemu.conf
#sudo sed -i 's/^#group = "root"/group = "root"/' /etc/libvirt/qemu.conf
sudo systemctl restart libvirtd
sudo systemctl enable libvirtd
# Setup Aliyun CLI
# Ref. https://www.alibabacloud.com/help/doc-detail/110244.html
echo -e "\nChecking Aliyun CLI..."
which aliyun
if [ "$?" != "0" ]; then
mkdir -p $HOME/aliyun
pushd $HOME/aliyun
wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz
tar -xf ./aliyun-cli-linux-latest-amd64.tgz
chmod 755 ./aliyun
sudo cp ./aliyun /usr/local/bin
popd
fi
read -t 30 -p "Configure credentials for Aliyun CLI now [y/N]? (in 30s) " answer
[ "$answer" = "y" ] && aliyun configure
# Setup Aliyun OSSUtil
# Ref. https://www.alibabacloud.com/help/doc-detail/50452.html
echo -e "\nChecking Aliyun OSSUtil..."
which ossutil64
if [ "$?" != "0" ]; then
mkdir -p $HOME/aliyun
pushd $HOME/aliyun
wget http://gosspublic.alicdn.com/ossutil/1.6.6/ossutil64
chmod 755 ./ossutil64
sudo cp ./ossutil64 /usr/local/bin
popd
fi
read -t 30 -p "Configure credentials for Aliyun OSSUtil now [y/N]? (in 30s) " answer
[ "$answer" = "y" ] && ossutil64 config
exit 0