Last active
December 3, 2018 12:27
-
-
Save pfernique/a40bfcff530efd1bc37454e92bc7645c to your computer and use it in GitHub Desktop.
Ubuntu configuration script
This file contains 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
*.sublime-workspace |
This file contains 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
set -v | |
export PID=`pwd` | |
source env.sh | |
if [[ -d ${HOME}/.local/opt ]]; then | |
rm -rf ${HOME}/.local/opt | |
fi | |
if [[ -d ${HOME}/.local/bin ]]; then | |
rm -rf ${HOME}/.local/bin | |
fi | |
if [[ -d ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION} ]]; then | |
rm -rf ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION} | |
fi | |
sudo sed -i 's/sublime_text/gedit/g' /usr/share/applications/defaults.list | |
sudo sed -i 's/sublime_text/gedit/g' /etc/gnome/defaults.list | |
if [[ -d ${CONDA_PREFIX}/.conda ]]; then | |
rm -rf ${HOME}/.conda | |
fi | |
rm -rf ${HOME}/.conda | |
if [[ -d ${CONDA_PREFIX} ]]; then | |
rm -rf ${CONDA_PREFIX} | |
fi | |
set +v |
This file contains 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
set -v | |
export PID=$(pwd) | |
source env.sh | |
sudo apt-get remove git -y | |
# Install Google Chrome | |
which google-chrome | |
if [[ ! "$?" = "0" ]]; then | |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
sudo dpkg -i google-chrome-stable_current_amd64.deb | |
fi | |
# Install Curl | |
which curl | |
if [[ ! "$?" = "0" ]]; then | |
sudo apt install curl -y | |
fi | |
# Install Git | |
which git | |
if [[ ! "$?" = "0" ]]; then | |
sudo apt install git -y | |
fi | |
git config --global user.email "${EMAIL}" | |
git config --global user.name "${NAME}" | |
git config --global push.default simple | |
grep "export PS1=" ${HOME}/.bashrc | |
if [[ ! "$?" = "0" ]]; then | |
echo "export PS1=\"\\\$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* master/\[\033[01;31m\][master] /' -e 's/* develop/\[\033[01;33m\][develop] /' -e 's/* \(.*\)/\[\033[01;32m\][\1] /' )\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ \"" >> ${HOME}/.bashrc | |
fi | |
make_local_opt() { | |
if [[ ! -d ${HOME}/.local/opt ]]; then | |
mkdir ${HOME}/.local/opt | |
fi | |
} | |
make_local_bin() { | |
if [[ ! -d ${HOME}/.local/bin ]]; then | |
mkdir ${HOME}/.local/bin | |
echo "export PATH=${HOME}/.local/bin:"'${PATH}' >> ${HOME}/.bashrc | |
fi | |
} | |
# Install Sublime Text | |
if [[ ! -f ${HOME}/.local/bin/sublime_text ]]; then | |
if [[ ! -d sublime_text_${SUBLIME_TEXT_VERSION} ]]; then | |
if [[ ! -f sublime_text.tar.bz2 ]]; then | |
curl https://download.sublimetext.com/sublime_text_${SUBLIME_TEXT_VERSION}_build_${SUBLIME_TEXT_BUILD}_x64.tar.bz2 -o sublime_text.tar.bz2 | |
fi | |
tar xvjf sublime_text.tar.bz2 | |
rm sublime_text.tar.bz2 | |
fi | |
make_local_opt | |
mv sublime_text_${SUBLIME_TEXT_VERSION} ${HOME}/.local/opt/ | |
make_local_bin | |
ln -s ${HOME}/.local/opt/sublime_text_${SUBLIME_TEXT_VERSION}/sublime_text ${HOME}/.local/bin/sublime_text | |
cp ${HOME}/.local/opt/sublime_text_${SUBLIME_TEXT_VERSION}/sublime_text.desktop ${HOME}/.local/share/applications | |
sed -i "s#Exec=/opt/sublime_text/sublime_text#Exec=${HOME}/.local/opt/sublime_text_${SUBLIME_TEXT_VERSION}/sublime_text#g" ${HOME}/.local/share/applications/sublime_text.desktop | |
sed -i "s#Icon=sublime-text#Icon=${HOME}/.local/opt/sublime_text_${SUBLIME_TEXT_VERSION}/Icon/48x48/sublime-text.png#g" ${HOME}/.local/share/applications/sublime_text.desktop | |
sudo sed -i 's/gedit/sublime_text/g' /usr/share/applications/defaults.list | |
sudo sed -i 's/gedit/sublime_text/g' /etc/gnome/defaults.list | |
if [[ ! -d ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION} ]]; then | |
mkdir ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION} | |
fi | |
if [[ ! -d ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION}/Packages ]]; then | |
mkdir ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION}/Packages | |
fi | |
if [[ ! -d ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION}/Packages/User ]]; then | |
mkdir ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION}/Packages/User | |
fi | |
cd ${HOME}/.config/sublime-text-${SUBLIME_TEXT_VERSION}/Packages/User | |
echo '// Settings in here override those in "Default/Preferences.sublime-settings",' > Preferences.sublime-settings | |
echo '// and are overridden in turn by syntax-specific settings.' >> Preferences.sublime-settings | |
echo '{' >> Preferences.sublime-settings | |
echo ' "tab_size": 4,' >> Preferences.sublime-settings | |
echo ' "remember_open_files": false,' >> Preferences.sublime-settings | |
echo ' "hot_exit": false,' >> Preferences.sublime-settings | |
echo ' "translate_tabs_to_spaces": true,' >> Preferences.sublime-settings | |
echo '}' >> Preferences.sublime-settings | |
cd ../../ | |
if [[ ! -d "Installed Packages" ]]; then | |
mkdir "Installed Packages" | |
fi | |
cd "Installed Packages" | |
curl https://packagecontrol.io/Package%20Control.sublime-package -o "Package Control.sublime-package" | |
cd ../Packages/User | |
echo '{' > "Package Control.sublime-settings" | |
echo ' "installed_packages":' >> "Package Control.sublime-settings" | |
echo ' [' >> "Package Control.sublime-settings" | |
echo ' "Terminal",' >> "Package Control.sublime-settings" | |
echo ' "Git",' >> "Package Control.sublime-settings" | |
echo ' "ProjectManager",' >> "Package Control.sublime-settings" | |
echo ' ]' >> "Package Control.sublime-settings" | |
echo '}' >> "Package Control.sublime-settings" | |
cd ${PID} | |
fi | |
conda activate | |
if [[ ! "$?" = "0" ]]; then | |
curl https://repo.continuum.io/miniconda/Miniconda${CONDA_VERSION}-latest-Linux-x86_64.sh -o miniconda.sh | |
chmod a+rwx miniconda.sh | |
./miniconda.sh -b -p ${CONDA_PREFIX} | |
rm miniconda.sh | |
grep "source ${CONDA_PREFIX}/etc/profile.d/conda.sh" ${HOME}/.bashrc | |
if [[ ! "$?" = "0" ]]; then | |
echo "source ${CONDA_PREFIX}/etc/profile.d/conda.sh" >> ${HOME}/.bashrc | |
fi | |
source ${CONDA_PREFIX}/etc/profile.d/conda.sh | |
conda activate | |
conda install conda-build anaconda-client conda-verify -y | |
conda create -n py2k python=2 -y | |
conda activate py2k | |
conda install ipython jupyter -y | |
conda deactivate | |
conda create -n py3k python=3 -y | |
conda activate py3k | |
conda install ipython jupyter -y | |
conda deactivate | |
fi | |
conda deactivate | |
grep "machine github.com" ${HOME}/.netrc | |
if [[ ! "$?" = "0" ]]; then | |
echo "machine github.com" >> ${HOME}/.netrc | |
echo "login ${GITHUB_LOGIN}" >> ${HOME}/.netrc | |
echo "Password for 'https://${GITHUB_LOGIN}@github.com': " | |
read -s GITHUB_PASSWORD | |
echo "password ${GITHUB_PASSWORD}" >> ${HOME}/.netrc | |
echo "machine gist.github.com" >> ${HOME}/.netrc | |
echo "login ${GITHUB_LOGIN}" >> ${HOME}/.netrc | |
echo "password ${GITHUB_PASSWORD}" >> ${HOME}/.netrc | |
fi | |
grep "machine gitlab.inria.fr" ${HOME}/.netrc | |
if [[ ! "$?" = "0" ]]; then | |
echo "machine gitlab.inria.fr" >> ${HOME}/.netrc | |
echo "login ${GITLAB_LOGIN}" >> ${HOME}/.netrc | |
echo "Password for 'https://${GITLAB_LOGIN}@gitlab.inria.fr': " | |
read -s GITLAB_PASSWORD | |
echo "password ${GITLAB_PASSWORD}" >> ${HOME}/.netrc | |
fi | |
if [[ ! -d ${HOME}/Desktop/develop ]]; then | |
mkdir ${HOME}/Desktop/develop | |
fi | |
rm ${HOME}/examples.desktop | |
if [[ ! "$XDG_CURRENT_DESKTOP" = "Unity" ]] | |
then | |
gsettings set org.gnome.shell favorite-apps "['org.gnome.Terminal.desktop', 'google-chrome.desktop', 'org.gnome.Nautilus.desktop']" | |
rm ~/.local/share/gnome-shell/extensions | |
curl "https://github.com/brunelli/gnome-shell-extension-installer/raw/master/gnome-shell-extension-installer" -L -o gnome-shell-extension-installer | |
chmod a+rwx gnome-shell-extension-installer | |
./gnome-shell-extension-installer 484 | |
./gnome-shell-extension-installer 517 | |
rm gnome-shell-extension-installer | |
gsettings set org.gnome.shell.app-switcher current-workspace-only "true" | |
gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces "true" | |
gsettings set org.gnome.desktop.wm.preferences num-workspaces "4" | |
gsettings set org.gnome.mutter dynamic-workspaces "false" | |
gsettings set org.gnome.mutter workspaces-only-on-primary "false" | |
gsettings set org.gnome.shell enabled-extensions "['workspace-grid@mathematical.coffee.gmail.com', 'ubuntu-appindicators@ubuntu.com']" | |
dconf write /org/gnome/shell/extensions/workspace-grid/num-columns 2 | |
dconf write /org/gnome/shell/extensions/workspace-grid/num-rows 2 | |
dconf write /org/gnome/shell/extensions/workspace-grid/show-workspace-labels false | |
fi | |
# Install docker | |
docker --help | |
if [[ ! "$?" = "0" ]]; then | |
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 0EBFCD88 | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce -y | |
fi | |
echo "Your system need to restart now, do you want to continue [y|N]?" | |
read -s RESTART | |
if [[ "$RESTART" = "y" || "$RESTART" = "Y" ]]; then | |
sudo reboot | |
fi | |
set +v |
This file contains 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
export SUBLIME_TEXT_VERSION=3 | |
export SUBLIME_TEXT_BUILD=3176 | |
export CONDA_VERSION=3 | |
export CONDA_PREFIX=${HOME}/Desktop/miniconda | |
export EMAIL="pfernique@gmail.com" | |
export NAME="Pierre Fernique" | |
export GITHUB_LOGIN="pfernique" | |
export GITLAB_LOGIN="pferni" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment