]>
Commit | Line | Data |
---|---|---|
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 | 9 | devnull=/dev/null |
8720834f | 10 | if [ "$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 | 23 | fi |
24 | ||
d50f11d1 | 25 | # create preferred folder structure |
d23b28eb | 26 | cd $DEST |
27 | mkdir -p bin etc share/fonts share/themes share/icons >$devnull 2>&1 | |
28 | which vim >$devnull 2>&1 && mkdir -pm 700 var/tmp/vim >$devnull 2>&1 | |
29 | cd $SRC >$devnull | |
1873e725 | 30 | |
dcac60d9 | 31 | # ensure ostype |
74024535 | 32 | if [ -z "$OSTYPE" ]; then |
d23b28eb | 33 | OSTYPE=$(uname -s | tr '[:upper:]' '[:lower:]') |
74024535 | 34 | fi |
dcac60d9 | 35 | |
36 | # accomodate multiple userlands | |
37 | lnargs=-sfnv | |
d877aef2 | 38 | case "$OSTYPE" in |
d23b28eb | 39 | freebsd*) lnargs=-sFhv;; |
40 | netbsd|openbsd*) lnargs=-sfhv;; | |
cf9ecb6f | 41 | esac |
42 | ||
7f359c8a | 43 | l() { |
d23b28eb | 44 | # TODO: use install? |
45 | [ -L "$1" -o \! -e "$1" ] && ln $lnargs "$SRC/${2:-$x}" "$DEST/${1:-$x}" || | |
46 | echo "!!! File exists and is not a link: $1" | |
7f359c8a | 47 | } |
48 | ||
d23b28eb | 49 | # generic links |
50 | find base -mindepth 1 -maxdepth 1 | while read -r x; do l "${x#base/}"; done | |
51 | find bin etc share -mindepth 1 -maxdepth 1 | while read -r x; do l; done | |
52 | ||
53 | # xorg/wayland resources | |
54 | find gui -mindepth 1 -maxdepth 1 | while read -r x; do | |
55 | if [ "$x" = gui/fonts ]; then | |
56 | find $x -mindepth 1 -maxdepth 2 -type d | while read -r x; do | |
57 | which mkfontscale >$devnull 2>&1 && mkfontscale "$x" | |
58 | which mkfontdir >$devnull 2>&1 && mkfontdir "$x" | |
59 | [ "$(head -1 "$x/fonts.dir")" = 0 ] && | |
60 | rm "$x/fonts.dir" | |
61 | [ "$(head -1 "$x/fonts.scale")" = 0 ] && | |
62 | rm "$x/fonts.scale" | |
63 | done | |
64 | elif [ "$x" = gui/icons ]; then | |
65 | find $x -mindepth 1 -maxdepth 2 -type d | while read -r x; do | |
66 | [ ! -e "$x/index.theme" ] && continue | |
67 | which gtk-update-icon-cache >$devnull 2>&1 && | |
68 | gtk-update-icon-cache "$x" | |
69 | done | |
70 | fi | |
71 | find "$x" -mindepth 1 -maxdepth 1 | while read -r x; do | |
72 | l "share${x#gui}" | |
73 | done | |
ff1a2414 | 74 | done |
d23b28eb | 75 | |
76 | # gpg | |
77 | if which gpg >$devnull 2>&1; then | |
78 | mkdir -p "$DEST/etc/gnupg" | |
79 | find gnupg -mindepth 1 -maxdepth 1 \! -name '*.gpg' | while read -r x; do | |
80 | l "etc/$x" | |
81 | done | |
82 | find gnupg -mindepth 1 -maxdepth 1 -name '*.gpg' | while read -r x; do | |
83 | gpg --import "$x" | |
84 | done | |
372276b7 | 85 | fi |
d23b28eb | 86 | |
87 | # ssh | |
88 | find ssh -mindepth 1 -maxdepth 1 | while read -r x; do | |
89 | l ".$x"; done | |
90 | ||
91 | # termux, assume it if android | |
92 | if [ $(uname -o) = 'Android' ]; then | |
93 | mkdir -p "$DEST/.termux" | |
94 | find termux -mindepth 1 -maxdepth 1 | while read -r x; do | |
95 | l ".$x"; done | |
96 | l ".termux/font.ttf" 'share/fonts/Dina-ttf/Dina.ttf' | |
97 | fi | |
98 | ||
99 | # vim: sts=4 sw=4 et |