Skip to content

Instantly share code, notes, and snippets.

@aaripurna
Last active June 2, 2019 07:33
Show Gist options
  • Save aaripurna/08d7ae9fc2d4ff39980d9c6387c99b1b to your computer and use it in GitHub Desktop.
Save aaripurna/08d7ae9fc2d4ff39980d9c6387c99b1b to your computer and use it in GitHub Desktop.
quick setup development setup for ubuntu derivatives distros
#!/bin/bash
set -e
update() {
sudo apt update #&& sudo apt upgrade -y
}
credential() {
sudo apt install make g++ git curl redis-server libgmp3-dev zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev postgresql postgresql-contrib libpq-dev -y
sudo systemctl start redis
}
node() {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
cat <<- "EOF" | tee output.txt
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" # This loads nvm bash_completion
EOF
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
$NVM_DIR install 10 && $NVM_DIR use 10 && npm install -g yarn
}
ruby() {
git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
cd $HOME/.rbenv && src/configure && make -C src
cat <<- "EOF" | tee -a $HOME/output.txt $(profile)
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
EOF
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 2.6.3 && rbenv global 2.6.3
gem install bundler && gem install nokogiri && gem install rails
}
zsh() {
sudo apt install zsh -y && sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
cat $HOME/output.txt | tee -a $HOME/.zshrc
}
profile() {
prof=$SHELL
if [ "$prof" = "/bin/bash" ]; then
echo $HOME/.bashrc
elif [ "$prof" = "/usr/bin/zsh" ]; then
echo $HOME/.zshrc
else
exit 1
fi
}
c-git() {
read -p "Name : " name
read -p "Email: " email
sudo apt install git
git config --global user.name $name
git config --global user.email $email
}
g-ssh() {
read -p "git email addrees : " email
ssh-keygen -t rsa -b 4096 -C $email
sudo apt install xclip -y
cat $HOME/.ssh/id_rsa.pub | xclip -selection clipboard
}
guide() {
cat << "EOF"
setup [OPTION]
[OPTION]
--update: for running update and upgrade script
--ruby : for installing ruby and rails through rbenv
--node : for installing node and yarn through nvm
--help : to show guide of the script
--all : to setup a complete development environment especially ruby on rails
--zsh : to install and configure zsh (oh my zsh) as default shell
--clean : auto remove unused package
--ssh : generate ssh key and copy it to the clipboard
--git : install and configure git
EOF
}
sublime() {
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
update
sudo apt install sublime-text
curl -L https://gist.githubusercontent.com/aaripurna/ec6a9eba2c004619274ebd4d273b62b8/raw -sSf | bash
}
clean() {
sudo apt autoremove -y
}
if [[ $# -eq 0 ]]; then
guide
elif [[ $1 == "--all" ]]; then
update
clean
credential
node
ruby
g-ssh
c-git
read -p "Do you want to install sublime text? (y/n) : " vstxt
if [[ "$vstxt" == "Y" ]] || [[ $svtxt == "y" ]]; then
sublime
fi
read -p "Do you want to install zsh? (y/n) :" vzsh
if [[ "$vzsh" == "y" ]] || [[ "$vzsh" == "Y" ]]; then
zsh
fi
read -p "I think you should reboot your PC now, Reboot? (y/n) : " vrb
if [[ "$vrb" == "Y" ]] || [[ "$vrb" == "y" ]]; then
reboot
fi
elif [[ $1 == "--node" ]]; then
node
elif [[ $1 == "--clean" ]]; then
clean
elif [[ $1 == "--ruby" ]]; then
ruby
elif [[ $1 == "--credential" ]]; then
credential
elif [[ $1 == "--zsh" ]]; then
zsh
elif [[ $1 == "--help" ]]; then
guide
elif [[ $1 == "--update" ]]; then
update
elif [[ $1 == "--ssh" ]]; then
g-ssh
elif [[ $1 == "--git" ]]; then
c-git
elif [[ $1 == "--sublime" ]]; then
sublime
else
cat << EOF
you typed wrong argumens
try setup --help
EOF
exit 1
fi
@aaripurna
Copy link
Author

aaripurna commented Jun 1, 2019

for auto setup

curl -L https://gist.githubusercontent.com/aaripurna/08d7ae9fc2d4ff39980d9c6387c99b1b/raw -sSf | bash -s -- --all

for download file

curl -o output -L https://gist.githubusercontent.com/aaripurna/08d7ae9fc2d4ff39980d9c6387c99b1b/raw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment