-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·132 lines (102 loc) · 3.46 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
#!/bin/bash
#
# Installs PCAGO and PCAGO-electron into some folder
#
PACKRAT_DEPENDENCIES_URL="https://github.com/rnajena/pcago-unified/releases/download/dependencies/packrat.zip"
PACKRAT_BINARIES_UBUNTU1804_URL="https://github.com/rnajena/pcago-unified/releases/download/ubuntu-18.04/packrat-Ubuntu-1804.zip"
CURRENT_DIR=$(pwd)
read -p "Please enter the folder where PCAGO will be installed: " installation_folder
installation_folder=$(realpath $installation_folder)
echo "PCAGO will be installed into $installation_folder"
read -p "Press enter to continue"
mkdir -p $installation_folder
mkdir -p $installation_folder/R
mkdir -p $installation_folder/pcago
mkdir -p $installation_folder/pcago-electron
# Check all dependencies
./check_dependencies.sh
./check_R.sh $installation_folder/R
if [ "" == "$($installation_folder/R/R --version | grep '3.4.3')" ]; then
echo "Something seems to be wrong with the R installation in $installation_folder/R/R"
echo "Canceling."
exit
fi
# For later: Use precompiled packrat dependencies
if [ -e "/etc/lsb-release" ]; then
source /etc/lsb-release
if [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$DISTRIB_RELEASE" == "18.04" ]; then
read -p "You are using Ubuntu 18.04. We offer precompiled R packages. Use the precompiled packages? [Y/N]" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
PACKRAT_DEPENDENCIES_URL=$PACKRAT_BINARIES_UBUNTU1804_URL
fi
fi
fi
# Automated part
echo "Preparation finished. The next steps will run automatically if everything goes well."
echo "This take some time, so get some coffee!"
read -p "(But first) press enter to continue"
# Copy over PCAGO-electron and PCAGO
echo ">>>>>>> Installing PCAGO and PCAGO-Electron ..."
cp -rv ./src/* $installation_folder/pcago
cp -rv ./src-electron/* $installation_folder/pcago-electron
ln -s $installation_folder/pcago $installation_folder/pcago-electron
ln -s $installation_folder/R/R $installation_folder/pcago/
ln -s $installation_folder/R/R $installation_folder/pcago-electron/
# Download dependencies
echo ">>>>>>> Downloading R packages ..."
cd $installation_folder/pcago/packrat
rm -rv src
wget -nc $PACKRAT_DEPENDENCIES_URL -O packrat.zip
unzip -o packrat.zip
cd $CURRENT_DIR
# Initial packrat restore (so we don't have to do it later on!)
echo ">>>>>>> Initial dependency initialization (1/2) ..."
cd $installation_folder/pcago/
$installation_folder/R/R --vanilla -f packrat/init.R --args --bootstrap-packrat &
pid=$!
trap "kill $pid" TERM
wait
echo ">>>>>>> Initial dependency initialization (2/2) ..."
echo "
source('packrat/init.R')
packrat::restore()
" | $installation_folder/R/R --vanilla &
pid=$!
trap "kill $pid" TERM
wait
cd $CURRENT_DIR
# NPM install
echo ">>>>>>> NPM initialization ..."
cd $installation_folder/pcago-electron/
npm install
cd $CURRENT_DIR
# Install starter files
cat > $installation_folder/pcago-server.sh <<EOL
#!/bin/bash
#
# Runs a PCAGO server in terminal
#
cd pcago
echo -e "source('packrat/init.R')\nshiny::runApp()" | ./R --vanilla
EOL
cat > $installation_folder/pcago-electron.sh <<EOL
#!/bin/bash
#
# Runs a PCAGO electron application
#
cd pcago-electron
npm start
EOL
chmod +x $installation_folder/pcago-electron.sh
chmod +x $installation_folder/pcago-server.sh
cp icon.svg $installation_folder
cat > $installation_folder/PCAGO.desktop <<EOL
[Desktop Entry]
Name=PCAGO
Exec=$installation_folder/pcago-electron.sh
Path=$installation_folder
Icon=$installation_folder/icon.svg
Type=Application
Categories=Science;
EOL