-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-release.sh
More file actions
139 lines (119 loc) · 4.44 KB
/
Copy pathinstall-release.sh
File metadata and controls
139 lines (119 loc) · 4.44 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -e
# FakeNotify release installer
# Downloads pre-built binaries from GitHub releases
#
# Usage: curl -sSL https://raw.githubusercontent.com/zachhandley/FakeNotify/main/install-release.sh | sudo bash
VERSION="${FAKENOTIFY_VERSION:-latest}"
INSTALL_DIR="/usr/local"
SYSTEMD_DIR="/etc/systemd/system"
CONFIG_DIR="/etc/fakenotify"
REPO="zachhandley/FakeNotify"
OLD_PRELOAD_PATH="/run/fakenotify/libfakenotify_preload.so"
NEW_PRELOAD_PATH="/usr/local/lib/libfakenotify_preload.so"
# Migration function to detect and warn about old paths
migrate_old_paths() {
echo ""
echo "Checking for old FakeNotify paths..."
local found_old=0
# Check environment files
for envfile in /etc/environment ~/.bashrc ~/.zshrc ~/.profile; do
if [ -f "$envfile" ] && grep -q "$OLD_PRELOAD_PATH" "$envfile" 2>/dev/null; then
echo " WARNING: Found old path in $envfile"
echo " Please update LD_PRELOAD to: $NEW_PRELOAD_PATH"
found_old=1
fi
done
# Search for docker-compose files with old path
if command -v find &>/dev/null; then
while IFS= read -r f; do
if [ -n "$f" ] && grep -q "$OLD_PRELOAD_PATH" "$f" 2>/dev/null; then
echo " WARNING: Found old path in $f"
found_old=1
fi
done < <(find /home -maxdepth 4 \( -name "docker-compose*.yml" -o -name "compose*.yml" \) 2>/dev/null | head -20)
fi
# Check systemd override files
if [ -d /etc/systemd/system ]; then
for f in /etc/systemd/system/*.service.d/*.conf /etc/systemd/system/*.service; do
if [ -f "$f" ] && grep -q "$OLD_PRELOAD_PATH" "$f" 2>/dev/null; then
echo " WARNING: Found old path in $f"
found_old=1
fi
done
fi
if [ "$found_old" -eq 1 ]; then
echo ""
echo " To fix, update LD_PRELOAD from:"
echo " $OLD_PRELOAD_PATH"
echo " to:"
echo " $NEW_PRELOAD_PATH"
echo ""
echo " And update volume mounts to:"
echo " - /run/fakenotify:/run/fakenotify:ro"
echo " - /usr/local/lib/libfakenotify_preload.so:/usr/local/lib/libfakenotify_preload.so:ro"
else
echo " No old paths found."
fi
}
# Detect architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
echo "Installing FakeNotify ($TARGET)..."
# Get download URL
if [ "$VERSION" = "latest" ]; then
RELEASE_URL="https://github.com/$REPO/releases/latest/download"
else
RELEASE_URL="https://github.com/$REPO/releases/download/v$VERSION"
fi
# Download binaries
echo "Downloading from $RELEASE_URL..."
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
curl -sSL "$RELEASE_URL/fakenotifyd-$TARGET" -o "$TMP_DIR/fakenotifyd"
curl -sSL "$RELEASE_URL/libfakenotify_preload-$TARGET.so" -o "$TMP_DIR/libfakenotify_preload.so"
# Install binaries
echo "Installing binaries..."
install -Dm755 "$TMP_DIR/fakenotifyd" "$INSTALL_DIR/bin/fakenotifyd"
install -Dm755 "$TMP_DIR/libfakenotify_preload.so" "$INSTALL_DIR/lib/libfakenotify_preload.so"
# Download and install systemd service
echo "Installing systemd service..."
curl -sSL "https://raw.githubusercontent.com/$REPO/main/fakenotify.service" -o "$TMP_DIR/fakenotify.service"
install -Dm644 "$TMP_DIR/fakenotify.service" "$SYSTEMD_DIR/fakenotify.service"
# Create config directory and default config
mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_DIR/config.toml" ]; then
echo "Creating default config..."
cat > "$CONFIG_DIR/config.toml" << 'EOF'
[daemon]
socket = "/run/fakenotify/fakenotify.sock"
log_level = "info"
# Add your NFS paths here:
# [[watch]]
# path = "/mnt/media"
# poll_interval = 5
# recursive = true
EOF
fi
# Reload systemd
systemctl daemon-reload
echo ""
echo "Installation complete!"
echo ""
echo "Next steps:"
echo " 1. Edit /etc/fakenotify/config.toml to add your NFS paths"
echo " 2. Start the daemon: sudo systemctl start fakenotify"
echo " 3. Enable on boot: sudo systemctl enable fakenotify"
echo ""
echo "For Docker containers:"
echo " environment:"
echo " - LD_PRELOAD=/usr/local/lib/libfakenotify_preload.so"
echo " volumes:"
echo " - /run/fakenotify:/run/fakenotify:ro"
echo " - /usr/local/lib/libfakenotify_preload.so:/usr/local/lib/libfakenotify_preload.so:ro"
# Check for old paths that need updating
migrate_old_paths