File size: 1,862 Bytes
a9b851c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

set -e

# Function for logging
log() {
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] [WEBDAV] $*"
}

# Function for cleanup
cleanup() {
    log "Performing WebDAV installation cleanup..."
    rm -rf /tmp/flydav* /tmp/webdav* /tmp/*.zip
}

# Trap to ensure cleanup on exit
trap cleanup EXIT

log "Starting WebDAV (FlyDAV) installation..."

# Detect architecture
ARCH=$(uname -m)
case $ARCH in
    x86_64)
        BINARY_ARCH="amd64"
        ;;
    aarch64|arm64)
        BINARY_ARCH="arm64"
        ;;
    armv7l)
        BINARY_ARCH="arm"
        ;;
    *)
        log "ERROR: Unsupported architecture: $ARCH"
        exit 1
        ;;
esac

log "Installing for architecture: $ARCH (binary: $BINARY_ARCH)"

# Download FlyDAV binary
FLYDAV_VERSION="v0.2.56"
DOWNLOAD_URL="https://github.com/pluveto/flydav/releases/download/${FLYDAV_VERSION}/flydav-app-linux-${BINARY_ARCH}.zip"

log "Downloading FlyDAV $FLYDAV_VERSION for $BINARY_ARCH..."
cd /tmp
curl -L -o "flydav.zip" "$DOWNLOAD_URL"

# Extract and install
log "Extracting FlyDAV..."
unzip -q flydav.zip
chmod +x flydav

# Install to system path accessible by non-root user
log "Installing FlyDAV binary..."
mkdir -p /usr/local/bin
mv flydav /usr/local/bin/flydav

# Verify installation
log "Verifying FlyDAV installation..."
if command -v flydav >/dev/null 2>&1; then
    FLYDAV_VERSION_CHECK=$(flydav --version 2>&1 || echo "FlyDAV installed")
    log "FlyDAV installed successfully: ${FLYDAV_VERSION_CHECK}"
else
    log "ERROR: FlyDAV installation failed"
    exit 1
fi

# Create directories that will be owned by user 1000
log "Creating WebDAV directories..."
mkdir -p /home/user/webdav /home/user/webdav/data /home/user/webdav/config
chown -R 1000:1000 /home/user/webdav

log "WebDAV (FlyDAV) installation completed successfully"
log "Version: $FLYDAV_VERSION"
log "Architecture: $BINARY_ARCH"