-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathinstall.sh
133 lines (120 loc) · 5.49 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
129
130
131
132
133
#!/bin/bash
###############################################################################
## ##
## PURPOSE: Install PRIDE-PPPAR ##
## ##
## AUTHOR : the PRIDE Group [email protected] ##
## ##
## VERSION: ver 3.1.1 ##
## ##
## DATE : Jan-14, 2025 ##
## ##
## @ GNSS RESEARCH CENTER, WUHAN UNIVERSITY, 2023 ##
## ##
## Copyright (C) 2023 by Wuhan University ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License (version 3) as ##
## published by the Free Software Foundation. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License (version 3) for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <https://www.gnu.org/licenses/>. ##
## ##
###############################################################################
SYS=`uname`
RED='\033[0;31m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check compiler
gfortran --version > /dev/null 2>&1
if [ $? -ne 0 ]; then
printf "${RED}error:${NC} no compiler: gfortran\n"
printf "${RED}error:${NC} PRIDE-PPPAR installation failed\n"; exit
fi
gcc --version > /dev/null 2>&1
if [ $? -ne 0 ]; then
printf "${RED}error:${NC} no compiler: gcc\n"
printf "${RED}error:${NC} PRIDE-PPPAR installation failed\n"; exit
fi
make --version > /dev/null 2>&1
if [ $? -ne 0 ]; then
printf "${RED}error:${NC} GNU make not found\n"
printf "${RED}error:${NC} PRIDE-PPPAR installation failed\n"; exit
fi
# Compilation & Installation
if [[ "${HOME}" == /root* ]]; then
printf "${RED}error:${NC} unable to install PRIDE-PPPAR in /root \n"
printf "${RED}error:${NC} PRIDE-PPPAR installation failed\n"; exit
fi
install_dir=${HOME}/.PRIDE_PPPAR_BIN
rm -rf "$install_dir"
cd src && make clean && make && make install \
&& cd .. \
&& mkdir -p $install_dir \
&& cp -f ./bin/* $install_dir \
&& chmod 755 ./scripts/*
# Check python
if which python3 > /dev/null 2>&1; then
sed -i 's/\#\!\/usr\/bin\/env python$/\#\!\/usr\/bin\/env python3/g' ./scripts/*.py
elif which python > /dev/null 2>&1; then
sed -i 's/\#\!\/usr\/bin\/env python3$/\#\!\/usr\/bin\/env python/g' ./scripts/*.py
else
printf "${YELLOW}warning:${NC} no python or python3, please install one of them before using py scripts\n"
fi
cp -f ./scripts/*py ./scripts/*sh $install_dir
mv -f $install_dir/pdp3.sh $install_dir/pdp3
if [ $? -eq 0 ]; then
if [ "$SYS" == "Darwin" ]; then
grep "^export PATH=$install_dir:\$PATH" ${HOME}/.bash_profile > /dev/null 2>&1
[ $? -ne 0 ] && echo "export PATH=$install_dir:\$PATH" >> ${HOME}/.bash_profile
else
grep "^export PATH=$install_dir:\$PATH" ${HOME}/.bashrc > /dev/null 2>&1
[ $? -ne 0 ] && echo "export PATH=$install_dir:\$PATH" >> ${HOME}/.bashrc
fi
fi
# Output
ls ${install_dir}/lsq > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "\033[1;31m" && cat ./doc/logo && echo -e "$NC"
printf "${BLUE}::${NC} PRIDE-PPPAR (v3.1.1) installation successfully completed!\n"
printf "${BLUE}::${NC} executable binaries are copy to $install_dir\n"
printf "${BLUE}::${NC} $install_dir added to PATH\n"
else
printf "${RED}error:${NC} PRIDE-PPPAR installation failed!\n"
exit 1
fi
chmod 755 $install_dir/*
work_dir=$(pwd)
cp ./table/config_template $install_dir
if [ "$SYS" == "Darwin" ]; then
sed -i '' "/Table directory/s#Default#$work_dir/table/#" $install_dir/config_template
else
sed -i "/Table directory/s#Default#$work_dir/table/#" $install_dir/config_template
fi
chmod 444 $install_dir/config_template
chmod 755 ./example/*.sh
# Select download sites
printf "\n"
read -p $'Would you like to download GNSS products from IGN (\e[31mrecommended for users outside China\e[0m) [Y/N]: ' test
if [ ${#test} -ge 1 ] && ( [ ${test:0:1} == "y" ] || [ ${test:0:1} == "Y" ] ); then
touch $install_dir/.ign_priority
fi
# Test examples
printf "\n"
read -p $'Run tests or not (\e[31mstrongly recommended for the first installation !!!\e[0m) [Y/N]: ' test
if [ ${#test} -ge 1 ] && ( [ ${test:0:1} == "y" ] || [ ${test:0:1} == "Y" ] ); then
cd example
if [ "$SYS" == "Darwin" ]; then
source ~/.bash_profile
else
source ~/.bashrc
fi
bash test.sh
cd ..
fi