From 9cb8ce5625409db9ad585ac09940e1dcd822a5f5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 16 Dec 2016 22:24:15 -0500 Subject: [PATCH] os/arch: rewrite and minimalize install script --- os/arch/install | 201 +++++++++++++++--------------------------------- 1 file changed, 60 insertions(+), 141 deletions(-) diff --git a/os/arch/install b/os/arch/install index 5559eb3e..5a57483b 100755 --- a/os/arch/install +++ b/os/arch/install @@ -1,16 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash PWD=$(dirname $0) -pacman="sudo pacman --needed --noconfirm -S" -pacaur="sudo pacaur --needed --noconfirm -y" + +pacman='sudo pacman --needed --noconfirm' +pacaur='pacaur --needed --noconfirm' exists() { command -v "$1" >/dev/null; } -install() { - echo "==> Installing: $@" - sudo pacmaur --needed --noconfirm -S $@ -} - ######################################## # @@ -21,37 +17,47 @@ install() { if ! echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1; then >&2 echo "No internet connection detected!" exit 1 +elif [[ $(id -u) == 0 ]]; then + >&2 echo "Should not be run as root!" + exit 2 fi -## Datetime -sudo timedatectl set-ntp true -sudo timedatectl set-timezone America/Toronto -# Use localtime b/c I expect to dualboot with windows (hisssss) -sudo hwclock --systohc --localtime +# Essential utilities +$pacman -S wget curl tree rsync openssh dnsutils -# Set locale -sed -i '/^#en_US\.UTF-8/s/^#//' /etc/locale.gen -locale-gen -ln -sfv /usr/share/zoneinfo/America/Toronto /etc/localtime -# Be verbose about package updates -sed -i 's/^#\(VerbosePkgLists.*\)/\1/' /etc/pacman.conf - - -## AUR helper -install git -if ! command -v pacaur >/dev/null; then +# Set up pacaur (AUR helper) +if ! exists pacaur; then pushd $(mktemp -d) - gpg --recv-keys --keyserver hkp://pgp.mit.edu 1EB2638FF56C0C53 - git clone https://aur.archlinux.org/cower.git && cd cower && makepkg -sri - git clone https://aur.archlinux.org/pacaur.git && cd pacaur && makepkg -sri + curl -o PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=cower && makepkg --skippgpcheck -sri + curl -o PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pacaur && makepkg --skippgpcheck -sri TEMP=$(pwd) popd rm -rf "$TEMP" + + if ! exists pacaur; then + >&2 echo "Pacaur wasn't successfully installed" + exit 3 + fi fi -## Fontconfig -if ! grep infinality /etc/pacman.conf >/dev/null; then - echo <>/etc/pacman.conf + +## Bootstrap +# Helpful utilities +$pacaur -S the_silver_searcher fasd tmux hub bc keybase cronie +sudo systemctl enable cronie.service + +if [[ -z $SERVER ]]; then + # crontab + if exists crontab; then + [[ -f $PWD/crontab ]] && crontab $PWD/crontab + fi + + # desktop server + $pacman -S xorg-init xorg-server + + # fontconfig + if ! grep infinality /etc/pacman.conf >/dev/null; then + echo < $PWD/.config/panel/panel.secrets