]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | # test | |
4 | if [ 0 -eq 1 ]; then | |
5 | mkdir() { echo -- "$*"; } | |
6 | alias ln="echo ln" | |
7 | alias rm="echo rm" | |
8 | alias cap_mkdb="echo cap_mkdb" | |
9 | alias unlink="echo unlink" | |
10 | fi | |
11 | ||
12 | # create preferred folder structure | |
13 | cd ~ | |
14 | mkdir -p bin etc share .urxvt/ext .icons .themes > /dev/null 2>&1 | |
15 | mkdir -pm 700 var/tmp var/tmp/vim > /dev/null 2>&1 | |
16 | cd - | |
17 | ||
18 | # accomodate multiple userlands | |
19 | fex='-perm -ugo=x' | |
20 | lnargs=-sfnv | |
21 | if [ -z "$OSTYPE" ]; then | |
22 | OSTYPE=`uname -s | tr '[:upper:]' '[:lower:]'` | |
23 | fi | |
24 | case "$OSTYPE" in | |
25 | # TODO: make links safer for systems without -Fw | |
26 | freebsd*) lnargs=-sFhvw;; | |
27 | netbsd*|openbsd*) lnargs=-sfhv;; | |
28 | # android busybox find doesn't have -executable | |
29 | android) fex=-executable;; | |
30 | esac | |
31 | ||
32 | l() { | |
33 | # TODO: use install? | |
34 | [ -L "$1" -o \! -e "$1" ] && ln $lnargs "${2:-$x}" "$1" | |
35 | } | |
36 | ||
37 | # link files | |
38 | find "$PWD/base" -mindepth 1 -maxdepth 1 | while read -r x; do | |
39 | l "$HOME/`basename "$x"`" | |
40 | done | |
41 | find bin share -mindepth 1 -maxdepth 1 | while read -r x; do | |
42 | l "$HOME/$x" "$PWD/$x" | |
43 | done | |
44 | find "$PWD/xdg" -mindepth 1 -maxdepth 1 | while read -r x; do | |
45 | l "${XDG_CONFIG_HOME:-$HOME/etc}/`basename "$x"`" | |
46 | done | |
47 | find "$PWD/urxvt-ext" -type f $fex -mindepth 1 -maxdepth 2 | while read -r x; do | |
48 | l "$HOME/.urxvt/ext/`basename $x`" | |
49 | done | |
50 | find "$PWD/xorg" -type d -mindepth 3 -maxdepth 3 | while read -r x; do | |
51 | l "$HOME/.icons/`basename $x`" | |
52 | done | |
53 | #TODO: theme | |
54 | ||
55 | cd ~ | |
56 | if [ "$OSTYPE" = "freebsd" ]; then | |
57 | # FreeBSD tries `_secure_path' on `.login_conf' before reading the | |
58 | # database, so it needs to be compiled and unlinked for it to actually | |
59 | # take effect. | |
60 | rm .login_conf.db | |
61 | cap_mkdb .login_conf | |
62 | fi | |
63 | unlink .login_conf | |
64 | # run .zprofile to set up tmp | |
65 | zsh .zprofile | |
66 | cd - |