dotfiles/instala.sh

250 lines
8.0 KiB
Bash
Executable File

#!/bin/bash
#
# Author:: drymer <drymer [ EN ] autistici.org>
# Copyright:: Copyright (c) 2016, drymer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
os=$(grep "^ID" /etc/os-release | cut -d'=' -f2)
root=$(pwd)
if [[ $os = "slackware" ]]
then
instalador="sbopkg -i "
elif [[ $os = "debian" ]]
then
instalador="apt-get install "
else
echo "No se soporta este SO, a cascarla."
exit 1
fi
# da error, mirar
if [[ $1 = "conf" ]]
then
if [[ $2 = "all" ]]
then
bash instala.sh conf X
bash instala.sh conf i3
bash instala.sh conf tmux
bash instala.sh conf qutebrowser
bash instala.sh conf emacs
bash instala.sh conf fonts
bash instala.sh conf pypi
elif [[ $2 = "X" ]]
then
ln -sf $(pwd)/Xdefaults $HOME/.Xdefaults
ln -sf $(pwd)/Xmodmap $HOME/.Xmodmap
ln -s $(pwd)/compton.conf $HOME/.compton.conf
elif [[ $2 = "i3" ]]
then
ln -sf $(pwd)/i3 $HOME/.i3
ln -sf $(pwd)/i3/i3blocks.conf $HOME/.i3blocks.conf
elif [[ $2 = "neomutt" ]]
then
ln -sf $(pwd)/mutt $HOME/.mutt
ln -sf $(pwd)/mutt/muttrc.example $HOME/.muttrc
ln -sf $(pwd)/mutt/offlineimaprc.example $HOME/.offlineimaprc
elif [[ $2 = "tmux" ]]
then
ln -sf $(pwd)/tmux.conf $HOME/.tmux.conf
elif [[ $2 = "qutebrowser" ]]
then
mkdir -p $HOME/.config/qutebrowser/
ln -sf $(pwd)/qutebrowser/{qutebrowser.conf,keys.conf} $HOME/.config/qutebrowser/
echo "Necesito permiso de superusuaria para copiar los archivos hosts, capture y umpv a su sitio."
#sudo ln -sf $(pwd)/qutebrowser/{capture,umpv} /usr/local/bin/
#sudo ln -sf $(pwd)/qutebrwoser/hosts/ /etc/hosts
elif [[ $2 = "emacs" ]]
then
# Establece el directorio de las configuraciones, lo crea y las copia ahí
EMACSDIR="$HOME/.emacs.d"
mkdir -p $EMACSDIR
ln -sf $(pwd)/emacs.d/{init.el,init-literate.org} $EMACSDIR
# crear private-literate.org si no existe para que no se queje init.el
if [[ ! -e $EMACSDIR/private-literate.org ]]
then
echo -e "* Vacio\n#+BEGIN_SRC emacs-lisp\n#+END_SRC" > $EMACSDIR/private-literate.org
fi
# Instalar todos los paquetes de emacs
emacs -Q --batch --eval "(load-file \""$EMACSDIR/"init.el\")"
# Por algún motivo al compilar desde el-get mete una ruta incorrecta en org-loaddefs.el
sed -i "s,org-mode-maint/lisp/,,g" $EMACSDIR/el-get/org-mode-maint/lisp/org-loaddefs.el
echo "Necesito permiso de superusuario para copiar los scripts capture y demacs en /usr/local/bin/"
#sudo ln -sf $(pwd)/emacs.d/{capture,demacs} /usr/local/bin/
elif [[ $2 = "shell" ]]
then
ln -sf $(pwd)/shell/zsh_custom_themes/* $HOME/.oh-my-zsh/custom/themes/
ln -sf $(pwd)/shell/aliases $HOME/.aliases
ln -sf $(pwd)/shell/bashrc $HOME/.bashrc
ln -sf $(pwd)/shell/zshrc $HOME/.zshrc
elif [[ $2 = "pypi" ]]
then
echo """
export WORKON_HOME=~/.virtualenvs
mkdir -p $WORKON_HOME
source `which virtualenvwrapper.sh` > /dev/null
""" >> $HOME/.bashrc
echo """
export WORKON_HOME=~/.virtualenvs
mkdir -p $WORKON_HOME
source `which virtualenvwrapper.sh` > /dev/null
""" >> $HOME/.zshrc
export WORKON_HOME=~/.virtualenvs
source `which virtualenvwrapper.sh`
echo "pip install jedi rope importmagic autopep8 yapf" >> $WORKON_HOME/postmkvirtualenv
elif [[ $2 = "" ]]
then
echo "./instala.sh conf {all, X, i3, tmux, qutebrowser, emacs, shell, pypi}"
else
echo "No existe ese parámetro. Escoge: {all, X, i3, tmux, qutebrowser, emacs, shell, pypi}"
fi
elif [[ $1 = "prog" ]]
then
if [[ $2 = "all" ]]
then
bash instala.sh prog i3
bash instala.sh prog mutt
bash instala.sh prog tmux
bash instala.sh prog qutebrowser
bash instala.sh prog emacs
bash instala.sh prog fonts
bash instala.sh prog pypi
bash instala.sh prog shell
cat /tmp/dotfiles_construido
elif [[ $2 = "i3" ]]
then
git clone --recursive https://github.com/Airblader/xcb-util-xrm.git $root/programas/xcb-util-xrm
cd $root/programas/xcb-util-xrm
./autogen.sh
./configure
make && echo "$2 construido correctamente" > /tmp/dotfiles_construido
#sudo make install
git clone https://github.com/Airblader/i3 $root/programas/i3-gaps
cd $root/programas/i3-gaps/
git checkout gaps-next
autoreconf --force --install
mkdir -p build && cd build/
autoreconf --force --install
../configure --prefix=/usr/local --sysconfdir=/etc --disable-sanitizers
make && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
git clone https://github.com/Airblader/i3blocks-gaps $root/programas/i3blocks-gaps/
cd $root/programas/i3blocks-gaps/
make all && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
echo "Puede que falten más dependencias, depende de la distro. Deberian estar todas en los repositorios oficiales."
elif [[ $2 = "mutt" ]]
then
git clone https://github.com/neomutt/neomutt $root/programas/neomutt/
cd $root/programas/neomutt/
./prepare --prefix=/usr/local --sysconfdir=/etc --enable-debug --enable-notmuch --enable-smtp --enable-hcache --enable-sidebar --with-ssl=/usr --with-curses=/usr --with-regex --with-sasl --enable-imap --enable-pop --with-idn --enable-gpgme --with-gpgme-prefix=/usr/ --disable-fmemopen
# make && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
elif [[ $2 = "tmux" ]]
then
# if [[ $os = "slackware" ]]
# then
# #sudo slackpkg install tmux
# else
# #sudo apt-get install tmux
echo lol1
elif [[ $2 = "qutebrowser" ]]
then
sudo $instalador libxkbcommon libinput qt5 qt5-webkit python3-PyQt5 python3-sip
#sudo pip3 install qutebrowser
elif [[ $2 = "emacs" ]]
then
git clone git://git.sv.gnu.org/emacs.git $root/programas/emacs/
cd $root/programas/emacs/
git checkout -b emacs-25
./autogen.sh
./configure
make bootstrap && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
elif [[ $2 = "fonts" ]]
then
FONTDIR="$HOME/.local/share/fonts"
mkdir -p $HOME/.local/share/
ln -fs $(pwd)/fonts/ $HOME/.local/share/
fc-cache -fv $FONTDIR
# las cuatro siguientes no se si son necesarias, pero es gratis ponerlas
fc-cache -fv $FONTDIR/misc
fc-cache -fv $FONTDIR/ohsnap
fc-cache -fv $FONTDIR/tewi
fc-cache -fv $FONTDIR/terminesspowerline
xset +fp $FONTDIR/
# las cuatro siguientes no se si son necesarias, pero es gratis ponerlas
xset +fp $FONTDIR/misc
xset +fp $FONTDIR/ohsnap
xset +fp $FONTDIR/tewi
xset +fp $FONTDIR/terminesspowerline
xset fp rehash
elif [[ $2 = "pypi" ]]
then
echo lol2
#sudo pip3 install rope importmagic autopep8 yapf Nikola Nikola[extras] mps-youtube youtube-dl speedtest-cli twine setuptools
#sudo pip2 install rope importmagic autopep8 yapf virtualenv virtualenvwrapper setuptools
elif [[ $2 = "shell" ]]
then
git clone https://github.com/thestinger/vte-ng $root/programas/vte-ng/
cd $root/programas/vte-ng
./autogen.sh
./configure
make && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
git clone https://github.com/thestinger/termite.git $root/programas/termite/
cd $root/programas/termite
./autogen.sh
./configure
make && echo "$2 construido correctamente" >> /tmp/dotfiles_construido
#sudo make install
cd $root
git clone https://github.com/robbyrussell/oh-my-zsh.git $root/programas/oh-my-zsh/
ln -s $root/programas/oh-my-zsh/ $HOME/.oh-my-zsh/
chsh -s /bin/zsh
elif [[ $2 = "" ]]
then
echo "./instala.sh conf {all, X, i3, tmux, qutebrowser, emacs, fonts, pypi, shell}"
else
echo "No existe ese parámetro. Escoge: {all, X, i3, tmux, qutebrowser, emacs, fonts, pypi, shell}"
fi
fi