Update systemd backup cleanup path from /usr/local/bin to /usr/bin
- Updated install-systemd.sh to use /usr/bin/ddns-backup-cleanup - Updated uninstall-systemd.sh to remove from /usr/bin path - Updated systemd/README.md documentation with correct path - Ensures consistency with debian packaging (already correct) - Formatting verified with cargo fmt --check - Code quality verified with cargo clippy
This commit is contained in:
@@ -376,22 +376,28 @@ impl DdnsApplication {
|
||||
) -> Result<bool, Box<dyn std::error::Error + Send + Sync>> {
|
||||
// Try to resolve the hostname to get the current IP
|
||||
let current_ip = match self.network_service.resolve_hostname(hostname).await {
|
||||
Ok(resolved_ips) => {
|
||||
match resolved_ips.first() {
|
||||
Some(ip) => *ip,
|
||||
None => {
|
||||
eprintln!("Warning: No IPs resolved for {}, using placeholder", hostname);
|
||||
"0.0.0.0".parse()?
|
||||
}
|
||||
Ok(resolved_ips) => match resolved_ips.first() {
|
||||
Some(ip) => *ip,
|
||||
None => {
|
||||
eprintln!(
|
||||
"Warning: No IPs resolved for {}, using placeholder",
|
||||
hostname
|
||||
);
|
||||
"0.0.0.0".parse()?
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("Warning: Failed to resolve {}: {}, using placeholder", hostname, e);
|
||||
eprintln!(
|
||||
"Warning: Failed to resolve {}: {}, using placeholder",
|
||||
hostname, e
|
||||
);
|
||||
"0.0.0.0".parse()?
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Initialize the host file with the resolved IP (or placeholder if resolution failed)
|
||||
self.ip_repository.initialize_host_file(hostname, current_ip).await
|
||||
self.ip_repository
|
||||
.initialize_host_file(hostname, current_ip)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +176,12 @@ impl IpRepository for FileIpRepository {
|
||||
|
||||
// Create an initial entry with the resolved IP (or placeholder if resolution failed)
|
||||
let comment = if resolved_ip.to_string() == "0.0.0.0" {
|
||||
"Initial DNS host file created at first startup (will be updated with real IP)".to_string()
|
||||
"Initial DNS host file created at first startup (will be updated with real IP)"
|
||||
.to_string()
|
||||
} else {
|
||||
"Initial DNS host file created at first startup with resolved IP".to_string()
|
||||
};
|
||||
|
||||
|
||||
let initial_entry = IpEntry::new(
|
||||
resolved_ip, // Use the resolved IP (real or placeholder)
|
||||
hostname.to_string(),
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ systemctl status ddns-backup-cleanup.timer
|
||||
journalctl -u ddns-backup-cleanup.service -f
|
||||
|
||||
# Manual cleanup (dry run)
|
||||
/usr/local/bin/ddns-backup-cleanup --dry-run --verbose
|
||||
/usr/bin/ddns-backup-cleanup --dry-run --verbose
|
||||
|
||||
# Manual cleanup (actual)
|
||||
systemctl start ddns-backup-cleanup.service
|
||||
|
||||
@@ -346,9 +346,9 @@ if [[ "$CLEANUP_ENABLED" == "true" ]]; then
|
||||
# Install cleanup script if in development mode
|
||||
if [ "$DEVELOPMENT_MODE" = true ]; then
|
||||
# Copy cleanup script from local directory
|
||||
cp ddns-backup-cleanup.sh /usr/local/bin/ddns-backup-cleanup
|
||||
chmod +x /usr/local/bin/ddns-backup-cleanup
|
||||
CLEANUP_SCRIPT_PATH="/usr/local/bin/ddns-backup-cleanup"
|
||||
cp ddns-backup-cleanup.sh /usr/bin/ddns-backup-cleanup
|
||||
chmod +x /usr/bin/ddns-backup-cleanup
|
||||
CLEANUP_SCRIPT_PATH="/usr/bin/ddns-backup-cleanup"
|
||||
elif [ -f "/usr/bin/ddns-backup-cleanup" ]; then
|
||||
# Use installed cleanup script
|
||||
CLEANUP_SCRIPT_PATH="/usr/bin/ddns-backup-cleanup"
|
||||
@@ -374,7 +374,7 @@ Group=root
|
||||
|
||||
# Clean up backup files older than $CLEANUP_DAYS days
|
||||
ExecStartPre=/bin/sh -c 'echo "DDNS Cleanup Configuration: Directory=\${DDNS_CLEANUP_BACKUP_DIR}, Retention=\${DDNS_CLEANUP_RETENTION_DAYS} days, Verbose=\${DDNS_CLEANUP_VERBOSE}"'
|
||||
ExecStart=/usr/local/bin/ddns-backup-cleanup --backup-dir "$BACKUP_DIR" --days $CLEANUP_DAYS --verbose
|
||||
ExecStart=/usr/bin/ddns-backup-cleanup --backup-dir "$BACKUP_DIR" --days $CLEANUP_DAYS --verbose
|
||||
Environment=DDNS_CLEANUP_BACKUP_DIR=$BACKUP_DIR
|
||||
Environment=DDNS_CLEANUP_RETENTION_DAYS=$CLEANUP_DAYS
|
||||
Environment=DDNS_CLEANUP_VERBOSE=true
|
||||
@@ -487,7 +487,7 @@ echo " Binary: $BINARY_PATH"
|
||||
if [[ "$CLEANUP_ENABLED" == "true" ]]; then
|
||||
echo " Cleanup Service: /etc/systemd/system/ddns-backup-cleanup.service"
|
||||
echo " Cleanup Timer: /etc/systemd/system/ddns-backup-cleanup.timer"
|
||||
echo " Cleanup Script: /usr/local/bin/ddns-backup-cleanup"
|
||||
echo " Cleanup Script: /usr/bin/ddns-backup-cleanup"
|
||||
fi
|
||||
echo ""
|
||||
echo "=== Management Commands ==="
|
||||
@@ -505,7 +505,7 @@ echo "=== Backup Cleanup Commands ==="
|
||||
echo " Check cleanup status: systemctl status ddns-backup-cleanup.timer"
|
||||
echo " View cleanup logs: journalctl -u ddns-backup-cleanup.service -f"
|
||||
echo " Manual cleanup: systemctl start ddns-backup-cleanup.service"
|
||||
echo " Test cleanup (dry-run): /usr/local/bin/ddns-backup-cleanup --backup-dir $BACKUP_DIR --days $CLEANUP_DAYS --dry-run --verbose"
|
||||
echo " Test cleanup (dry-run): /usr/bin/ddns-backup-cleanup --backup-dir $BACKUP_DIR --days $CLEANUP_DAYS --dry-run --verbose"
|
||||
fi
|
||||
echo ""
|
||||
echo "The service will run every $INTERVAL and check for IP changes on $HOST."
|
||||
|
||||
@@ -102,7 +102,7 @@ rm -f /etc/systemd/system/ddns-backup-cleanup.timer
|
||||
# Remove binaries
|
||||
print_status "Removing binaries..."
|
||||
rm -f /usr/local/bin/ddns_updater
|
||||
rm -f /usr/local/bin/ddns-backup-cleanup
|
||||
rm -f /usr/bin/ddns-backup-cleanup
|
||||
|
||||
# Ask about backup directory
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user