-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·128 lines (102 loc) · 2.58 KB
/
install.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
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
121
122
123
124
125
126
127
128
#!/bin/bash
: '
Installation script for AutoParallelizePy.
Author: Abbas Raboonik
Contact: raboonik@gmail.com
GitID: https://github.com/raboonik
'
if [ ! "$EUID" -ne 0 ]
then
echo "Please do not run as root and try again without sudo!"
exit
fi
sourceDir=$(pwd)
installationDir=$HOME/.local/lib/AutoParallelizePy/
if [ $# -eq 0 ]
then
echo "Installing in the default directory under $installationDir"
else
installationDir=$1
if [ ! -d $installationDir ]
then
echo "The input directory does not exist!"
exit
else
echo "Installing in $installationDir"
installationDir=$installationDir"AutoParallelizePy"
fi
fi
IFS='/' read -r -a array <<< "$installationDir"
installationDir=""
for subDir in "${array[@]}"
do
installationDir=${installationDir}${subDir}"/"
if [ ! -d "$installationDir" ]; then
mkdir $installationDir
fi
done
cp -r $sourceDir"/libs/" $installationDir
if [ -f $sourceDir"/add2path.sh" ]
then
rm $sourceDir"/add2path.sh"
fi
touch $sourceDir"/add2path.sh"
echo "
#!/bin/bash
: '
Add AutoParallelizePy library to .bashrc and source it.
'
if [ ! "\$EUID" -ne 0 ]
then
echo "Please do not run as root and try again without sudo!"
exit
fi
if [ ! -f \"$HOME"/.bashrc"\" ]
then
touch \"$HOME"/.bashrc"\"
fi
addLine=\"export PYTHONPATH='${PYTHONPATH}:${installationDir}libs'\"
if grep -Fxq \$addLine \$HOME"/.bashrc"
then
echo ".bashrc file already updated"
else
echo "Adding the AutoParallelizePy library to PYTHONPATH in .bashrc"
echo "\$addLine" >> \$HOME/.bashrc
source \$HOME/.bashrc
fi
" >> $sourceDir"/add2path.sh"
chmod +x $sourceDir"/add2path.sh"
if [ -f $sourceDir"/uninstall.sh" ]
then
rm $sourceDir"/uninstall.sh"
fi
touch $sourceDir"/uninstall.sh"
echo "
#!/bin/bash
: '
Uninstallation script for AutoParallelizePy.
Remove libraries and update python the environment.
'
if [ ! "\$EUID" -ne 0 ]
then
echo "Please do not run as root and try again without sudo!"
exit
fi
if [ -f \"$sourceDir"/add2path.sh"\" ]
then
rm \"$sourceDir"/add2path.sh"\"
fi
if [ -d \"$installationDir\" ]
then
rm -r $installationDir"\*"
export PYTHONPATH=\${PYTHONPATH#"\":${installationDir}libs"\"}
echo "AutoParallelizePy uninstallation successfully!"
else
echo "AutoParallelizePy not installed or not found at ${installationDir}!"
fi
sed -i \""/\\/AutoParallelizePy\\//d"\" $HOME/.bashrc
source $HOME/.bashrc
rm $sourceDir"/uninstall.sh"
" >> $sourceDir"/uninstall.sh"
chmod +x $sourceDir"/uninstall.sh"
echo "Installation done successfully!"