mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 19:07:04 +01:00
i3 config was filed under periodic_background, which it never was. It is now linux_configuration/i3/ (config + installer) and linux_configuration/i3blocks/ (the status scripts), both at depth 2. misc/testsAndMisc-bash/ was a directory named after the repo it already lived in, so its contents moved up to misc/. Its stray .gitignore came along, keeping the media rules working from the new location; its .vscode/tasks.json did not, because it invoked Bash/transcribe.sh, a path this repo dropped long ago. Most of this commit is the references the previous flatten missed. Its regex skipped anything with a variable prefix, which left 16 files -- including check_and_enable_services.sh and install_core_system.sh, the orchestrators -- still naming $CONFIG_DIR/scripts/periodic_background/... It had also rewritten three i3 paths into scripts/i3blocks/, a directory that has never existed; the i3blocks suites caught that by failing. 13 more symlinks broke on the i3 move. Repointed, and cpu_monitor/volume/ disk were run again to confirm the bar still reports. Depth 139 -> 104. Roughly 47 of the remainder sit in digital_wellbeing and hosts, still deferred. The rest encode real structure -- a C project, Python package directories, artgate's routes/styles, systemd unit dirs -- so flattening them further would destroy information rather than taxonomy. Verified: 1798 tests at 100%, both i3blocks suites pass, the shell coverage gate is clean, and the relocated media rules still ignore what they should while test_fw.srt stays tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
95 lines
2.4 KiB
Bash
Executable File
95 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Fix script for media-organizer.service
|
|
# The service was failing due to:
|
|
# 1. Corrupted ExecStart path (line break in the middle)
|
|
# 2. Wrong script path (missing 'utils/' directory)
|
|
# 3. User/Group set to root instead of actual user
|
|
|
|
set -euo pipefail
|
|
|
|
SERVICE_NAME="media-organizer"
|
|
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
|
|
|
DEFAULT_ORGANIZE_SCRIPT="/home/kuhy/testsAndMisc/linux_configuration/utils/organize_downloads.sh"
|
|
LEGACY_ORGANIZE_SCRIPT="/home/kuhy/linux-configuration/utils/organize_downloads.sh"
|
|
if [[ -f $DEFAULT_ORGANIZE_SCRIPT ]]; then
|
|
ORGANIZE_SCRIPT="$DEFAULT_ORGANIZE_SCRIPT"
|
|
elif [[ -f $LEGACY_ORGANIZE_SCRIPT ]]; then
|
|
ORGANIZE_SCRIPT="$LEGACY_ORGANIZE_SCRIPT"
|
|
else
|
|
ORGANIZE_SCRIPT="$DEFAULT_ORGANIZE_SCRIPT"
|
|
fi
|
|
|
|
TARGET_USER="${SUDO_USER:-kuhy}"
|
|
|
|
log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
|
}
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
log "This script needs to be run as root."
|
|
log "Re-executing with sudo..."
|
|
exec sudo "$0" "$@"
|
|
fi
|
|
|
|
log "Fixing media-organizer.service..."
|
|
|
|
# Verify the organize_downloads.sh script exists
|
|
if [[ ! -f $ORGANIZE_SCRIPT ]]; then
|
|
log "ERROR: organize_downloads.sh not found at $ORGANIZE_SCRIPT"
|
|
exit 1
|
|
fi
|
|
|
|
# Stop the service if running (ignore errors)
|
|
systemctl stop "$SERVICE_NAME.service" 2>/dev/null || true
|
|
|
|
# Recreate the service file with correct configuration
|
|
cat >"$SERVICE_FILE" <<EOF
|
|
[Unit]
|
|
Description=Media File Organizer
|
|
After=graphical-session.target
|
|
Wants=graphical-session.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
User=$TARGET_USER
|
|
Group=$TARGET_USER
|
|
ExecStart=$ORGANIZE_SCRIPT
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
RemainAfterExit=no
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
log "Recreated service file: $SERVICE_FILE"
|
|
|
|
# Reload systemd daemon
|
|
systemctl daemon-reload
|
|
log "Reloaded systemd daemon"
|
|
|
|
# Reset the failed state
|
|
systemctl reset-failed "$SERVICE_NAME.service" 2>/dev/null || true
|
|
log "Reset failed state"
|
|
|
|
# Re-enable the service
|
|
systemctl enable "$SERVICE_NAME.service"
|
|
log "Service enabled"
|
|
|
|
# Optionally start the service to verify it works
|
|
log "Starting service to verify fix..."
|
|
if systemctl start "$SERVICE_NAME.service"; then
|
|
log "SUCCESS: media-organizer.service started successfully!"
|
|
else
|
|
log "WARNING: Service still has issues. Check: journalctl -u $SERVICE_NAME"
|
|
fi
|
|
|
|
# Show current status
|
|
log "Current service status:"
|
|
systemctl status "$SERVICE_NAME.service" --no-pager || true
|
|
|
|
log "Fix complete!"
|