2017-02-12 11:41:03 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Installs user preferences the way I like it
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
function prompt { # text
|
|
|
|
while true; do
|
|
|
|
read -p "$1 [yn] " yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]* ) return 1;;
|
|
|
|
[Nn]* ) return 0;;
|
|
|
|
* ) echo "Please answer yes or no.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't ask for things that are already there
|
2017-03-27 10:03:44 +02:00
|
|
|
TERMUX=0
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ -d /data/data/com.termux/files ]; then
|
2017-03-27 10:03:44 +02:00
|
|
|
TERMUX=1
|
|
|
|
GUI=0
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if which i3 &> /dev/null; then
|
2017-03-27 10:03:44 +02:00
|
|
|
GUI=1
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $ADMIN ]; then
|
|
|
|
prompt "Are you a superuser on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
ADMIN=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
if [ -z $GUI ]; then
|
|
|
|
prompt "Do you want a X environment on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
GUI=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
if [ -z $EXTRA ]; then
|
|
|
|
prompt "Do you want not-so-needed software on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
EXTRA=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# TODO Verify if the package exists before installing it
|
|
|
|
|
|
|
|
# System detection
|
|
|
|
if which pacman &> /dev/null; then
|
|
|
|
ARCH=1
|
|
|
|
if [ $ADMIN == 1 ]; then
|
|
|
|
sudo pacman -Sy
|
|
|
|
function installOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
sudo pacman -S $1 --noconfirm
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function installFileOne { # file
|
|
|
|
sudo pacman -U "$1"
|
|
|
|
}
|
2017-02-12 15:14:51 +01:00
|
|
|
if which yaourt &> /dev/null; then
|
2017-02-12 11:41:03 +01:00
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
yaourt -S "$1" --noconfirm
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# Install package from PKGBUILD file
|
|
|
|
function installPKGBUILD { # url
|
|
|
|
TMP_DIR="$(mktemp -d /tmp/pkgbuild.XXXXXXXXXX)"
|
|
|
|
cd "$TMP_DIR"
|
|
|
|
wget "$1" -O PKGBUILD
|
|
|
|
makepkg -si
|
|
|
|
cd -
|
|
|
|
rm -rf "$TMP_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "You're on a Arch System but it's not yours? Did Arch got that popular?"
|
|
|
|
return 42
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif which dpkg &> /dev/null; then
|
|
|
|
DEBIAN=1
|
|
|
|
if [[ $ADMIN == 1 || $TERMUX == 1 ]]; then
|
|
|
|
if [ $TERMUX == 1 ]; then
|
|
|
|
DEBIAN=0
|
|
|
|
apt update -y
|
|
|
|
else
|
|
|
|
sudo apt-get update -y
|
|
|
|
fi
|
|
|
|
function installOne { # package
|
|
|
|
|
|
|
|
# Finding out if it's already installed or not
|
|
|
|
STATUS=$(mktemp)
|
|
|
|
LANG=C dpkg-query --status $1 &> $STATUS
|
2017-03-27 10:03:44 +02:00
|
|
|
installed=0
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $? == 0 ]; then
|
|
|
|
cat $STATUS | grep '^Status:' | grep ' installed' --quiet
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
installed=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rm -f $STATUS > /dev/null
|
|
|
|
|
|
|
|
echo 101 $1 $installed
|
|
|
|
# Installing if it's not installed
|
|
|
|
if [ $installed == 0 ]; then
|
|
|
|
# TODO noconfirm
|
|
|
|
if [ $TERMUX == 1 ]; then
|
|
|
|
apt install $1 -y
|
|
|
|
else
|
|
|
|
sudo apt-get install $1 -y
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function installFileOne { # file
|
|
|
|
dpkg -i "$1"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function installOne { # package
|
2017-02-12 13:29:03 +01:00
|
|
|
debloc install $1
|
2017-02-12 11:41:03 +01:00
|
|
|
}
|
|
|
|
function installFileOne { # file
|
2017-02-12 13:29:03 +01:00
|
|
|
debloc deb "$1"
|
2017-02-12 11:41:03 +01:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
function altInstallOne {
|
|
|
|
echo "[ERROR] There's no alternate installer for this distribution. Can't install $1."
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo "Uuuh, what kind of distribution is this?"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install package with the standard
|
|
|
|
# package manager for the distribution
|
|
|
|
function inst {
|
|
|
|
for pkg in $*; do
|
|
|
|
installOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install package FILE with the standard
|
|
|
|
# package manager for the distribution
|
|
|
|
function instFile {
|
|
|
|
for pkg in $*; do
|
|
|
|
installFileOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install package with the alternate
|
|
|
|
# package manager for the distribution
|
|
|
|
function altInst {
|
|
|
|
for pkg in $*; do
|
|
|
|
altInstallOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Common CLI
|
|
|
|
|
|
|
|
# Utils
|
2017-02-12 15:14:51 +01:00
|
|
|
inst coreutils man openssl-tool grep sed sh tar
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $TERMUX == 1 ]; then
|
2017-02-12 15:14:51 +01:00
|
|
|
inst termux-api
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $ADMIN == 1 ]; then
|
|
|
|
inst tsu
|
|
|
|
fi
|
|
|
|
fi
|
2017-03-27 10:05:29 +02:00
|
|
|
inst moreutils screen ncdu lsof htop proxytunnel pv curl wget sshfs netcat mosh bash-completion
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $ARCH == 1 ]; then
|
|
|
|
inst gopass
|
|
|
|
else
|
|
|
|
inst pass
|
|
|
|
fi
|
|
|
|
if [[ $ARCH == 1 && $ADMIN == 1 ]]; then
|
|
|
|
inst pkgfile
|
|
|
|
systemctl enable pkgfile-update.timer
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Dev
|
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst build-essential
|
|
|
|
elif [ $ARCH == 1 ]; then
|
|
|
|
inst base-devel
|
|
|
|
else
|
|
|
|
inst make
|
|
|
|
fi
|
2017-02-12 13:29:03 +01:00
|
|
|
inst git
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Text editor
|
|
|
|
if [ $TERMUX == 1 ]; then
|
|
|
|
inst vim-python
|
|
|
|
elif [ $DEBIAN == 1 ]; then
|
2017-02-12 13:29:03 +01:00
|
|
|
inst vim-nox
|
2017-02-12 15:14:51 +01:00
|
|
|
if [ $ADMIN == 0 ]; then
|
|
|
|
debloc altern vim nox
|
|
|
|
fi
|
2017-02-12 11:41:03 +01:00
|
|
|
else
|
|
|
|
inst vim
|
|
|
|
fi
|
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst exuberant-ctags
|
|
|
|
else
|
|
|
|
inst ctags
|
|
|
|
fi
|
|
|
|
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
|
|
|
|
vim +PluginInstall +qall
|
|
|
|
|
|
|
|
# YouCompleteMe (vim plugin)
|
2017-02-12 13:29:03 +01:00
|
|
|
if [ $DEBIAN == 1 || $TERMUX == 1 ]; then
|
|
|
|
inst python-dev python3-dev
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
2017-03-27 10:03:44 +02:00
|
|
|
YCM_ARGS=""
|
2017-02-12 13:29:03 +01:00
|
|
|
if [ $TERMUX != 1 ]; then
|
|
|
|
YCM_ARGS="$YCM_ARGS --clang-completer --tern-completer"
|
|
|
|
fi
|
|
|
|
python $HOME/.vim/bundle/YouCompleteMe/install.py $YCM_ARGS
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
# Common GUI
|
|
|
|
|
|
|
|
if [ $GUI == 1 ]; then
|
|
|
|
# Desktop manager
|
|
|
|
inst i3 i3lock i3status dunst unclutter xautolock feh numlockx scrot
|
2017-07-02 22:06:24 +02:00
|
|
|
if [ $ARCH == 1 ]; then
|
2017-07-03 06:07:02 +02:00
|
|
|
altInst polybar-git ttf-font-awesome
|
2017-07-02 22:06:24 +02:00
|
|
|
else
|
|
|
|
echo "TODO compile polybar-git"
|
|
|
|
fi
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst suckless-tools
|
|
|
|
if [ $ADMIN == 0 ]; then
|
2017-02-12 13:29:03 +01:00
|
|
|
debloc altern dmenu xft
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
inst dmenu
|
|
|
|
fi
|
|
|
|
if [ "$(source /etc/os-release; echo $NAME)" == "Manjaro Linux" ]; then
|
|
|
|
inst menda-themes menda-circle-icon-theme xcursor-menda
|
|
|
|
fi
|
|
|
|
|
|
|
|
# qutebrowser
|
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst python3-lxml python-tox python3-pyqt5 python3-pyqt5.qtwebkit python3-pyqt5.qtquick python3-sip python3-jinja2 python3-pygments python3-yaml
|
|
|
|
TMP_DIR=$(mktemp -d)
|
|
|
|
$(cd $TMP_DIR; wget https://qutebrowser.org/python3-pypeg2_2.15.2-1_all.deb)
|
|
|
|
$(cd $TMP_DIR; wget https://github.com/qutebrowser/qutebrowser/releases/download/v0.9.1/qutebrowser_0.9.1-2_all.deb)
|
|
|
|
instFile $TMP_DIR/*.deb
|
|
|
|
rm -rf $TMP_DIR
|
|
|
|
|
|
|
|
elif [ $ARCH == 1 ]; then
|
2017-06-21 20:02:03 +02:00
|
|
|
inst qutebrowser qt5-webengine
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Screen filter
|
|
|
|
if [ $ARCH == 1 ]; then
|
|
|
|
altInst sct
|
2017-02-12 13:29:03 +01:00
|
|
|
elif [ $TERMUX != 1 ]; then
|
|
|
|
if [ ! -f $HOME/.gscripts/sct ]; then
|
2017-02-12 11:41:03 +01:00
|
|
|
TMP=$(mktemp)
|
|
|
|
wget http://www.tedunangst.com/flak/files/sct.c -O $TMP
|
2017-02-12 13:29:03 +01:00
|
|
|
cc -std=c99 -O2 -I /usr/X11R6/include -o $HOME/.gscripts/sct $TMP -L /usr/X11R6/lib -lm -lX11 -lXrandr
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Graphical vim
|
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst vim-gtk
|
|
|
|
else
|
|
|
|
inst gvim
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $EXTRA == 1 ]; then
|
2017-02-12 13:29:03 +01:00
|
|
|
# Extra dev
|
2017-06-14 13:04:36 +02:00
|
|
|
inst cmake clang llvm npm
|
2017-02-12 13:29:03 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Extra CLI
|
|
|
|
inst sl ffmpeg youtube-dl
|
|
|
|
|
|
|
|
if [ $ARCH == 1 ]; then
|
2017-07-02 22:06:24 +02:00
|
|
|
altInst pdftk translate-shell git-lfs js-beautify insect visidata-git
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Extra GUI
|
|
|
|
if [ $GUI == 1 ]; then
|
|
|
|
inst vlc gimp mpd vimpc
|
|
|
|
|
|
|
|
if [ $ARCH == 1 ]; then
|
|
|
|
inst simplescreenrecorder
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|