Skip to content

Instantly share code, notes, and snippets.

@howiezhao
Last active April 17, 2022 09:06
Show Gist options
  • Save howiezhao/2c813bf46960c8f7f03e920a8ef4dcab to your computer and use it in GitHub Desktop.
Save howiezhao/2c813bf46960c8f7f03e920a8ef4dcab to your computer and use it in GitHub Desktop.
A Ubuntu/macOS new environment installation script
#!/bin/bash
echo "---------------A Ubuntu/macOS new environment installation script---------------"
echo "---------------Install and Run: bash <(curl -L -s url)---------------"
go_version=1.16.3
wpsoffice_version1=9615
wpsoffice_version2=11.1.0.9615
vagrant_version=2.2.9
fiddler_version=0.5.0
aptUpdate(){
sudo apt update -y
sudo apt upgrade -y
}
aptInstall(){
echo "---------------Install command line software from apt:---------------"
sudo apt install -y build-essential binutils cmake clang python-pip python3-pip openssh-server tmux \
proxychains4 vim zsh ibus-rime autojump neofetch gdb gdbserver tcpdump qemu qemu-kvm libvirt-dev \
htop tree whois ascii unicode p7zip-full p7zip-rar ranger hackrf graphviz aria2 silversearcher-ag \
shellcheck
echo "---------------Install GUI software from apt:---------------"
sudo apt install -y chromium-browser chromium-chromedriver wireshark virt-manager meld mtr \
obs-studio steam-installer remmina boinc-client boinc-manager
}
aptInstallNodejs(){
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
}
snapInstall(){
echo "---------------Install GUI software from snap:---------------"
sudo snap install --classic skype
sudo snap install --classic telegram-desktop
sudo snap install --classic code
sudo snap install --classic postman
sudo snap install --classic ipfs-desktop
sudo snap install --classic scrcpy
sudo snap install --classic thunderbird
sudo snap install --classic --stable intellij-idea-ultimate
sudo snap install --classic --stable pycharm-professional
sudo snap install --classic --stable clion
sudo snap install --classic --stable goland
}
installOther(){
sudo apt install -y python-dev python3-dev libgmp3-dev gnome-tweaks chrome-gnome-shell software-properties-common
}
addPPAs(){
sudo add-apt-repository -y ppa:bladerf/bladerf
sudo add-apt-repository -y ppa:myriadrf/drivers
sudo add-apt-repository -y ppa:myriadrf/gnuradio
sudo add-apt-repository -y ppa:gqrx/gqrx-sdr
sudo apt-add-repository --yes --update ppa:ansible/ansible
}
checkDevEnv(){
ghc --version ; stack --version ; go version ; node -v ; npm -v ; ruby -v ; gem -v
}
pip3Install(){
sudo pip3 install \
# Data
pandas xlrd
# Code quality
pylint flake8 black isort pre-commit yamllint \
# Document
jupyter sphinx sphinx-autobuild \
# Project management
pipenv cookiecutter pipreqs virtualenvwrapper \
# Other
ipdb mycli pytest youtube-dl httpie
}
npmInstall(){
sudo npm install -g markdownlint-cli hexo-cli conventional-changelog-cli reveal-md \
tldr nodemon yo nrm
}
cargoInstall(){
cargo install evcxr_jupyter tokei mdbook bat
}
aptInstallSublime(){
echo "---------------Install the GPG key:---------------"
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "---------------Ensure apt is set up to work with https sources:---------------"
sudo apt install apt-transport-https
echo "---------------Select the Stable channel to use:---------------"
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
echo "---------------Update apt sources and install Sublime Text:---------------"
sudo apt update
sudo apt install sublime-text
}
aptInstallAnyDesk(){
echo "---------------Install the GPG key:---------------"
wget -qO - https://keys.anydesk.com/repos/DEB-GPG-KEY | apt-key add -
echo "---------------Add the Repository:---------------"
echo "deb http://deb.anydesk.com/ all main" > /etc/apt/sources.list.d/anydesk-stable.list
echo "---------------Update apt sources and install AnyDesk:---------------"
apt update
apt install anydesk
}
aptInstallAlbert(){
echo "---------------Install the GPG key:---------------"
curl https://build.opensuse.org/projects/home:manuelschneid3r/public_key | sudo apt-key add -
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_18.04/ /' > /etc/apt/sources.list.d/home:manuelschneid3r.list"
wget -nv https://download.opensuse.org/repositories/home:manuelschneid3r/xUbuntu_18.04/Release.key -O Release.key
sudo apt-key add - < Release.key
rm -rf Release.key
echo "---------------Update apt sources and install Albert:---------------"
sudo apt update
sudo apt install albert
}
installWPSOffice(){
wget -P /tmp http://wdl1.pcfg.cache.wpscdn.com/wpsdl/wpsoffice/download/linux/${wpsoffice_version1}/wps-office_${wpsoffice_version2}.XA_amd64.deb
sudo dpkg -i /tmp/wps-office_${wpsoffice_version}.XA_amd64.deb
echo "---------------Fix WPSOffice fonts bug:---------------"
git clone https://github.com/iamdh4/ttf-wps-fonts.git /tmp/ttf-wps-fonts
sudo /tmp/ttf-wps-fonts/install.sh
}
installBTSync(){
wget https://web.archive.org/web/20150801113642/http://syncapp.bittorrent.com/1.4.111/btsync_x64-1.4.111.tar.gz
mkdir btsync_x64-1.4.11
cd btsync_x64-1.4.11
tar -zxvf ../btsync_x64-1.4.111.tar.gz
}
installVagrant(){
wget -P /tmp https://releases.hashicorp.com/vagrant/${vagrant_version}/vagrant_${vagrant_version}_x86_64.deb
sudo dpkg -i /tmp/vagrant_${vagrant_version}_x86_64.deb
}
installFiddlerEverywhere(){
wget https://downloads.getfiddler.com/linux/progress-telerik-fiddler-${fiddler_version}.AppImage
chmod +x progress-telerik-fiddler-${fiddler_version}.AppImage
}
brewInstall(){
brew install wget htop tmux tree neofetch proxychains-ng telnet ifstat ripgrep ncdu \
# Dev
pyenv nvm haskell-stack lua luarocks icdiff \
# Other
redis #?
}
brewCaskInstall(){
brew install --cask \
# Essential software
shadowsocksx-ng v2rayu google-chrome keka iina scroll-reverser sublime-text qbittorrent thunder xbar \
# Universal software
skype zoom steam microsoft-remote-desktop baidunetdisk sunloginclient \
# Development software
iterm2 docker jetbrains-toolbox tunnelblick postman meld vmware-fusion dash wireshark visual-studio-code wechatwebdevtools \
# Other
fliqlo
}
postInstall(){
mkdir ~/work
mkdir ~/github
mkdir ~/github/gist
git config --global user.email "howiezhaohr@hotmail.com"
git config --global user.name "howiezhao"
git config --global icdiff.options '--highlight --line-numbers'
git clone git@gist.github.com:2c813bf46960c8f7f03e920a8ef4dcab.git ~/github/gist/2c813bf46960c8f7f03e920a8ef4dcab
git clone git@github.com:howiezhao/dotfiles.git ~/github/dotfiles
~/github/dotfiles/link.sh
}
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "---------------Ubuntu system detected:---------------"
echo "---------------Update and Upgrade:---------------"
aptUpdate
aptInstall
echo "---------------Install and configure development environment:---------------"
echo "---------------Install Node.js LTS:---------------"
aptInstallNodejs
echo "---------------Install Haskell Stack:---------------"
curl -sSL https://get.haskellstack.org/ | sh
echo "---------------Install Go ${go_version}:---------------"
wget https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go${go_version}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo "---------------Install Rust:---------------"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Version Older
# sudo apt install -y haskell-platform haskell-stack golang-go nodejs npm ruby-full
snapInstall
echo "---------------Install other tools:---------------"
installOther
echo "---------------Add PPAs:---------------"
addPPAs
sudo apt update
echo "---------------Install software from PPAs:---------------"
sudo apt install -y gqrx-sdr
sudo apt install ansible
echo "---------------Fix GNU Radio Bug:---------------"
# Refer: https://askubuntu.com/questions/1159230/gnuradio-package-annoyance
sudo rm /usr/share/mime/packages/gnuradio.xml
sudo ln -s /usr/share/gnuradio/grc/freedesktop/gnuradio-grc.xml /usr/share/mime/packages/gnuradio.xml
echo "---------------Check development environment:---------------"
checkDevEnv
echo "---------------Install python package from pip:---------------"
pip3Install
echo "---------------Install node package from npm:---------------"
npmInstall
echo "---------------Install rust package from cargo:---------------"
cargoInstall
echo "---------------Install other software:---------------"
echo "---------------Install Sublime Text 3:---------------"
aptInstallSublime
echo "---------------Install AnyDesk:---------------"
aptInstallAnyDesk
echo "---------------Install Albert:---------------"
aptInstallAlbert
echo "---------------Install WPSOffice ${wpsoffice_version}:---------------"
installWPSOffice
echo "---------------Install BTSync 1.4.111:---------------"
installBTSync
echo "---------------Install Vagrant ${vagrant_version}:---------------"
installVagrant
echo "---------------Install Fiddler Everywhere ${fiddler_version}:---------------"
installFiddlerEverywhere
echo "---------------Configure history display time:---------------"
touch /etc/profile.d/custom_histformat.sh
echo 'HISTTIMEFORMAT="%F %T "' >> /etc/profile.d/custom_histformat.sh
echo "---------------Successful!---------------"
echo "Then you should install GNOME Extensions: system-monitor, TopIcons Plus"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "---------------macOS system detected:---------------"
echo "---------------macOS settings:---------------"
echo "---------------Allow any source:---------------"
sudo spctl --master-disable
echo "---------------Install Xcode Command Line Tools:---------------"
xcode-select --install
sudo xcodebuild -license accrpt
echo "---------------Install Homebrew:---------------"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew update
brewInstall
brewCaskInstall
pip3Install
npmInstall
cargoInstall
postInstall
echo "---------------Configure history display time:---------------"
sudo chmod 446 /etc/profile
echo 'HISTTIMEFORMAT="%F %T "' >> /etc/profile
sudo chmod 444 /etc/profile
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment