Last active
May 22, 2019 12:25
-
-
Save yusuf-khamis/670a81ea8a61d5bb8e0322a4bbe141c1 to your computer and use it in GitHub Desktop.
A script that installs the basic packages needed by a nodejs developer i.e. git, nvm and node, nginx, mysql and mysql workbench, redis, sql server and nodemon and @angular/cli npm packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
color=`tput setaf 2` | |
reset=`tput sgr0` | |
echo "${color}Script started, this script uses apt instead of apt-get${reset}" | |
#run apt update first | |
sudo apt update | |
#install git if not already installed | |
if [ -z "`which git`" ]; then | |
echo "${color}Installing Git${reset}" | |
sudo apt install git -y | |
fi | |
#get and run nvm script | |
echo "${color}Installing nvm${reset}" | |
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | |
#export so as to access nvm command | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | |
#install and activate latest stable version of node | |
echo "${color}Installing latest stable node version${reset}" | |
nvm install stable | |
nvm use stable | |
#install nodemon and @angular/cli and typescript | |
echo "${color}Installing nodemon and @angular/cli and typescript global npm packages${reset}" | |
npm install -g nodemon @angular/cli cross-env typescript | |
#Increase the number of watches nodemon can create | |
echo "${color}Increasing the number of watches that can be created by nodemon${reset}" | |
#src: https://stackoverflow.com/questions/34662574/node-js-getting-error-nodemon-internal-watch-failed-watch-enospc | |
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p | |
#install nginx server | |
echo "${color}Installing Nginx server${reset}" | |
sudo apt install nginx -y | |
#install and set up mysql server | |
echo "${color}Installing and configuring mysql-server${reset}" | |
sudo apt install mysql-server -y | |
mysql_secure_installation | |
#install mysql workbench | |
echo "${color}Installing mysql workbench${reset}" | |
sudo apt install mysql-workbench -y | |
#install sed if not installed | |
if [ -z "`which sed`" ]; then | |
echo "${color}Installing sed(Stream EDitor)${reset}" | |
sudo apt install sed --reinstall -y | |
fi | |
#install build tools | |
echo "${color}Installing build tools${reset}" | |
sudo apt install build-essential tcl -y | |
#install and set up redis | |
echo "${color}Downloading and installing redis${reset}" | |
wget http://download.redis.io/redis-stable.tar.gz | |
tar xzvf redis-stable.tar.gz | |
rm redis-stable.tar.gz | |
cd redis-stable | |
make | |
make test | |
sudo make install | |
echo "${color}Setting up redis${reset}" | |
sudo mkdir /etc/redis | |
sudo mkdir /var/redis | |
sudo cp utils/redis_init_script /etc/init.d/redis_6379 | |
sudo cp redis.conf /etc/redis/6379.conf | |
sudo mkdir /var/redis/6379 | |
sudo sed -i 's/daemonize no/daemonize yes/' /etc/redis/6379.conf | |
sudo sed -i 's/pidfile .*/pidfile \/var\/run\/redis_6379.pid/' /etc/redis/6379.conf | |
sudo sed -i 's/logfile .*/logfile \/var\/log\/redis_6379.log/' /etc/redis/6379.conf | |
sudo sed -i 's/dir .*/dir \/var\/redis\/6379/' /etc/redis/6379.conf | |
sudo update-rc.d redis_6379 defaults | |
sudo /etc/init.d/redis_6379 start | |
echo "${color}Started redis on port 6379${reset}" | |
echo "${color}Do you want to install MS SQL Server[y/n](y)?${reset}" | |
read yn | |
if [ $yn = "y" ] || [ $yn = "Y" ] || [ -z $yn ]; then | |
apt-get install -y libjemalloc1 libsss-nss-idmap0 libc++1 gawk curl | |
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - | |
add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)" | |
add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)" | |
wget http://archive.ubuntu.com/ubuntu/pool/main/c/ca-certificates/ca-certificates_20160104ubuntu1_all.deb | |
dpkg -i ca-certificates_20160104ubuntu1_all.deb | |
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb | |
dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb | |
apt install -y libcurl3 | |
apt update | |
apt install -y mssql-server | |
sudo /opt/mssql/bin/mssql-conf setup | |
fi | |
echo "${color}Script ended, bye...${reset}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment