2017-07-21 14:35:08 +02:00
|
|
|
# common.sh
|
|
|
|
|
2019-01-25 23:34:56 +01:00
|
|
|
ROCKETCHAT_VERSION=0.73.2
|
|
|
|
ROCKETCHAT_SHASUM=3dc3eb11f383f7b72b0f23fedb305b6a566fa536a1e5087a4398255deeb864d8
|
|
|
|
ROCKETCHAT_DOWNLOAD_URI=https://releases.rocket.chat/${ROCKETCHAT_VERSION}/download
|
|
|
|
NODE_VERSION=8.11.4
|
2018-10-05 21:53:49 +02:00
|
|
|
DEBIAN_ISSUE=$(grep 9 /etc/debian_version >/dev/null && echo stretch || echo jessie)
|
2017-07-21 14:35:08 +02:00
|
|
|
|
2017-11-27 21:45:46 +01:00
|
|
|
checkcmd() {
|
|
|
|
curl -m 1 -s localhost:$port$path/api/v1/info | \
|
|
|
|
python -c "import sys, json; print json.load(sys.stdin)['success']" 2>/dev/null | \
|
|
|
|
grep "True" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2017-07-21 14:35:08 +02:00
|
|
|
waitforservice() {
|
2017-11-27 21:45:46 +01:00
|
|
|
isup=false
|
|
|
|
x=90
|
|
|
|
while [ $x -gt 0 ]; do
|
|
|
|
echo "Waiting approx. $x seconds..."
|
|
|
|
x=$(( $x - 1 ))
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
if checkcmd; then
|
|
|
|
isup=true; break;
|
|
|
|
fi;
|
|
|
|
done
|
|
|
|
|
|
|
|
if $isup; then
|
|
|
|
echo "service is up"
|
|
|
|
else
|
|
|
|
ynh_die "$app could not be started"
|
|
|
|
fi
|
2017-09-04 22:24:56 +02:00
|
|
|
}
|
|
|
|
|
2018-01-10 17:21:46 +01:00
|
|
|
installnode(){
|
2018-10-09 13:03:49 +02:00
|
|
|
if [ $DEBIAN_ISSUE == "stretch" ]; then
|
2018-10-19 21:07:59 +02:00
|
|
|
sudo curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
|
|
|
|
sudo bash nodesource_setup.sh
|
2018-10-03 21:44:14 +02:00
|
|
|
sudo apt-get install -y nodejs
|
|
|
|
else
|
|
|
|
sudo apt-get install -y npm
|
2019-01-25 23:34:56 +01:00
|
|
|
# Using npm install inherits and n, and the node version required by Rocket.Chat:
|
|
|
|
sudo npm install -g inherits n
|
2018-10-19 21:07:59 +02:00
|
|
|
sudo n $NODE_VERSION
|
2018-10-03 21:44:14 +02:00
|
|
|
fi
|
2018-10-19 21:07:59 +02:00
|
|
|
echo "node version is now: "
|
|
|
|
node --version
|
2018-01-10 17:21:46 +01:00
|
|
|
}
|
|
|
|
|
2017-09-04 22:24:56 +02:00
|
|
|
installdeps(){
|
2017-09-28 20:40:20 +02:00
|
|
|
|
|
|
|
if [ $(dpkg --print-architecture) == "armhf" ]; then
|
|
|
|
#Install mongodb for debian armhf
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y mongodb-server
|
2019-01-25 23:34:56 +01:00
|
|
|
|
|
|
|
# start mongodb service
|
|
|
|
sudo systemctl enable mongodb.service
|
|
|
|
sudo systemctl start mongodb.service
|
|
|
|
|
|
|
|
# add mongodb to services
|
|
|
|
sudo yunohost service add mongodb -l /var/log/mongodb/mongodb.log
|
2017-09-28 20:40:20 +02:00
|
|
|
else
|
|
|
|
#Install mongodb for debian x86/x64
|
2019-01-25 23:34:56 +01:00
|
|
|
sudo apt-get install dirmngr && sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
|
2018-10-03 20:45:18 +02:00
|
|
|
echo "deb http://repo.mongodb.org/apt/debian ${DEBIAN_ISSUE}/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
|
2017-09-28 20:40:20 +02:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y mongodb-org
|
2017-09-04 22:24:56 +02:00
|
|
|
|
2019-01-25 23:34:56 +01:00
|
|
|
# start mongodb service
|
|
|
|
sudo systemctl enable mongod.service
|
|
|
|
sudo systemctl start mongod.service
|
2017-09-04 22:24:56 +02:00
|
|
|
|
2019-01-25 23:34:56 +01:00
|
|
|
# add mongodb to services
|
|
|
|
sudo yunohost service add mongod -l /var/log/mongodb/mongod.log
|
|
|
|
fi
|
2017-09-04 22:24:56 +02:00
|
|
|
|
2017-09-28 20:40:20 +02:00
|
|
|
#Install other dependencies
|
2019-01-25 23:34:56 +01:00
|
|
|
sudo apt-get install -y build-essential gzip curl graphicsmagick
|
2017-09-28 20:40:20 +02:00
|
|
|
|
2018-01-10 17:21:46 +01:00
|
|
|
installnode
|
2017-07-21 14:35:08 +02:00
|
|
|
}
|