From 9661927306a17e2f39516c0cb6b8f1e780eae24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Mon, 27 Aug 2018 18:37:14 +0200 Subject: [PATCH] Migrate from gitolite --- etc/conf.d/reflector.conf | 6 + etc/pacman.conf | 100 +++++++++++++++ etc/pacman.d/hooks/mirrorupgrade.hook | 10 ++ etc/skel/.nanorc | 80 ++++++++++++ etc/skel/.zprofile | 2 + etc/skel/.zshenv | 2 + etc/skel/.zshrc | 169 ++++++++++++++++++++++++++ sync.sh | 100 +++++++++++++++ 8 files changed, 469 insertions(+) create mode 100644 etc/conf.d/reflector.conf create mode 100644 etc/pacman.conf create mode 100644 etc/pacman.d/hooks/mirrorupgrade.hook create mode 100644 etc/skel/.nanorc create mode 100644 etc/skel/.zprofile create mode 100644 etc/skel/.zshenv create mode 100644 etc/skel/.zshrc create mode 100755 sync.sh diff --git a/etc/conf.d/reflector.conf b/etc/conf.d/reflector.conf new file mode 100644 index 0000000..40e6190 --- /dev/null +++ b/etc/conf.d/reflector.conf @@ -0,0 +1,6 @@ +COUNTRY=DE +AGE=6 +LATEST=30 +NUMBER=20 +SORT=rate +PROTOCOL=https diff --git a/etc/pacman.conf b/etc/pacman.conf new file mode 100644 index 0000000..273521c --- /dev/null +++ b/etc/pacman.conf @@ -0,0 +1,100 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -C - -f %u > %o +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = auto +Color + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +UseSyslog +Color +TotalDownload +CheckSpace +VerbosePkgLists + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# The testing repositories are disabled by default. To enable, uncomment the +# repo name header and Include lines. You can add preferred servers immediately +# after the header, and they will be used before the default mirrors. + +#[testing] +#Include = /etc/pacman.d/mirrorlist + +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +#[community-testing] +#Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist + +# If you want to run 32 bit applications on your x86_64 system, +# enable the multilib repositories as required here. + +#[multilib-testing] +#Include = /etc/pacman.d/mirrorlist + +[multilib] +Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/custompkgs diff --git a/etc/pacman.d/hooks/mirrorupgrade.hook b/etc/pacman.d/hooks/mirrorupgrade.hook new file mode 100644 index 0000000..fd847c6 --- /dev/null +++ b/etc/pacman.d/hooks/mirrorupgrade.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Upgrade +Type = Package +Target = pacman-mirrorlist + +[Action] +Description = Updating pacman-mirrorlist with reflector and removing pacnew... +When = PostTransaction +Depends = reflector +Exec = /usr/bin/env sh -c "reflector --country 'Germany' --latest 200 --age 24 --sort rate --save /etc/pacman.d/mirrorlist; if [[ -f /etc/pacman.d/mirrorlist.pacnew ]]; then rm /etc/pacman.d/mirrorlist.pacnew; fi" diff --git a/etc/skel/.nanorc b/etc/skel/.nanorc new file mode 100644 index 0000000..39b35b8 --- /dev/null +++ b/etc/skel/.nanorc @@ -0,0 +1,80 @@ +set nowrap +set tabsize 4 +set tabstospaces + +include "/usr/share/nano/*.nanorc" +include /usr/share/nano-syntax-highlighting/privoxy.nanorc +include /usr/share/nano-syntax-highlighting/cmake.nanorc +include /usr/share/nano-syntax-highlighting/puppet.nanorc +include /usr/share/nano-syntax-highlighting/conf.nanorc +include /usr/share/nano-syntax-highlighting/erb.nanorc +include /usr/share/nano-syntax-highlighting/glsl.nanorc +include /usr/share/nano-syntax-highlighting/man.nanorc +include /usr/share/nano-syntax-highlighting/makefile.nanorc +include /usr/share/nano-syntax-highlighting/mpdconf.nanorc +include /usr/share/nano-syntax-highlighting/sed.nanorc +include /usr/share/nano-syntax-highlighting/perl.nanorc +include /usr/share/nano-syntax-highlighting/zsh.nanorc +include /usr/share/nano-syntax-highlighting/csharp.nanorc +include /usr/share/nano-syntax-highlighting/rpmspec.nanorc +include /usr/share/nano-syntax-highlighting/ledger.nanorc +include /usr/share/nano-syntax-highlighting/pkg-config.nanorc +include /usr/share/nano-syntax-highlighting/lisp.nanorc +include /usr/share/nano-syntax-highlighting/ini.nanorc +include /usr/share/nano-syntax-highlighting/scala.nanorc +include /usr/share/nano-syntax-highlighting/xresources.nanorc +include /usr/share/nano-syntax-highlighting/c.nanorc +include /usr/share/nano-syntax-highlighting/python.nanorc +include /usr/share/nano-syntax-highlighting/asciidoc.nanorc +include /usr/share/nano-syntax-highlighting/nginx.nanorc +include /usr/share/nano-syntax-highlighting/gentoo.nanorc +include /usr/share/nano-syntax-highlighting/json.nanorc +include /usr/share/nano-syntax-highlighting/java.nanorc +include /usr/share/nano-syntax-highlighting/cython.nanorc +include /usr/share/nano-syntax-highlighting/haml.nanorc +include /usr/share/nano-syntax-highlighting/php.nanorc +include /usr/share/nano-syntax-highlighting/css.nanorc +include /usr/share/nano-syntax-highlighting/coffeescript.nanorc +include /usr/share/nano-syntax-highlighting/tcl.nanorc +include /usr/share/nano-syntax-highlighting/markdown.nanorc +include /usr/share/nano-syntax-highlighting/Dockerfile.nanorc +include /usr/share/nano-syntax-highlighting/mutt.nanorc +include /usr/share/nano-syntax-highlighting/vala.nanorc +include /usr/share/nano-syntax-highlighting/ruby.nanorc +include /usr/share/nano-syntax-highlighting/keymap.nanorc +include /usr/share/nano-syntax-highlighting/sh.nanorc +include /usr/share/nano-syntax-highlighting/vi.nanorc +include /usr/share/nano-syntax-highlighting/xml.nanorc +include /usr/share/nano-syntax-highlighting/sql.nanorc +include /usr/share/nano-syntax-highlighting/html.nanorc +include /usr/share/nano-syntax-highlighting/yaml.nanorc +include /usr/share/nano-syntax-highlighting/gitcommit.nanorc +include /usr/share/nano-syntax-highlighting/awk.nanorc +include /usr/share/nano-syntax-highlighting/fortran.nanorc +include /usr/share/nano-syntax-highlighting/email.nanorc +include /usr/share/nano-syntax-highlighting/js.nanorc +include /usr/share/nano-syntax-highlighting/sls.nanorc +include /usr/share/nano-syntax-highlighting/kickstart.nanorc +include /usr/share/nano-syntax-highlighting/inputrc.nanorc +include /usr/share/nano-syntax-highlighting/pkgbuild.nanorc +include /usr/share/nano-syntax-highlighting/yum.nanorc +include /usr/share/nano-syntax-highlighting/patch.nanorc +include /usr/share/nano-syntax-highlighting/apacheconf.nanorc +include /usr/share/nano-syntax-highlighting/fish.nanorc +include /usr/share/nano-syntax-highlighting/asm.nanorc +include /usr/share/nano-syntax-highlighting/dot.nanorc +include /usr/share/nano-syntax-highlighting/javascript.nanorc +include /usr/share/nano-syntax-highlighting/pov.nanorc +include /usr/share/nano-syntax-highlighting/groff.nanorc +include /usr/share/nano-syntax-highlighting/lua.nanorc +include /usr/share/nano-syntax-highlighting/reST.nanorc +include /usr/share/nano-syntax-highlighting/peg.nanorc +include /usr/share/nano-syntax-highlighting/perl6.nanorc +include /usr/share/nano-syntax-highlighting/go.nanorc +include /usr/share/nano-syntax-highlighting/systemd.nanorc +include /usr/share/nano-syntax-highlighting/tex.nanorc +include /usr/share/nano-syntax-highlighting/po.nanorc +include /usr/share/nano-syntax-highlighting/nanorc.nanorc +include /usr/share/nano-syntax-highlighting/colortest.nanorc +include /usr/share/nano-syntax-highlighting/zshrc.nanorc +include /usr/share/nano-syntax-highlighting/git.nanorc \ No newline at end of file diff --git a/etc/skel/.zprofile b/etc/skel/.zprofile new file mode 100644 index 0000000..bca40e7 --- /dev/null +++ b/etc/skel/.zprofile @@ -0,0 +1,2 @@ +#!/bin/zsh +loadkeys de diff --git a/etc/skel/.zshenv b/etc/skel/.zshenv new file mode 100644 index 0000000..c3f46ca --- /dev/null +++ b/etc/skel/.zshenv @@ -0,0 +1,2 @@ +# misc +export EDITOR="nano" diff --git a/etc/skel/.zshrc b/etc/skel/.zshrc new file mode 100644 index 0000000..04df62c --- /dev/null +++ b/etc/skel/.zshrc @@ -0,0 +1,169 @@ +# SETTINGS +autoload -U compinit promptinit +autoload -U colors && colors +compinit +promptinit +prompt walters +zstyle ':completion:*' menu select +setopt completealiases +setopt HIST_IGNORE_DUPS + +PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg_no_bold[yellow]%}%1~%{$reset_color%} #" +RPROMPT="[%{$fg_no_bold[yellow]%}%?%{$reset_color%}]" +LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:'; + +# HISTORY +HISTFILE=~/.zsh_history +HISTSIZE=2000 +SAVEHIST=2000 + +# ALIAS +alias ls="ls --color -F" +alias ll="ls --color -lh -a" +alias ll-octal-dir='stat -c "%a %n" *' +alias ip='ip -c' +alias n="nano" +alias ..='cd ..' +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' + +alias e='$EDITOR' +alias edit='$EDITOR' + +alias pac="yay" +alias pkg-upgrade="yay && pacman-orphans && sudo paccache -rk 2 && sync" +alias pkg-upgrade-full="yay -Syyu --devel && pacman-orphans && sudo paccache -rk 2 && sync" +alias pacdiff-merge='sudo DIFFPROG=vimdiff DIFFSEARCHPATH="/boot /etc /usr" pacdiff' +alias font-cache-update='sudo fc-cache -vf' +alias mkinitcpio-linux='sudo mkinitcpio -p linux' +alias systemctl-list-running-services="sudo systemctl --type=service" +alias systemctl-list-units='sudo systemctl list-units' +alias systemctl-list-unit-files='sudo systemctl list-unit-files' +alias systemctl-failed='sudo systemctl --failed' +alias systemctl-daemon-reload='sudo systemctl daemon-reload' +alias journalctl-error='sudo journalctl -b --priority 0..3' +alias journalctl-user='journalctl -b' + +# EXPORTS +export LS_COLORS + +# FUNCTIONS +# systemd +shutdown-timer() { + bash -c 'echo "System is going to shutdown in $1 minute(s)..." + sleep $1m + systemctl poweroff' -- $1 +} + +hibernate-timer() { + bash -c 'echo "System is going to hibernate in $1 minute(s)..." + sleep $1m + systemctl hibernate' -- $1 +} + +shutdown() { + systemctl poweroff +} + +hibernate() { + systemctl hibernate +} + +standby() { + systemctl suspend +} + +restart() { + systemctl reboot +} + +# misc +function chpwd() { + ll +} + +process-name() { + ps -p $1 -o comm= +} + +man() { + env \ + LESS_TERMCAP_mb=$(printf "\e[1;31m") \ + LESS_TERMCAP_md=$(printf "\e[1;31m") \ + LESS_TERMCAP_me=$(printf "\e[0m") \ + LESS_TERMCAP_se=$(printf "\e[0m") \ + LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ + LESS_TERMCAP_ue=$(printf "\e[0m") \ + LESS_TERMCAP_us=$(printf "\e[1;32m") \ + man "$@" +} + +# pacman +pacman-orphans() { + if [[ ! -n $(pacman -Qdt) ]]; then + echo "No orphans to remove." + else + sudo pacman -Rns $(pacman -Qdtq) + fi +} + +pacman-unneeded() { + ignoregrp="base base-devel" + ignorepkg="" + + comm -23 <(pacman -Qqt | sort) <(echo $ignorepkg | tr ' ' '\n' | cat <(pacman -Sqg $ignoregrp) - | sort -u) +} + +pacman-modified() { + pacman -Qii | awk '/^MODIFIED/ {print $2}' +} + +pacman-disowned() { + sudo lostfiles +} + +# SOURCE CUSTOM IMPORTS +if [ -f ~/.zsh_custom ]; then + source ~/.zsh_custom +fi + +# KEYBINDINGS +typeset -A key + +key[Home]=${terminfo[khome]} +key[End]=${terminfo[kend]} +key[Insert]=${terminfo[kich1]} +key[Delete]=${terminfo[kdch1]} +key[Up]=${terminfo[kcuu1]} +key[Down]=${terminfo[kcud1]} +key[Left]=${terminfo[kcub1]} +key[Right]=${terminfo[kcuf1]} +key[PageUp]=${terminfo[kpp]} +key[PageDown]=${terminfo[knp]} + +[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode +[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char +[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history +[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history + +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + function zle-line-init () { + printf '%s' "${terminfo[smkx]}" + } + function zle-line-finish () { + printf '%s' "${terminfo[rmkx]}" + } + zle -N zle-line-init + zle -N zle-line-finish +fi + +# HIGHLIGHTING +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern) +source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh diff --git a/sync.sh b/sync.sh new file mode 100755 index 0000000..c32bfd0 --- /dev/null +++ b/sync.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# Be careful what you are doing with this script. You may overwrite dotfiles. +# cd into the repository before executing the script! +set -e; + +usage() { + echo "Press 1 to sync git folder with /etc"; + echo "Press 2 to sync /etc/skel with all command line users"; + echo "Press 3 to sync /etc/skel with a specific user's home folder" + echo "Press 4 to list command line users for sync"; + echo "---"; + echo "Hit CTRL+C to exit"; +} + +menu() { + usage; + read -n 1 -e -p ">" menuInput + echo ""; + + if [ "$menuInput" = "1" ]; then + sudo rsync -r -t -v --chown=root:root --progress $(pwd)/etc/ /etc/ + echo ""; + elif [ "$menuInput" = "2" ]; then + # require root + [[ $UID -eq 0 ]] || (>&2 echo "ERROR: need to be root!" && exit 1) + + # determine shell + echo "Which shell (shortname, e.g. zsh)?"; + read -e -p ">" shellInput + echo ""; + + # shell users + users=$(cat /etc/passwd|grep $shellInput| awk -F':' '{ print $1 }'); + + # stage + tmpDir=/tmp/dotfiles-system-sync/; + mkdir -p $tmpDir; + srcDir=$(pwd)/etc/skel/. + cp -R $srcDir $tmpDir; + + # copy + for user in $users; do + exists=$(id -u $user); + primaryGroup=$(id -gn $user); + chown -R $user:$primaryGroup $tmpDir; + trgDir=$(eval echo ~$user/); + echo "Copy from $tmpDir to $trgDir"; + cp -Rp $tmpDir/. $trgDir/; + done + + # remove stage + rm -rf $tmpDir; + elif [ "$menuInput" = "3" ]; then + # determine shell + echo "Which user?"; + read -e -p ">" user + echo ""; + + # stage + tmpDir=/tmp/dotfiles-system-sync/; + mkdir -p $tmpDir; + srcDir=$(pwd)/etc/skel/. + cp -R $srcDir $tmpDir; + + # copy + exists=$(id -u $user); + + if [ $UID -ne $exists ] && [ $UID -ne 0 ]; then + echo "ERROR: need to be $user or root!"; + exit 1; + fi + + primaryGroup=$(id -gn $user); + chown -R $user:$primaryGroup $tmpDir; + trgDir=$(eval echo ~$user/); + echo "Copy from $tmpDir to $trgDir"; + cp -Rp $tmpDir/. $trgDir/; + + # remove stage + rm -rf $tmpDir; + + elif [ "$menuInput" = "4" ]; then + echo "Which shell (shortname, e.g. zsh)?"; + read -e -p ">" shellInput + echo ""; + + # shell users + users=$(cat /etc/passwd|grep $shellInput| awk -F':' '{ print $1 }'); + echo "Users with shell $shellInput" + + for u in $users; do + echo $u; + done + + fi + + menu; +} + +menu;