-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappctl_setup
More file actions
executable file
·122 lines (102 loc) · 3.02 KB
/
appctl_setup
File metadata and controls
executable file
·122 lines (102 loc) · 3.02 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
set -o pipefail
initialize_basedir() {
echo -e "${YELLOW}Initializing: ${pf9_basedir}${NC}"
for dir in ${pf9_state_dirs}; do
echo -e "${YELLOW}Ensuring ${dir} exists${NC}"
if ! mkdir -p "${dir}" > /dev/null 2>&1; then echo -e "${RED}Failed to create directory: ${dir}${NC}"; fi
done
}
refresh_symlink() {
# Create symlink in /usr/bin
if [ -L ${symlink_path} ]; then
if ! (sudo rm ${symlink_path} 2>&1); then
echo -e "${RED}Failed to remove existing symlink: ${symlink_path}${NC}"; fi
fi
if ! (sudo ln -s ${cli_exec} ${symlink_path} 2>&1); then
echo -e "${RED}Failed to create Platform9 CLI symlink in /usr/bin${NC}"; fi
}
check_installation() {
if ! (${cli_exec} --help 2>&1); then
echo -e "${RED}Installation of Platform9 Appctl CLI Failed.${NC}"; fi
}
download_cli_binary() {
echo "Note: SUDO access required to install Platform9 Appctl CLI."
echo " You might be prompted for your SUDO password."
echo ""
echo "Downloading Platform9 Appctl CLI binary..."
sudo rm ${cli_exec} 2> /dev/null
cd ${pf9_bin} > /dev/null && sudo curl -s -O ${cli_path} 2>&1 && cd - > /dev/null
sudo chmod 555 ${cli_exec}
echo ""
echo -e "${GREEN}Platform9 Appctl CLI binary downloaded.${NC}"
echo ""
}
download_cli_binary_windows(){
echo "Downloading Platform9 Appctl CLI binary..."
curl -s -O ${cli_path}
Ren "appctl" "appctl.exe"
echo ""
echo -e "${GREEN}Platform9 Appctl CLI binary downloaded.${NC}"
echo ""
}
print_pf9_logo() {
cat << "EOF"
____ _ _ __ ___
| _ \| | __ _| |_ / _| ___ _ __ _ __ ___ / _ \
| |_) | |/ _` | __| |_ / _ \| '__| '_ ` _ \ (_) |
| __/| | (_| | |_| _| (_) | | | | | | | \__, |
|_| |_|\__,_|\__|_| \___/|_| |_| |_| |_| /_/
EOF
}
set_os_cpu(){
os=""
cpu=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os="macos"
symlink_path="/usr/local/bin/appctl"
return
elif [[ "$OSTYPE" == "msys"* ]]; then
os="windows"
else
echo "This OS is not supported. Check documentation for supported versions at https://platform9.com/docs/appctl/getting-started"
exit
fi
arch=$(uname -i)
if [ "$arch" == 'x86_64' ];then
cpu="64"
else
echo "This CPU Architecture is not supported."
exit
fi
}
##main
symlink_path="/usr/bin/appctl"
pf9_basedir=$(dirname ~/pf9/.)
pf9_bin=${pf9_basedir}/bin
pf9_state_dirs="${pf9_bin}"
set_os_cpu
cli_path="https://pmkft-assets.s3-us-west-1.amazonaws.com/appctl/${os}/appctl"
cli_exec="${pf9_bin}/appctl"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
print_pf9_logo
echo ""
echo ""
initialize_basedir
if [[ ${os} == "win"* ]]; then
download_cli_binary_windows
echo ""
else
download_cli_binary
echo "Installing Platform9 Appctl CLI..."
echo ""
refresh_symlink
check_installation
fi
echo ""
echo -e "${GREEN}Platform9 Appctl CLI installation completed successfully !${NC}"