carbs

Cem's Auto Rice Bootstrapping Scripts
git clone git://git.ckyln.com/carbs.git
Log | Files | Refs | README | LICENSE

commit a316218513176453d0dae4d42757307e21e52d89
parent 4ddb34916f95ec643ef05e65bc666505dd43399f
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  7 Oct 2019 15:21:32 +0300

add post-installation scripts

Diffstat:
Mcarbs | 33++++++++++++++++++++++++---------
Apost-install/README | 7+++++++
Apost-install/nvim.sh | 33+++++++++++++++++++++++++++++++++
Apost-install/template | 36++++++++++++++++++++++++++++++++++++
Apost-install/zsh.sh | 31+++++++++++++++++++++++++++++++
5 files changed, 131 insertions(+), 9 deletions(-)

diff --git a/carbs b/carbs @@ -38,6 +38,7 @@ usage: ${0##*/} [options] -n Run the script noninteractively -P <filename> Download progs.csv and exit -k <X11-Keymap> Set X11 Keymap + -s <location> Use an alternative post-install script directory -h/--help Print this help message @@ -51,7 +52,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then exit fi -while getopts ':p::d::r:n:P::k:' flag; do +while getopts ':p::d::r:n:P::k::s:' flag; do case $flag in P) curl -Lo $OPTARG https://git.ckyln.com/raw/carbs/progs.csv && exit || die 'Could not download progs.csv' ;; p) [ -e $OPTARG ] && progs="$(realpath $OPTARG)" || die "Could not find progs.csv file" ;; @@ -59,6 +60,7 @@ while getopts ':p::d::r:n:P::k:' flag; do d) [ -d $OPTARG ] && targetdir="$(realpath $OPTARG)" || die "Target location $OPTARG does not exist or is not a directory" ;; n) sudo -V >/dev/null 2>&1 && interactive=0 || die "Sudo must be installed in order to have a non interactive installation" ;; k) XK=$OPTARG ;; + s) [ -d $OPTARG ] && PIDIR="$(realpath $OPTARG)" || die "Could not find post-install directory" ;; :) die "${0##*/}: option requires an argument -- $OPTARG" ;; ?) die "${0##*/}: invalid option -- $OPTARG" ;; esac @@ -174,12 +176,6 @@ dotfilesinstall() { rm $targetdir/README* $targetdir/LICENSE $targetdir/.git -rf $targetdir/screenshots } -neovimconfig() { - out 'Installing nvim plugins' - curl -fLo $targetdir/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim || error 'Could not download plug.vim' - [ $targetdir = $HOME ] && nvim -c "PlugInstall | :q | :q" && msg 'Installed vim plugs' -} - wallpaperinstall() { out ' Installing wallpapers' mkdir -p $targetdir/Pictures @@ -215,6 +211,26 @@ Carbs is finished, it is best to do a reboot EOF } +postinstall() { + out "Starting post-installation" + if [ -z "$PIDIR" ]; then + cd /tmp + DIR="$(mktemp -d)" + PIDIR="${DIR}/post-install" + git clone git://git.ckyln.com/carbs $DIR >/dev/null + out "Cloning CARBS repository for post-installation scripts" + fi + cd $PIDIR + for script in *; do + case $script in + *.sh) ./${script} $targetdir ;; + README) continue ;; + template) continue ;; + *) warning "$script is not a shell script, not running" ;; + esac + done +} + if [ $interactive = 1 ]; then @@ -225,9 +241,8 @@ sudo pacman -Sy || die 'Could not refresh pacman db' yay -V >/dev/null 2>&1 || installyaybin installcsv dotfilesinstall $dotfiles -nvim -v >/dev/null 2>&1 && neovimconfig || warning 'Not installing nvim plugins' -sudo chsh -s /usr/bin/zsh $USER wallpaperinstall +postinstall keyboardset addusergroups finalize diff --git a/post-install/README b/post-install/README @@ -0,0 +1,7 @@ +CARBS post-install scripts +========================== + +These scripts are run after dotfiles and wallpapers +that are meant to be modular and configurable. There also is +a template file that can be used to write scripts with simple +error handling. diff --git a/post-install/nvim.sh b/post-install/nvim.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +## CARBS, Cem's Auto-Rice Bootstrapping Script +## Copyright (C) 2019 Cem Keylan <cem@ckyln.com> + +## 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 3 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 <https://www.gnu.org/licenses/>. + + +out() { printf "$1\\n"; } +error() { out "==> ERROR: $@"; } >&2 +warning() { out "==> WARNING: $@"; } >&2 +msg() { out "==> $@"; } +msg2() { out " -> $@";} +die() { error "$@"; exit 1; } + +nvim -v >/dev/null 2>&1 || die "nvim does not seem to be installed, stopping script" +out "Installing nvim plugins" +curl -fLO $HOME/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim || die 'Could not download plug.vim' +[ -e $HOME/.config/nvim/init.vim ] || die "init.vim does not exist in home directory" +nvim -c "PlugInstall | :q | :q" +msg "nvim post-installation complete" + diff --git a/post-install/template b/post-install/template @@ -0,0 +1,36 @@ +#!/bin/sh + +## CARBS, Cem's Auto-Rice Bootstrapping Script +## Copyright (C) 2019 Cem Keylan <cem@ckyln.com> + +## 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 3 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 <https://www.gnu.org/licenses/>. + + +out() { printf "$1\\n"; } +error() { out "==> ERROR: $@"; } >&2 +warning() { out "==> WARNING: $@"; } >&2 +msg() { out "==> $@"; } +msg2() { out " -> $@";} +die() { error "$@"; exit 1; } + +# Check if program is installed and exit if it is not installed +## EXAMPLE: +## program -v >/dev/null 2>&1 || die "Program is not installed" + + + +# After the post-installation script is finished, end the +# script with a msg call +## EXAMPLE: +## msg "Finished the configuration of program" diff --git a/post-install/zsh.sh b/post-install/zsh.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +## CARBS, Cem's Auto-Rice Bootstrapping Script +## Copyright (C) 2019 Cem Keylan <cem@ckyln.com> + +## 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 3 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 <https://www.gnu.org/licenses/>. + + +out() { printf "$1\\n"; } +error() { out "==> ERROR: $@"; } >&2 +warning() { out "==> WARNING: $@"; } >&2 +msg() { out "==> $@"; } +msg2() { out " -> $@";} +die() { error "$@"; exit 1; } + +# Check if program is installed and exit if it is not installed +zsh --version >/dev/null 2>&1 || die "zsh is not installed" +sudo chsh -s /usr/bin/zsh $USER || die "Could not change shell" +msg "Changed ${USER}'s shell to zsh" +