]> git.sev.monster Git - dotfiles.git/blame - install.sh
add random_seed and backup pubring to gpg forward dir
[dotfiles.git] / install.sh
CommitLineData
1b8a4102 1#!/bin/sh
03bc64c4 2
8720834f 3#NOTE: .zshenv XDG paths are hardcoded to allow non-zsh install
4
d23b28eb 5: ${DEST:=$(realpath "$HOME")}
6: ${SRC:=$(dirname "$(realpath "$0")")}
7
84251d17 8# test
fef7b7c4 9devnull=/dev/null
8720834f 10if [ "$1" = "test" ]; then
d23b28eb 11 echo "Running test -- no changes will be applied"
12 devnull=/dev/stdout
13 _cd() {
14 cd $*;
15 echo " cd $*";
16 echo "\$PWD=$PWD";
17 }
18 alias cd="_cd"
19 alias mkdir="echo -- mkdir"
20 alias ln="echo -- ln"
21 alias rm="echo -- rm"
22 alias sh="echo -- sh"
7f359c8a 23fi
24
d50f11d1 25# create preferred folder structure
d23b28eb 26cd $DEST
27mkdir -p bin etc share/fonts share/themes share/icons >$devnull 2>&1
a2a81fa8 28command -v vim >$devnull 2>&1 && mkdir -pm 700 var/tmp/vim >$devnull 2>&1
d23b28eb 29cd $SRC >$devnull
1873e725 30
dcac60d9 31# ensure ostype
74024535 32if [ -z "$OSTYPE" ]; then
d23b28eb 33 OSTYPE=$(uname -s | tr '[:upper:]' '[:lower:]')
74024535 34fi
dcac60d9 35
36# accomodate multiple userlands
37lnargs=-sfnv
d877aef2 38case "$OSTYPE" in
d23b28eb 39 freebsd*) lnargs=-sFhv;;
40 netbsd|openbsd*) lnargs=-sfhv;;
cf9ecb6f 41esac
42
7f359c8a 43l() {
d23b28eb 44 # TODO: use install?
6d54344e 45 d="$DEST/${1:-$x}"
46 [ -L "$d" -o \! -e "$d" ] && ln $lnargs "$SRC/${2:-$x}" "$d" ||
d23b28eb 47 echo "!!! File exists and is not a link: $1"
7f359c8a 48}
49
d23b28eb 50# generic links
51find base -mindepth 1 -maxdepth 1 | while read -r x; do l "${x#base/}"; done
52find bin etc share -mindepth 1 -maxdepth 1 | while read -r x; do l; done
53
54# xorg/wayland resources
6d54344e 55find gui -mindepth 1 -maxdepth 1 | while read -r y; do
56 case "${y#gui/}" in
57 icons|themes)
58 find "$y" -mindepth 1 -maxdepth 2 -type d | while read -r x; do
59 [ ! -e "$x/index.theme" ] && continue
a2a81fa8 60 command -v gtk-update-icon-cache >$devnull 2>&1 &&
6d54344e 61 gtk-update-icon-cache -f "$x"
62 l "share${y#gui}/$(basename "$x")"
63 done
64 ;;
65 fonts)
66 find "$y" -mindepth 1 -maxdepth 2 -type d | while read -r x; do
a2a81fa8 67 command -v mkfontscale >$devnull 2>&1 && mkfontscale "$x"
68 command -v mkfontdir >$devnull 2>&1 && mkfontdir "$x"
6d54344e 69 [ "$(head -1 "$x/fonts.scale" >$devnull 2>&1)" = 0 ] &&
70 rm "$x/fonts.scale"
71 [ "$(head -1 "$x/fonts.dir" >$devnull 2>&1)" = 0 ] &&
72 rm "$x/fonts.dir"
73 l "share${y#gui}/$(basename "$x")"
74 done
75 ;;
76 *)
77 find "$y" -mindepth 1 -maxdepth 1 | while read -r x; do
78 l "share${x#gui}"
79 done
80 ;;
81 esac
ff1a2414 82done
d23b28eb 83
84# gpg
a2a81fa8 85if command -v gpg >$devnull 2>&1; then
d23b28eb 86 mkdir -p "$DEST/etc/gnupg"
87 find gnupg -mindepth 1 -maxdepth 1 \! -name '*.gpg' | while read -r x; do
88 l "etc/$x"
89 done
90 find gnupg -mindepth 1 -maxdepth 1 -name '*.gpg' | while read -r x; do
91 gpg --import "$x"
92 done
372276b7 93fi
d23b28eb 94
95# ssh
96find ssh -mindepth 1 -maxdepth 1 | while read -r x; do
97 l ".$x"; done
98
99# termux, assume it if android
100if [ $(uname -o) = 'Android' ]; then
101 mkdir -p "$DEST/.termux"
102 find termux -mindepth 1 -maxdepth 1 | while read -r x; do
103 l ".$x"; done
104 l ".termux/font.ttf" 'share/fonts/Dina-ttf/Dina.ttf'
105fi
106
107# vim: sts=4 sw=4 et
This page took 0.059288 seconds and 4 git commands to generate.