-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
executable file
·106 lines (95 loc) · 2.86 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
#
# Zelta Installer
#
# Note that this will clobber /usr/local/share/zelta, /usr/local/bin/zelta, and
# examples, but not other existing files. Keep this in mind if you intend to
# directly modify the installed copies.
if [ root = "$USER" ]; then
: ${ZELTA_BIN:="/usr/local/bin"}
: ${ZELTA_SHARE:="/usr/local/share/zelta"}
: ${ZELTA_ETC:="/usr/local/etc/zelta"}
: ${ZELTA_MAN8:="/usr/local/share/man/man8"}
if [ ! -d "$ZELTA_MAN8" ] ; then
ZELTA_MAN8="/usr/share/man/man8"
fi
elif [ -z "$ZELTA_BIN$ZELTA_SHARE$ZELTA_ETC$ZELTA_DOC" ]; then
: ${ZELTA_BIN:="$HOME/bin"}
: ${ZELTA_SHARE:="$HOME/.local/share/zelta"}
: ${ZELTA_ETC:="$HOME/.config/zelta"}
: ${ZELTA_DOC:="$ZELTA_SHARE/doc"}
echo Installing Zelta as an Unprivileged User
echo
echo To install Zelta as an unprivileged user, follow these steps:
echo
echo 1. Set the following environment variables in your startup script
echo or export them with your desired values:
echo
echo export ZELTA_BIN=\"$ZELTA_BIN\"
echo export ZELTA_SHARE=\"$ZELTA_SHARE\"
echo export ZELTA_ETC=\"$ZELTA_ETC\"
echo export ZELTA_DOC=\"$ZELTA_DOC\"
echo
echo 2. Ensure that \"$ZELTA_BIN\" is in PATH environment variable.
echo
echo Note: If you prefer a global installation, cancel this installation
echo and rerun this command as root, e.g. \`sudo install.sh\`.
echo
echo Proceed with installation?
echo
echo Press Control-C to stop or Return to install using the above paths.
read whatever
fi
: ${ZELTA_CONF:="$ZELTA_ETC/zelta.conf"}
: ${ZELTA_ENV:="$ZELTA_ETC/zelta.env"}
ZELTA="$ZELTA_BIN/zelta"
copy_file() {
if [ -z "$3" ]; then
ZELTA_MODE="755"
else
ZELTA_MODE="$3"
fi
if [ ! -f "$2" ] || [ "$1" -nt "$2" ]; then
echo "installing: $1 -> $2"
cp "$1" "$2"
chmod "$ZELTA_MODE" "$2"
fi
}
link_to_zelta() {
if [ ! -e "$ZELTA_BIN/$1" ]; then
echo "symlinking: $ZELTA -> $1"
ln -s $ZELTA "$ZELTA_BIN/$1"
fi
}
mkdir -p "$ZELTA_BIN" "$ZELTA_SHARE" "$ZELTA_ETC" "$ZELTA_DOC"
copy_file bin/zelta "$ZELTA"
find share/zelta -name '*.awk' -o -name '*.sh' | while read -r file; do
copy_file "$file" "${ZELTA_SHARE}/$(basename "$file")"
done
if [ -x "$ZELTA_MAN8" ] ; then
find doc -name '*.8' | while read -r file; do
copy_file "$file" "${ZELTA_MAN8}/$(basename "$file")"
done
fi
## Old Aliases:
# link_to_zelta zmatch
# link_to_zelta zpull
# link_to_zelta zp
# Environment and default overrides
copy_file zelta.env "${ZELTA_ENV}.example"
if [ ! -s "$ZELTA_ENV" ]; then
copy_file zelta.env "$ZELTA_ENV"
[ -x /usr/bin/time ] || echo 'TIME_COMMAND="zelta time"' >> "$ZELTA_ENV"
fi
# Example zelta policy
copy_file zelta.conf "${ZELTA_CONF}.example" "644"
if [ ! -s "$ZELTA_CONF" ]; then
copy_file zelta.conf "$ZELTA_CONF" "644"
fi
# Add doc if requested
if [ "$ZELTA_DOC" ]; then
mkdir -p "$ZELTA_DOC"
find doc/ -type f | while read -r file; do
copy_file "$file" "${ZELTA_DOC}/$(basename "$file")"
done
fi