Scripts for sytem installations

This commit is contained in:
Geoffrey Frogeye 2016-12-04 17:24:46 +01:00
parent 75b820f0df
commit 0fadd434da
6 changed files with 330 additions and 33 deletions

View file

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# Installs all programs on the system
function debloc-custom-cli {
# Utils
debloc-install moreutils screen ncdu htop sl proxytunnel pass pv curl
# Text editor
debloc-install vim exuberant-ctags
# Dev
debloc-install build-essential cmake clang llvm git
}
function debloc-custom {
debloc-custom-cli
# Desktop manager
debloc-install i3 i3lock dmenu dunst unclutter xautolock feh numlockx scrot imagemagick suckless-tools
ln -s $DEBLOC_ROOT/bin/dmenu{.xft,}
# qutebrowser
debloc-install python3-lxml python-tox python3-pyqt5 python3-pyqt5.qtwebkit python3-sip python3-jinja2 python3-pygments python3-yaml
TMP_DIR=$(mktemp -d)
$(cd $TMP_DIR; wget --quiet https://qutebrowser.org/python3-pypeg2_2.15.2-1_all.deb)
$(cd $TMP_DIR; wget --quiet https://github.com/The-Compiler/qutebrowser/releases/download/v0.8.4/qutebrowser_0.8.4-1_all.deb)
debloc-deb $TMP_DIR/*.deb
rm -rf $TMP_DIR
}

View file

@ -1,7 +1,11 @@
#!/usr/bin/env bash
# Installs Debian packages on a Debian system
# with no root access, in the user home
# (sourceable)
if [ ! -f /etc/apt/sources.list ]; then
# Not a debian system
# Not a Debian system
return 0
fi

0
scripts/dotfiles.sh Normal file → Executable file
View file

View file

@ -1,4 +1,6 @@
source ~/.scripts/proxy.sh
source ~/.scripts/debloc.sh
source ~/.scripts/debloc-custom.sh
source ~/.scripts/dotfiles.sh
source ~/.scripts/installPreferences.sh
source ~/.scripts/installArch.sh
alias beep=~/.scripts/beep.sh

104
scripts/installArch.sh Executable file
View file

@ -0,0 +1,104 @@
#!/usr/bin/env bash
# Setups an Arch Linux system the way I like it
# (sourceable, requires sudo)
if [[ "$(which pacman) &> /dev/null" == 1 ]]; then
# Not an Arch system
return 0
fi
# Configuration
function install-arch {
# 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
if [[ "$(which yaourt) &> /dev/null" ]]; then
local YAOURT=1
fi
if [[ "$(which bauerbill) &> /dev/null" ]]; then
local BAUERBILL=1
fi
if [ -z $YAOURT ]; then
prompt "Do you want yaourt on this machine?"
local YAOURT=$?
fi
if [ $YAOURT ]; then
if [ -z $BAUERBILL ]; then
prompt "Do you want bauerbill on this machine?"
local BAUERBILL=$?
fi
else
BAUERBILL=0
fi
# COMMON
# Install packages if they aren't installed
function inst {
for pkg in $*; do
pacman -Q $pkg &> /dev/null
if [ $? == 1 ]; then
sudo pacman -S $pkg --noconfirm
fi
done
}
# 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"
}
# SYSTEM
inst wget
if [[ $YAOURT && $(pacman -Q yaourt) == 1 ]]; then
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query"
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt"
fi
if [ $(pacman -Q pamac) == 0 ]; then
sudo pacman -Rsc pamac
fi
if [[ $BAUERBILL && $(pacman -Q bauerbill) == 1 ]]; then
sudo pacman -Sy manjaro-{hotfixes,keyring,release,system} --noconfirm
gpg --recv-keys 1D1F0DC78F173680
installPKGBUILD http://xyne.archlinux.ca/projects/reflector/pkgbuild/PKGBUILD
yaourt -S bauerbill --noconfirm
bb-wrapper -Su
# TODO Prompt if all went well, if not restart
else
sudo pacman -Syu
fi
# Disable predictable network names
sudo ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
# TODO
# make -j8 in MAKEPKG
# time
# nfs
# hibernate
}

218
scripts/installPreferences.sh Executable file
View file

@ -0,0 +1,218 @@
#!/usr/bin/env bash
# Installs user preferences the way I like it
# (sourceable)
function install-preferences {
# 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
if [[ "$(which i3) &> /dev/null" ]]; then
local GUI=1
fi
if [ -z $ADMIN ]; then
prompt "Are you a superuser on this machine?"
local ADMIN=$?
fi
if [ -z $GUI ]; then
prompt "Do you want a X environment on this machine?"
local GUI=$?
fi
if [ -z $EXTRA ]; then
prompt "Do you want not-so-needed software on this machine?"
local EXTRA=$?
fi
# TODO Verify if the package exists before installing it
# System detection
if [[ "$(which pacman) &> /dev/null" ]]; then
ARCH=1
if [ $ADMIN ]; 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"
}
if [ -f /usr/bin/yaourt ]; then
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 ]; then
apt-get update
function installOne { # package
STATUS=$(mktemp)
LANG=C dpkg --list $1 &> $STATUS
if [ $? == 0 ]; then
cat $STATUS | grep '^Status:' | grep ' installed' --quiet
if [ $? == 0 ]; then
# TODO noconfirm
sudo apt-get install $1
fi
fi
rm -f $STATUS > /dev/null
}
function installFileOne { # file
dpkg -i "$1"
}
else
function installOne { # package
debloc-install $1
}
function installFileOne { # file
debloc-deb "$1"
}
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
inst moreutils screen ncdu htop proxytunnel pass pv curl sshfs netcat
# Text editor
inst vim
if [ $ARCH ]; then
inst ctags
else
inst exuberant-ctags
fi
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
# Dev
if [ $DEBIAN ]; then
inst build-essential
elif [ $ARCH ]; then
inst base-devel
fi
inst git cmake clang llvm
# Common GUI
if [ $GUI ]; then
# Desktop manager
inst i3 i3lock dmenu dunst unclutter xautolock feh numlockx scrot
if [ $DEBIAN ]; then
inst suckles-tools
if [ ! $ROOT ]; then
ln -s $DEBLOC_ROOT/bin/dmenu{.xft,}
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 ]; then
inst python3-lxml python-tox python3-pyqt5 python3-pyqt5.qtwebkit python3-sip python3-jinja2 python3-pygments python3-yaml
TMP_DIR=$(mktemp -d)
$(cd $TMP_DIR; wget --quiet https://qutebrowser.org/python3-pypeg2_2.15.2-1_all.deb)
$(cd $TMP_DIR; wget --quiet https://github.com/The-Compiler/qutebrowser/releases/download/v0.8.4/qutebrowser_0.8.4-1_all.deb)
instFile $TMP_DIR/*.deb
rm -rf $TMP_DIR
elif [ $ARCH ]; then
altInst qutebrowser
fi
fi
if [ $EXTRA ]; then
# Extra CLI
inst sl
if [ $ARCH ]; then
altInst pdftk
fi
# Extra GUI
if [ $GUI ]; then
inst vlc gimp mpd vimpc
if [ $ARCH ]; then
inst simplescreenrecorder
fi
fi
fi
}