-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·116 lines (97 loc) · 3.13 KB
/
install
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
#!/bin/bash
function oneline() {
echo -ne "\033[2K" ; printf "\r$1"
}
# Detect if patch install or full install
if [ "$1" == "patch" ]; then
installType="patch"
elif [ "$1" == "update" ]; then
installType="update"
elif [ -z "$1" ]; then
installType="new"
else
echo "Invalid argument for install."
exit 1
fi
echo "Installing TapisV3 CLI"
# Detect the OS
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) os=linux;;
Darwin*) os=mac;;
*) os=$unameOut
esac
oneline "Detected OS: $os"
# Kill install if OS not linux or mac
if [ $os != mac ] && [ $os != linux ]; then
oneline "Operating system not supported: '$os' - Cancelling installation"
exit 1
fi
# Set the rcfile based on OS
rcfile="$HOME/.bashrc"
if [ $os == mac ]; then
rcfile="$HOME/.zshrc"
fi
# Source code directory
# libDir='/usr/local/lib/tapis'
libDir=~/tapis/v3
# Configs directory
# configDir='/usr/local/etc/tapis'
configDir=~/tapis/v3/configs
# Create directories that will house the source code and config files
oneline "Creating directories:"
directoriesToCreate=($libDir $configDir)
for directory in "${directoriesToCreate[@]}"; do
oneline $directory
mkdir -p $directory
done
# Copy the source code from the current directory to the source code directory
oneline "Copying source code to '$libDir'"
projectDir="$(pwd)"
rsync -a "${projectDir}/src" $libDir
rsync -a "${projectDir}/requirements.txt" "${libDir}/src"
# Create the config.json that will house the cli configurations
oneline "Generating config in '$configDir'"
if [ $installType == "new" ]; then
touch "${configDir}/config.json"
rsync -a "${projectDir}/config.json" "${configDir}/config.json"
fi
tapisEntrypoint="${libDir}/src/tapis.sh"
oneline "Making tapis.sh executable"
chmod +x $tapisEntrypoint
if [ $installType == "update" ] || [ $installType == "new" ]; then
oneline "Creating virtual envrionment"
cd "${libDir}/src"
python3 -m venv env
source env/bin/activate
oneline "Install python dependencies in virtual env"
pip install --upgrade pip
pip install -r requirements.txt
pip list
deactivate
fi
allowRCFileModification=n
if [ $installType == "new" ]; then
echo -n "Do you want to allow the TapisV3 CLI install to modify your $rcfile? [y/n]: "
read -r -n 1 allowRCFileModification
fi
if [ $allowRCFileModification == "y" ]; then
echo "Adding alias for 'tapis': $rcfile"
echo "alias tapis='${tapisEntrypoint}'" >> $rcfile
echo ""
echo "################## FINAL STEP #########################################"
echo "To complete installation, source your rcfile by running the following:"
echo "source $rcfile"
echo "#######################################################################"
echo ""
else
echo ""
echo "################## FINAL STEP #########################################"
echo "To complete installation, add an alias to the tapis script in $rcfile"
echo "alias tapis='${tapisEntrypoint}'"
echo ""
echo "then run the following command:"
echo "source $rcfile"
echo "#######################################################################"
echo ""
fi