Enable icloud.service at boot in installer (systemctl enable + loginctl enable-linger)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
de9f465c42
commit
260f6316f5
1 file changed
+46
-4
+46
-4
@@ -34,7 +34,7 @@ echo " GUI install: $GUI_INSTALL"
|
||||
echo ""
|
||||
|
||||
# ── System dependencies ───────────────────────────────────────────────────────
|
||||
header "1/5 Installing system dependencies"
|
||||
header "1/6 Installing system dependencies"
|
||||
PKGS=(
|
||||
python3
|
||||
python3-venv
|
||||
@@ -55,7 +55,7 @@ sudo apt-get install -y "${PKGS[@]}" 2>&1 | grep -E "(install|already)" || true
|
||||
success "Dependencies installed"
|
||||
|
||||
# ── Clone / update icloud-linux backend ───────────────────────────────────────
|
||||
header "2/5 Installing icloud-linux backend"
|
||||
header "2/6 Installing icloud-linux backend"
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
info "Already cloned — pulling latest"
|
||||
git -C "$INSTALL_DIR" pull --ff-only
|
||||
@@ -72,7 +72,7 @@ python3 -m venv "$INSTALL_DIR/venv"
|
||||
success "Backend ready at $INSTALL_DIR"
|
||||
|
||||
# ── Install the GUI ───────────────────────────────────────────────────────────
|
||||
header "3/5 Installing iCloud Drive GUI"
|
||||
header "3/6 Installing iCloud Drive GUI"
|
||||
mkdir -p "$GUI_INSTALL"
|
||||
|
||||
# Copy the GUI script alongside this installer script
|
||||
@@ -85,7 +85,7 @@ else
|
||||
fi
|
||||
|
||||
# ── Wrapper script in PATH ────────────────────────────────────────────────────
|
||||
header "4/5 Creating launcher"
|
||||
header "4/6 Creating launcher"
|
||||
mkdir -p "$BIN_DIR"
|
||||
cat > "$BIN_DIR/icloud-drive" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
@@ -143,6 +143,46 @@ ICLOUDCTL_PATH="$INSTALL_DIR/icloudctl"
|
||||
sed -i "s|ICLOUDCTL = .*|ICLOUDCTL = \"$ICLOUDCTL_PATH\"|" "$GUI_INSTALL/icloud_gui.py"
|
||||
success "GUI configured to use $ICLOUDCTL_PATH"
|
||||
|
||||
# ── Enable service at boot ─────────────────────────────────────────────────────
|
||||
header "6/6 Enabling iCloud service at boot"
|
||||
|
||||
SERVICE_DIR="$HOME/.config/systemd/user"
|
||||
mkdir -p "$SERVICE_DIR"
|
||||
|
||||
# Only write the service file if icloud-linux provides one; otherwise create it
|
||||
if [ -f "$INSTALL_DIR/icloud-linux/icloud.service" ]; then
|
||||
cp "$INSTALL_DIR/icloud-linux/icloud.service" "$SERVICE_DIR/icloud.service"
|
||||
elif [ ! -f "$SERVICE_DIR/icloud.service" ]; then
|
||||
cat > "$SERVICE_DIR/icloud.service" <<SVCEOF
|
||||
[Unit]
|
||||
Description=iCloud Linux FUSE filesystem (user)
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-/usr/bin/fusermount -uz "%h/iCloud"
|
||||
ExecStop=-/usr/bin/fusermount -uz "%h/iCloud"
|
||||
ExecStart="$INSTALL_DIR/icloud-linux/.venv/bin/python" "$INSTALL_DIR/icloud-linux/driver.py" -f -c "%h/.config/icloud-linux/config.yaml" "%h/iCloud"
|
||||
Restart=on-failure
|
||||
RestartSec=15
|
||||
TimeoutStopSec=10
|
||||
KillMode=control-group
|
||||
ExecStopPost=-/usr/bin/fusermount -uz "%h/iCloud"
|
||||
Environment=ICLOUD_LOG_PATH=%h/.local/state/icloud-linux/icloud.log
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
SVCEOF
|
||||
info "Created systemd service file"
|
||||
fi
|
||||
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable icloud.service
|
||||
# Enable linger so the service starts at boot even before graphical login
|
||||
loginctl enable-linger "$USER" 2>/dev/null || true
|
||||
success "iCloud service enabled at boot (systemctl --user enable icloud.service)"
|
||||
|
||||
# ── Done ──────────────────────────────────────────────────────────────────────
|
||||
header "Installation complete!"
|
||||
echo ""
|
||||
@@ -156,5 +196,7 @@ echo " 3. Go to ${BOLD}Sign In${RESET} and authenticate (handles 2FA)"
|
||||
echo ""
|
||||
echo " 4. On ${BOLD}Dashboard${RESET}, press ${BOLD}Start${RESET} to begin syncing"
|
||||
echo ""
|
||||
echo " The iCloud service will start automatically at every login."
|
||||
echo ""
|
||||
echo " To uninstall, run: $SCRIPT_DIR/uninstall.sh"
|
||||
echo ""
|
||||
Reference in new issue
Block a user