From 773feb2425042b58f5fcc40717c0b52798df172d Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Sun, 28 Nov 2021 12:33:54 +0100 Subject: [PATCH 1/1] init --- copy-new.sh | 21 +++++++++++++++++++++ download.sh | 7 +++++++ fix-latin1.sh | 2 ++ mount-redmi.sh | 6 ++++++ reencode.sh | 14 ++++++++++++++ send-key.sh | 30 ++++++++++++++++++++++++++++++ send-offline.sh | 23 +++++++++++++++++++++++ send-redmi.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 148 insertions(+) create mode 100755 copy-new.sh create mode 100755 download.sh create mode 100755 fix-latin1.sh create mode 100755 mount-redmi.sh create mode 100755 reencode.sh create mode 100755 send-key.sh create mode 100755 send-offline.sh create mode 100755 send-redmi.sh diff --git a/copy-new.sh b/copy-new.sh new file mode 100755 index 0000000..9de3904 --- /dev/null +++ b/copy-new.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -eux +cd "${0%/*}" +rsync -ai \ + --exclude '*.disable' \ + --exclude '*.part' \ + --exclude '*.aria2' \ + --include '.*' \ + --include '*/' \ + --exclude '*' \ + new/ old/ + +# Hardlink files between new/ and old/ +cd new +find . -type d -exec \ +rsync -lptgodDi \ + --exclude '*.disable' \ + --exclude '*.part' \ + --exclude '*.aria2' \ + --link-dest "$PWD"/{}/ \ + {}/ ../old/{}/ \; diff --git a/download.sh b/download.sh new file mode 100755 index 0000000..3c20d35 --- /dev/null +++ b/download.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2016 +set -eux +cd "${0%/*}" +find new -depth -type f -name .feed -printf "%h\0" | sort -z -n | +exec xargs -r -0 -P 0 -I {} -L 1 bash -c 'podl "$1" || true' {} +./reencode.sh diff --git a/fix-latin1.sh b/fix-latin1.sh new file mode 100755 index 0000000..58cdaad --- /dev/null +++ b/fix-latin1.sh @@ -0,0 +1,2 @@ +#!/bin/sh -eux +convmv --fixdouble --replace --notest -f utf-8 -t latin1 -r --exec "mv #1 #2" . diff --git a/mount-redmi.sh b/mount-redmi.sh new file mode 100755 index 0000000..6543738 --- /dev/null +++ b/mount-redmi.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -eux +mkdir -p ~/mnt/redmi +mountpoint ~/mnt/redmi || +go-mtpfs -android ~/mnt/redmi & +disown diff --git a/reencode.sh b/reencode.sh new file mode 100755 index 0000000..6b9c064 --- /dev/null +++ b/reencode.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# shellcheck disable=SC1004 +# shellcheck disable=SC2016 +# shellcheck disable=SC2126 +set -eux +test $# -gt 0 || +set -- "${0%/*}"/{old,new}/audio +find "$@" -depth -type f -name "*.mp3" -print0 | sort -n -z | +xargs -0 -P "$(lscpu --online -p | grep -v "#" | wc -l)" -I {} bash -c ' + nice -n 19 ffmpeg -y -i "$0" \ + -c:a libopus -b:a 64k \ + -application voip "${0%.*}.opus" && + rm -vf "$0" +' {} \; diff --git a/send-key.sh b/send-key.sh new file mode 100755 index 0000000..db672a8 --- /dev/null +++ b/send-key.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2064 +set -eux + +cd "${0%/*}" + +dev=/dev/disk/by-uuid/1AEC-F13E +mnt=$(mktemp -d) +mkdir -p "$mnt" +sudo umount "$dev" || true +trap "sudo umount $mnt && rmdir $mnt && sync" EXIT +sudo mount -v -o uid="$USER",fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush "$dev" "$mnt" + +#./copy-new.sh + +rsync -rv \ + --exclude "*.part" \ + --exclude "*.aria2" \ + --exclude "/audio/RadioFrance/LaSérieDocumentaire/*" \ + --include "/audio/SmashingSecurity/2021-*" \ + --exclude "/audio/SmashingSecurity/*" \ + --include "/audio/NakedSecurity/2021-*" \ + --exclude "/audio/NakedSecurity/*" \ + --include "/audio/FOSSAndCrafts/2021-*" \ + --exclude "/audio/FOSSAndCrafts/*" \ + --exclude ".*" \ + --no-inc-recursive --info=progress2 \ + --size-only --inplace --partial --progress -i \ + new/audio \ + "$mnt"/ diff --git a/send-offline.sh b/send-offline.sh new file mode 100755 index 0000000..3896d03 --- /dev/null +++ b/send-offline.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -eux +cd "${0%/*}" +zfs_mount () { + for d in $(zfs list -rH -o name "$@") + do + mountpoint "/mnt/$d" || + sudo zfs mount -l "$d" + done +} +zpool status off2 || +sudo zpool import off2 +zfs_mount off2/julm/public +# Backup config and cache +rsync -rv \ + --inplace --partial --progress -i \ + --exclude "*" --include ".*" \ + old/{audio,video} /mnt/off2/julm/public +# Move content +rsync -rv --no-inc-recursive --info=progress2 \ + --inplace --partial --progress -i \ + --exclude ".*" --remove-source-files \ + old/{audio,video} /mnt/off2/julm/public diff --git a/send-redmi.sh b/send-redmi.sh new file mode 100755 index 0000000..468e774 --- /dev/null +++ b/send-redmi.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -eux +cd "${0%/*}" + +mkdir -p ~/mnt/redmi +trap "umount ~/mnt/redmi" EXIT +umount ~/mnt/redmi || true +mountpoint ~/mnt/redmi || { + go-mtpfs -android ~/mnt/redmi & +} +sleep 1 +mountpoint ~/mnt/redmi + +./copy-new.sh + +rsync -rv --remove-source-files \ + --exclude "*.part" \ + --exclude "*.aria2" \ + --exclude "LaSérieDocumentaire" \ + --exclude "TousAuLarzac" \ + --exclude "CestCash" \ + --exclude "thinkerview" \ + --include "/audio/SmashingSecurity/2021-*" \ + --exclude "/audio/SmashingSecurity/*" \ + --include "/audio/NakedSecurity/2021-*" \ + --exclude "/audio/NakedSecurity/*" \ + --include "/audio/FOSSAndCrafts/2021-*" \ + --exclude "/audio/FOSSAndCrafts/*" \ + --exclude "/video/fun/fremo/*" \ + --exclude "/video/science/numberphile/*" \ + --exclude "/video/politique/QG/*" \ + --include "/video/science/PrimumNonNocere/2021-*" \ + --exclude "/video/science/PrimumNonNocere/2020-*" \ + --include "/video/science/Asclépios/2021-*" \ + --exclude "/video/science/Asclépios/2020-*" \ + --include "/video/science/LeSenseOfWonder/2022-*" \ + --exclude "/video/science/LeSenseOfWonder/*" \ + --exclude "/video/politique/*" \ + --exclude ".*" \ + --exclude "dn" \ + --exclude "hors-serie" \ + --no-inc-recursive --info=progress2 \ + --size-only --inplace --partial --progress -i \ + new/{audio,video,documents,films} \ + ~/mnt/redmi/"Carte SD SanDisk/Android/data/com.termux/files/" -- 2.47.0