Compare commits
No commits in common. "de4f965a9853f7b108ec157538385911c09ad3ec" and "e5487d0e273573a547cb9e7979cf4bc014ddc05e" have entirely different histories.
de4f965a98
...
e5487d0e27
3 changed files with 0 additions and 179 deletions
|
|
@ -39,91 +39,6 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
freetube-sync = {
|
||||
enable = true;
|
||||
config = {
|
||||
Label = "local.home-manager.freetube-sync";
|
||||
ProgramArguments = [
|
||||
"/bin/sh"
|
||||
"-c"
|
||||
''
|
||||
FREETUBE_CONFIG_DIR="$HOME/Library/Application Support/FreeTube"
|
||||
NEXTCLOUD_DIR="$HOME/Nextcloud/Settings/FreeTube"
|
||||
|
||||
# Create directories if they don't exist
|
||||
mkdir -p "$FREETUBE_CONFIG_DIR"
|
||||
mkdir -p "$NEXTCLOUD_DIR"
|
||||
|
||||
# List of database files to sync
|
||||
DB_FILES=("settings.db" "history.db" "playlists.db" "subscriptions.db")
|
||||
|
||||
# Initial sync if Nextcloud has db files but FreeTube doesn't
|
||||
if [ -n "$(ls ''$NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ ! -n "$(ls ''$FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||
echo "Performing initial sync from Nextcloud to FreeTube"
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
if [ -f "''$NEXTCLOUD_DIR/''$DB_FILE" ]; then
|
||||
rsync -av --checksum "''$NEXTCLOUD_DIR/''$DB_FILE" "''$FREETUBE_CONFIG_DIR/''$DB_FILE"
|
||||
fi
|
||||
done
|
||||
# If Nextcloud is empty but FreeTube has db files, copy to Nextcloud
|
||||
elif [ ! -n "$(ls ''$NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ -n "$(ls ''$FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||
echo "Performing initial sync from FreeTube to Nextcloud"
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
if [ -f "''$FREETUBE_CONFIG_DIR/''$DB_FILE" ]; then
|
||||
rsync -av --checksum "''$FREETUBE_CONFIG_DIR/''$DB_FILE" "''$NEXTCLOUD_DIR/''$DB_FILE"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Process each database file individually
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
FT_PATH="''$FREETUBE_CONFIG_DIR/''$DB_FILE"
|
||||
NC_PATH="''$NEXTCLOUD_DIR/''$DB_FILE"
|
||||
|
||||
# Skip if neither file exists
|
||||
if [ ! -f "''$FT_PATH" ] && [ ! -f "''$NC_PATH" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If only one exists, copy it
|
||||
if [ -f "''$FT_PATH" ] && [ ! -f "''$NC_PATH" ]; then
|
||||
echo "Copying ''$DB_FILE from FreeTube to Nextcloud"
|
||||
rsync -av "''$FT_PATH" "''$NC_PATH"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ ! -f "''$FT_PATH" ] && [ -f "''$NC_PATH" ]; then
|
||||
echo "Copying ''$DB_FILE from Nextcloud to FreeTube"
|
||||
rsync -av "''$NC_PATH" "''$FT_PATH"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Both files exist, check which is newer
|
||||
if [ "''$FT_PATH" -nt "''$NC_PATH" ]; then
|
||||
echo "Syncing newer ''$DB_FILE from FreeTube to Nextcloud"
|
||||
rsync -av --update "''$FT_PATH" "''$NC_PATH"
|
||||
elif [ "''$NC_PATH" -nt "''$FT_PATH" ]; then
|
||||
echo "Syncing newer ''$DB_FILE from Nextcloud to FreeTube"
|
||||
rsync -av --update "''$NC_PATH" "''$FT_PATH"
|
||||
else
|
||||
# Same modification time, compare checksums
|
||||
echo "Verifying ''$DB_FILE with checksum comparison"
|
||||
rsync -av --checksum "''$NC_PATH" "''$FT_PATH"
|
||||
rsync -av --checksum "''$FT_PATH" "''$NC_PATH"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
''
|
||||
];
|
||||
RunAtLoad = true;
|
||||
StartInterval = 300; # Run every 5 minutes (300 seconds)
|
||||
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/freetube-sync.log";
|
||||
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/freetube-sync-error.log";
|
||||
EnvironmentVariables = {
|
||||
PATH = "${lib.makeBinPath [ pkgs.rsync pkgs.findutils ]}:$PATH";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
programs = {
|
||||
|
|
|
|||
|
|
@ -16,26 +16,20 @@
|
|||
# iucar/rstudio
|
||||
|
||||
# dnf packages:
|
||||
# apptainer
|
||||
# chromium
|
||||
# firefoxpwa - The nix version installs an "immutable" runtime, which simply launches extra browser windows on non-NixOS
|
||||
# inkscape
|
||||
# kate
|
||||
# kdiff3
|
||||
# krita
|
||||
# lutris
|
||||
# musescore
|
||||
# nextcloud-client
|
||||
# nextcloud-client-dolphin
|
||||
# obs-studio
|
||||
# podman-compose
|
||||
# podman-docker
|
||||
# qownnotes
|
||||
# qt
|
||||
# rssguard
|
||||
# rstudio-desktop
|
||||
# steam
|
||||
# supertuxkart
|
||||
# tailscale
|
||||
# thunderbird
|
||||
# vlc
|
||||
|
|
|
|||
|
|
@ -41,94 +41,6 @@ in {
|
|||
};
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
};
|
||||
|
||||
freetube-sync = {
|
||||
Unit = {
|
||||
Description = "Sync FreeTube settings with Nextcloud";
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.writeShellScript "freetube-sync.sh" ''
|
||||
FREETUBE_CONFIG_DIR="$HOME/.var/app/io.freetubeapp.FreeTube/config/FreeTube"
|
||||
NEXTCLOUD_DIR="$HOME/Nextcloud/Settings/FreeTube"
|
||||
|
||||
# Create directories if they don't exist
|
||||
mkdir -p "$FREETUBE_CONFIG_DIR"
|
||||
mkdir -p "$NEXTCLOUD_DIR"
|
||||
|
||||
# List of database files to sync
|
||||
DB_FILES=("settings.db" "history.db" "playlists.db" "subscriptions.db")
|
||||
|
||||
# Initial sync if Nextcloud has db files but FreeTube doesn't
|
||||
if [ -n "$(ls -A $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ ! -n "$(ls -A $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||
echo "Performing initial sync from Nextcloud to FreeTube"
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
if [ -f "$NEXTCLOUD_DIR/$DB_FILE" ]; then
|
||||
rsync -av --checksum "$NEXTCLOUD_DIR/$DB_FILE" "$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||
fi
|
||||
done
|
||||
# If Nextcloud is empty but FreeTube has db files, copy to Nextcloud
|
||||
elif [ ! -n "$(ls -A $NEXTCLOUD_DIR/*.db 2>/dev/null)" ] && [ -n "$(ls -A $FREETUBE_CONFIG_DIR/*.db 2>/dev/null)" ]; then
|
||||
echo "Performing initial sync from FreeTube to Nextcloud"
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
if [ -f "$FREETUBE_CONFIG_DIR/$DB_FILE" ]; then
|
||||
rsync -av --checksum "$FREETUBE_CONFIG_DIR/$DB_FILE" "$NEXTCLOUD_DIR/$DB_FILE"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Process each database file individually
|
||||
for DB_FILE in "''${DB_FILES[@]}"; do
|
||||
FT_PATH="$FREETUBE_CONFIG_DIR/$DB_FILE"
|
||||
NC_PATH="$NEXTCLOUD_DIR/$DB_FILE"
|
||||
|
||||
# Skip if neither file exists
|
||||
if [ ! -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If only one exists, copy it
|
||||
if [ -f "$FT_PATH" ] && [ ! -f "$NC_PATH" ]; then
|
||||
echo "Copying $DB_FILE from FreeTube to Nextcloud"
|
||||
rsync -av "$FT_PATH" "$NC_PATH"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ ! -f "$FT_PATH" ] && [ -f "$NC_PATH" ]; then
|
||||
echo "Copying $DB_FILE from Nextcloud to FreeTube"
|
||||
rsync -av "$NC_PATH" "$FT_PATH"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Both files exist, check which is newer
|
||||
if [ "$FT_PATH" -nt "$NC_PATH" ]; then
|
||||
echo "Syncing newer $DB_FILE from FreeTube to Nextcloud"
|
||||
rsync -av --update "$FT_PATH" "$NC_PATH"
|
||||
elif [ "$NC_PATH" -nt "$FT_PATH" ]; then
|
||||
echo "Syncing newer $DB_FILE from Nextcloud to FreeTube"
|
||||
rsync -av --update "$NC_PATH" "$FT_PATH"
|
||||
else
|
||||
# Same modification time, compare checksums
|
||||
echo "Verifying $DB_FILE with checksum comparison"
|
||||
rsync -av --checksum "$NC_PATH" "$FT_PATH"
|
||||
rsync -av --checksum "$FT_PATH" "$NC_PATH"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
''}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
timers = {
|
||||
freetube-sync = {
|
||||
Unit = { Description = "Timer for FreeTube settings sync"; };
|
||||
Timer = {
|
||||
OnBootSec = "1m";
|
||||
OnUnitActiveSec = "5m";
|
||||
};
|
||||
Install = { WantedBy = [ "timers.target" ]; };
|
||||
};
|
||||
};
|
||||
};
|
||||
xdg = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue