-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·66 lines (55 loc) · 1.71 KB
/
install
File metadata and controls
executable file
·66 lines (55 loc) · 1.71 KB
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
#!/bin/bash
set -e
[ -w /usr/local/lib ] || {
echo "Can't write to /usr/local/lib"
exit 1
}
[ -w /usr/local/bin ] || {
echo "Can't write to /usr/local/bin"
exit 1
}
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# Ensure we're in a git repo
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "Error: Must run from a git repository" >&2
exit 1
fi
# Get all tracked files, excluding non-essential ones
mapfile -t FILES < <(git ls-files | grep -v -E '^(\.|tools/|docs/|.*\.md$|LICENSE|config\.example\.ini)')
# Create installation directory
INSTALL_DIR="/usr/local/lib/ilma"
mkdir -p "$INSTALL_DIR"
# Copy files preserving directory structure
updated_files=()
for file in "${FILES[@]}"; do
target="$INSTALL_DIR/$file"
mkdir -p "$(dirname "$target")"
if [[ ! -f "$target" ]] || ! cmp -s "$file" "$target"; then
cp -a "$file" "$target"
updated_files+=("$file")
fi
done
# Ensure main executable is executable
chmod +x "$INSTALL_DIR/ilma"
# Create symlink
ln -sf "$INSTALL_DIR/ilma" /usr/local/bin/ilma
# Copy starter config to user config directory if it doesn't exist
USER_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/ilma"
USER_CONFIG="$USER_CONFIG_DIR/config.ini"
if [ ! -f "$USER_CONFIG" ]; then
mkdir -p "$USER_CONFIG_DIR"
cp -a "$SCRIPT_DIR/config.example.ini" "$USER_CONFIG"
echo "Created starter config at $USER_CONFIG"
else
echo "Existing config found at $USER_CONFIG (not overwritten)"
fi
if [[ ${#updated_files[@]} -gt 0 ]]; then
echo "Updated ${#updated_files[@]} file(s)"
else
echo "All files up to date"
fi
echo "Installed ilma to /usr/local/bin/ilma"
echo "Run: ilma --help"
echo "Project configs: /usr/local/lib/ilma/configs/"
echo "Run: ilma validate --dependencies"