This repository was archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
135 lines (110 loc) · 3.36 KB
/
setup.sh
File metadata and controls
135 lines (110 loc) · 3.36 KB
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
134
135
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELL='\033[0;33m'
BLU='\033[0;34m'
NC='\033[0m' # No Color
UBUNTU_VERSION="xenial"
MONGO_VERSION="3.2"
programs=(Nodejs Foreverjs MongoDB python build-essential yarn)
function _installNvm {
printInstallingMessage "nvm"
dest_script=/tmp/nvm_installer.sh
wget -O $dest_script https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh
chmod 755 $dest_script
$dest_script
rm $dest_script
}
function printInstallingMessage {
printf "${GREEN}Installing $1...${NC}\n"
}
function installYarn {
if [ -f $HOME/.yarn ]; then
echo "Yarn already installed"
return
fi
printInstallingMessage "yarn"
dest_script=/tmp/yarn_installer.sh
wget -O $dest_script https://yarnpkg.com/install.sh
chmod 755 $dest_script
$dest_script
rm $dest_script
}
function installPython {
printInstallingMessage "python Ubuntu package"
sudo apt-get --yes install python
}
function installBuildEssential {
printInstallingMessage "build-essential Ubuntu package"
sudo apt-get --yes install build-essential
}
function installNode {
_installNvm
printInstallingMessage Nodejs
#This export is useful to avoid logout and reconnect
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install node
}
function installMongo {
printInstallingMessage MongoDB
# Import the public key used by the package management system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# Create a list file for MongoDB
echo "deb http://repo.mongodb.org/apt/ubuntu $UBUNTU_VERSION/mongodb-org/$MONGO_VERSION multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-$MONGO_VERSION.list
# Reload local package database.
sudo apt-get update
# Install the MongoDB packages
sudo apt-get install -y mongodb-org
sudo cp -af systemd-services/mongodb.service /etc/systemd/system/
sudo systemctl enable mongodb
sudo systemctl start mongodb
}
function installForever {
printInstallingMessage Foreverjs
npm i -g forever
}
function install {
install=false
while true; do
read -p "Do you wish to install $1? [y/n] " yn
case $yn in
[Yy]* ) install=true; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
if [ $install = true ]
then
case $1 in
build-essential) installBuildEssential;;
python) installPython;;
Nodejs) installNode;;
Foreverjs) installForever;;
MongoDB) installMongo;;
yarn) installYarn;;
esac
fi
}
# Fix for language problem
export LC_ALL=C
sudo echo "LC_ALL=en_US.UTF-8" > /etc/default/locale
sudo echo "LANGUAGE=en_US" >> /etc/default/locale
sudo echo "LANG=en_US.UTF-8" >> /etc/default/locale
# Adding nodejs user
sudo useradd nodejs -m -s /bin/bash
# Installing ssl script
mkdir ~/.bons
curl -O https://raw.githubusercontent.com/bons/b-bash-scripts/master/scripts/ssl.sh
mv ssl.sh ~/.bons
chmod 755 ~/.bons/ssl.sh
sudo ln -s ~/.bons/ssl.sh /usr/local/bin/b-ssl
# Updating apt
sudo apt-get update
for i in "${programs[@]}"
do
install $i
done
printf "${GREEN}Setup completed, enjoy! ^^${NC}\n"
printf "Please use the user ${YELL}nodejs${NC} to run your nodejs process\n connect as nodejs using ${BLU}sudo su nodejs${NC}, add your public ssh key if you want\n"
printf "Note that if you want to use ${YELL}yarn${NC} or ${YELL}nvm${NC} you most logout and reconnect\n"